Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eclipse/openpass/mantle-api
  • adascri/scenario_api
  • jtschea/scenario_api
  • mstump/mantle-api
  • xiaopan/scenario_api
  • AndreasB/scenario_api
  • kcantero/scenario_api
  • dweiwg6/scenario_api
  • shankarpatali/mantle-api
  • etiennep/mantle-api
  • nutario/mantle-api
  • rbiegel/mantle-api
  • nmraghu/mantle-api
  • rparisha2/mantle-api
  • naidagoro/mantle-api
  • kim10101/mantle-api
  • mbehrischv52/mantle-api
  • khbner/mantle-api
  • lappino/mantle-api
  • anastasiiavolkova/mantle-api
  • daniilnikulin/mantle-api
  • mkellerer/mantle-api
  • ansssardesa/mantle-api
  • tonweenink/mantle-api
24 results
Show changes
Commits on Source (2)
Showing
with 794 additions and 0 deletions
......@@ -6,3 +6,4 @@ BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Allman
ColumnLimit: 0
SeparateDefinitionBlocks: Always
......@@ -31,3 +31,5 @@ target_link_libraries(MantleAPITest PUBLIC MantleAPI::MantleAPI GTest::gmock_mai
include(GoogleTest)
gtest_discover_tests(MantleAPITest)
add_subdirectory(MantleAPI)
################################################################################
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
#
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
################################################################################
add_subdirectory(Common)
add_subdirectory(Execution)
add_subdirectory(Traffic)
add_subdirectory(Map)
################################################################################
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
#
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
################################################################################
add_executable(CommonTest)
target_sources(CommonTest PUBLIC identifiable_test.cc)
target_include_directories(CommonTest PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/test>)
target_link_libraries(CommonTest PUBLIC MantleAPI::MantleAPI GTest::gmock_main)
include(GoogleTest)
gtest_discover_tests(CommonTest)
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <string>
#include "MantleAPI/Common/mock_identifiable.h"
namespace
{
using testing::_;
using testing::Const;
using testing::DefaultValue;
using testing::Return;
using testing::ReturnRef;
class IdentifiableTest : public testing::Test
{
protected:
mantle_api::MockIdentifiable mock_identifiable_;
mantle_api::IIdentifiable& identifiable_{mock_identifiable_};
};
TEST_F(IdentifiableTest, GetUniqueId)
{
EXPECT_CALL(Const(mock_identifiable_), GetUniqueId()) //
.Times(1)
.WillOnce(Return(mantle_api::UniqueId{}));
std::ignore = identifiable_.GetUniqueId();
}
TEST_F(IdentifiableTest, SetName)
{
EXPECT_CALL(mock_identifiable_, SetName(_)).Times(1);
identifiable_.SetName({});
}
TEST_F(IdentifiableTest, GetName)
{
const auto default_string = std::string{"default_string"};
DefaultValue<const std::string&>::Set(default_string);
EXPECT_CALL(Const(mock_identifiable_), GetName()) //
.Times(1)
.WillOnce(ReturnRef(default_string));
std::ignore = identifiable_.GetName();
DefaultValue<const std::string&>::Clear();
}
} // namespace
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <gmock/gmock.h>
#include "MantleAPI/Common/i_identifiable.h"
namespace mantle_api
{
class MockIdentifiable final : public IIdentifiable
{
public:
MOCK_METHOD(UniqueId, GetUniqueId, (), (const, override));
MOCK_METHOD(void, SetName, (const std::string& name), (override));
MOCK_METHOD(const std::string&, GetName, (), (const, override));
};
} // namespace mantle_api
################################################################################
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
#
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
################################################################################
add_executable(ExecutionTest)
target_sources(ExecutionTest PUBLIC environment_test.cc)
target_include_directories(ExecutionTest PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/test>)
target_link_libraries(ExecutionTest PUBLIC MantleAPI::MantleAPI GTest::gmock_main)
include(GoogleTest)
gtest_discover_tests(ExecutionTest)
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "MantleAPI/Execution/mock_environment.h"
#include "MantleAPI/Map/mock_lane_location_query_service.h"
#include "MantleAPI/Traffic/mock_entity.h"
namespace
{
using testing::_;
using testing::Const;
using testing::DefaultValue;
using testing::Return;
using testing::ReturnRef;
class EnvironmentTest : public testing::Test
{
protected:
mantle_api::MockEnvironment mock_environment_;
mantle_api::IEnvironment& environment_{mock_environment_};
};
TEST_F(EnvironmentTest, CreateMap)
{
EXPECT_CALL(mock_environment_, CreateMap(_, _)).Times(1);
environment_.CreateMap({}, {});
}
TEST_F(EnvironmentTest, AddEntityToController)
{
EXPECT_CALL(mock_environment_, AddEntityToController(_, _)).Times(1);
auto entity = mantle_api::MockEntity{};
environment_.AddEntityToController(entity, {});
}
TEST_F(EnvironmentTest, RemoveControllerFromEntity)
{
EXPECT_CALL(mock_environment_, RemoveControllerFromEntity(_)).Times(1);
environment_.RemoveControllerFromEntity({});
}
TEST_F(EnvironmentTest, UpdateControlStrategies)
{
EXPECT_CALL(mock_environment_, UpdateControlStrategies(_, _)).Times(1);
environment_.UpdateControlStrategies({}, {});
}
TEST_F(EnvironmentTest, HasControlStrategyGoalBeenReached)
{
EXPECT_CALL(Const(mock_environment_), HasControlStrategyGoalBeenReached(_, _)) //
.Times(1)
.WillOnce(Return(true));
std::ignore = environment_.HasControlStrategyGoalBeenReached({}, {});
}
TEST_F(EnvironmentTest, GetQueryService)
{
const auto mock_lane_location_query_service = mantle_api::MockLaneLocationQueryService{};
DefaultValue<const mantle_api::ILaneLocationQueryService&>::Set(mock_lane_location_query_service);
EXPECT_CALL(Const(mock_environment_), GetQueryService()).Times(1).WillOnce(ReturnRef(mock_lane_location_query_service));
std::ignore = environment_.GetQueryService();
DefaultValue<const mantle_api::ILaneLocationQueryService&>::Clear();
}
TEST_F(EnvironmentTest, GetConverter)
{
EXPECT_CALL(Const(mock_environment_), GetConverter()) //
.Times(1)
.WillOnce(Return(nullptr));
std::ignore = environment_.GetConverter();
}
TEST_F(EnvironmentTest, GetGeometryHelper)
{
EXPECT_CALL(mock_environment_, GetGeometryHelper()) //
.Times(1)
.WillOnce(Return(nullptr));
std::ignore = environment_.GetGeometryHelper();
}
TEST_F(EnvironmentTest, DISABLED_GetEntityRepository) // FIXME: Missing MockEntityRepository
{
EXPECT_CALL(Const(mock_environment_), GetEntityRepository()).Times(1);
std::ignore = environment_.GetEntityRepository();
}
TEST_F(EnvironmentTest, DISABLED_GetControllerRepository) // FIXME: Missing MockControllerRepository
{
EXPECT_CALL(Const(mock_environment_), GetControllerRepository()).Times(1);
std::ignore = environment_.GetControllerRepository();
}
TEST_F(EnvironmentTest, SetDateTime)
{
EXPECT_CALL(mock_environment_, SetDateTime(_)).Times(1);
environment_.SetDateTime({});
}
TEST_F(EnvironmentTest, GetDateTime)
{
EXPECT_CALL(mock_environment_, GetDateTime()) //
.Times(1)
.WillOnce(Return(mantle_api::Time{}));
std::ignore = environment_.GetDateTime();
}
TEST_F(EnvironmentTest, GetSimulationTime)
{
EXPECT_CALL(mock_environment_, GetSimulationTime()) //
.Times(1)
.WillOnce(Return(mantle_api::Time{}));
std::ignore = environment_.GetSimulationTime();
}
} // namespace
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <gmock/gmock.h>
#include <optional>
#include <string>
#include "MantleAPI/Execution/i_environment.h"
namespace mantle_api
{
class MockEnvironment : public IEnvironment
{
public:
MOCK_METHOD(void, CreateMap, (const std::string& map_file_path, const mantle_api::MapDetails& map_details), (override));
MOCK_METHOD(void, AddEntityToController, (IEntity & entity, UniqueId controller_id), (override));
MOCK_METHOD(void, RemoveControllerFromEntity, (UniqueId entity_id), (override));
MOCK_METHOD(void, UpdateControlStrategies, (UniqueId entity_id, std::vector<std::shared_ptr<mantle_api::ControlStrategy>> control_strategies), (override));
MOCK_METHOD(bool, HasControlStrategyGoalBeenReached, (UniqueId entity_id, mantle_api::ControlStrategyType type), (const, override));
MOCK_METHOD(const ILaneLocationQueryService&, GetQueryService, (), (const, override));
MOCK_METHOD(const ICoordConverter*, GetConverter, (), (const, override));
MOCK_METHOD(const IGeometryHelper*, GetGeometryHelper, (), (const, override));
MOCK_METHOD(IEntityRepository&, GetEntityRepository, (), (override));
MOCK_METHOD(const IEntityRepository&, GetEntityRepository, (), (const, override));
MOCK_METHOD(IControllerRepository&, GetControllerRepository, (), (override));
MOCK_METHOD(const IControllerRepository&, GetControllerRepository, (), (const, override));
MOCK_METHOD(void, SetDateTime, (mantle_api::Time time), (override));
MOCK_METHOD(mantle_api::Time, GetDateTime, (), (override));
MOCK_METHOD(mantle_api::Time, GetSimulationTime, (), (override));
MOCK_METHOD(void, SetWeather, (Weather weather), (override));
MOCK_METHOD(void, SetRoadCondition, (std::vector<FrictionPatch> friction_patches), (override));
MOCK_METHOD(void, SetTrafficSignalState, (const std::string& traffic_signal_name, const std::string& traffic_signal_state), (override));
MOCK_METHOD(void, ExecuteCustomCommand, (const std::vector<std::string>& actors, const std::string& type, const std::string& command), (override));
MOCK_METHOD(void, SetUserDefinedValue, (const std::string& name, const std::string& value), (override));
MOCK_METHOD(std::optional<std::string>, GetUserDefinedValue, (const std::string& name), (override));
MOCK_METHOD(void, SetDefaultRoutingBehavior, (mantle_api::DefaultRoutingBehavior default_routing_behavior), (override));
MOCK_METHOD(void, AssignRoute, (mantle_api::UniqueId entity_id, mantle_api::RouteDefinition route_definition), (override));
};
} // namespace mantle_api
################################################################################
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
#
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
################################################################################
add_executable(MapTest)
target_sources(MapTest PUBLIC lane_location_query_service_test.cc)
target_include_directories(MapTest PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/test>)
target_link_libraries(MapTest PUBLIC MantleAPI::MantleAPI GTest::gmock_main)
include(GoogleTest)
gtest_discover_tests(MapTest)
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <string>
#include "MantleAPI/Map/mock_lane_location_query_service.h"
namespace
{
using testing::_;
using testing::Const;
using testing::Return;
class LaneLocationQueryServiceTest : public testing::Test
{
protected:
mantle_api::MockLaneLocationQueryService mock_lane_location_query_service_;
mantle_api::ILaneLocationQueryService& lane_location_query_service_{mock_lane_location_query_service_};
};
TEST_F(LaneLocationQueryServiceTest, GetLaneOrientation)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), GetLaneOrientation(_)) //
.Times(1)
.WillOnce(Return(mantle_api::Orientation3<units::angle::radian_t>{}));
std::ignore = lane_location_query_service_.GetLaneOrientation({});
}
TEST_F(LaneLocationQueryServiceTest, GetUpwardsShiftedLanePosition)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), GetUpwardsShiftedLanePosition(_, _, _)) //
.Times(1)
.WillOnce(Return(mantle_api::Vec3<units::length::meter_t>{}));
std::ignore = lane_location_query_service_.GetUpwardsShiftedLanePosition({}, {}, {});
}
TEST_F(LaneLocationQueryServiceTest, IsPositionOnLane)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), IsPositionOnLane(_)) //
.Times(1)
.WillOnce(Return(true));
std::ignore = lane_location_query_service_.IsPositionOnLane({});
}
TEST_F(LaneLocationQueryServiceTest, GetLaneIdsAtPosition)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), GetLaneIdsAtPosition(_)) //
.Times(1)
.WillOnce(Return(std::vector<mantle_api::UniqueId>{}));
std::ignore = lane_location_query_service_.GetLaneIdsAtPosition({});
}
TEST_F(LaneLocationQueryServiceTest, FindLanePoseAtDistanceFrom)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), FindLanePoseAtDistanceFrom(_, _, _)) //
.Times(1)
.WillOnce(Return(std::optional<mantle_api::Pose>{}));
std::ignore = lane_location_query_service_.FindLanePoseAtDistanceFrom({}, {}, {});
}
TEST_F(LaneLocationQueryServiceTest, GetLongitudinalLaneDistanceBetweenPositions)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), GetLongitudinalLaneDistanceBetweenPositions(_, _)) //
.Times(1)
.WillOnce(Return(std::optional<units::length::meter_t>{}));
std::ignore = lane_location_query_service_.GetLongitudinalLaneDistanceBetweenPositions({}, {});
}
TEST_F(LaneLocationQueryServiceTest, FindRelativeLanePoseAtDistanceFrom)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), FindRelativeLanePoseAtDistanceFrom(_, _, _, _)) //
.Times(1)
.WillOnce(Return(std::optional<mantle_api::Pose>{}));
std::ignore = lane_location_query_service_.FindRelativeLanePoseAtDistanceFrom({}, {}, {}, {});
}
TEST_F(LaneLocationQueryServiceTest, GetRelativeLaneId)
{
EXPECT_CALL(Const(mock_lane_location_query_service_), GetRelativeLaneId(_, _)) //
.Times(1)
.WillOnce(Return(std::optional<mantle_api::LaneId>{}));
std::ignore = lane_location_query_service_.GetRelativeLaneId({}, {});
}
} // namespace
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <gmock/gmock.h>
#include "MantleAPI/Map/i_lane_location_query_service.h"
namespace mantle_api
{
class MockLaneLocationQueryService final : public ILaneLocationQueryService
{
public:
MOCK_METHOD(Orientation3<units::angle::radian_t>, GetLaneOrientation, //
(const Vec3<units::length::meter_t>& position),
(const, override));
MOCK_METHOD(Vec3<units::length::meter_t>, GetUpwardsShiftedLanePosition, //
(const Vec3<units::length::meter_t>& position, double upwards_shift, bool allow_invalid_positions),
(const, override));
MOCK_METHOD(bool, IsPositionOnLane, (const Vec3<units::length::meter_t>& position), (const, override));
MOCK_METHOD(std::vector<UniqueId>, GetLaneIdsAtPosition, (const Vec3<units::length::meter_t>& position), (const, override));
MOCK_METHOD(std::optional<Pose>, FindLanePoseAtDistanceFrom, //
(const Pose& reference_pose_on_lane, units::length::meter_t distance, Direction direction),
(const, override));
MOCK_METHOD(std::optional<units::length::meter_t>, GetLongitudinalLaneDistanceBetweenPositions, //
(const mantle_api::Vec3<units::length::meter_t>& start_position, const mantle_api::Vec3<units::length::meter_t>& target_position),
(const, override));
MOCK_METHOD(std::optional<Pose>, FindRelativeLanePoseAtDistanceFrom, //
(const Pose& reference_pose_on_lane, int relative_target_lane, units::length::meter_t distance, units::length::meter_t lateral_offset),
(const, override));
MOCK_METHOD(std::optional<mantle_api::LaneId>, GetRelativeLaneId, //
(const mantle_api::Pose& reference_pose_on_lane, int relative_lane_target),
(const, override));
};
} // namespace mantle_api
################################################################################
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
#
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
################################################################################
add_executable(TrafficTest)
target_sources(TrafficTest PUBLIC entity_repository_test.cc entity_test.cc)
target_include_directories(TrafficTest PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/test>)
target_link_libraries(TrafficTest PUBLIC MantleAPI::MantleAPI GTest::gmock_main)
include(GoogleTest)
gtest_discover_tests(TrafficTest)
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "MantleAPI/Traffic/mock_entity_repository.h"
namespace
{
using testing::_;
using testing::An;
using testing::Const;
using testing::Return;
class EntityRepositoryTest : public testing::Test
{
protected:
mantle_api::MockEntityRepository mock_entity_repository_;
mantle_api::IEntityRepository& entity_repository_{mock_entity_repository_};
};
TEST_F(EntityRepositoryTest, DISABLED_CreateVehicle) // FIXME: Missing MockVehicle
{
// const auto mock_vehicle = mantle_api::MockVehicle{};
// DefaultValue<mantle_api::IVehicle&>::Set(mock_vehicle);
EXPECT_CALL(mock_entity_repository_, Create(_, An<const mantle_api::VehicleProperties&>())).Times(1);
entity_repository_.Create({}, mantle_api::VehicleProperties{});
}
} // namespace
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "MantleAPI/Traffic/mock_entity.h"
namespace
{
using testing::_;
using testing::Const;
using testing::Return;
class EntityTest : public testing::Test
{
protected:
mantle_api::MockEntity mock_entity_;
mantle_api::IEntity& entity_{mock_entity_};
};
TEST_F(EntityTest, SetPosition)
{
EXPECT_CALL(mock_entity_, SetPosition(_)).Times(1);
entity_.SetPosition({});
}
TEST_F(EntityTest, GetPosition)
{
EXPECT_CALL(Const(mock_entity_), GetPosition()) //
.Times(1)
.WillOnce(Return(mantle_api::Vec3<units::length::meter_t>{}));
std::ignore = entity_.GetPosition();
}
TEST_F(EntityTest, SetVelocity)
{
EXPECT_CALL(mock_entity_, SetVelocity(_)).Times(1);
entity_.SetVelocity({});
}
TEST_F(EntityTest, GetVelocity)
{
EXPECT_CALL(Const(mock_entity_), GetVelocity()) //
.Times(1)
.WillOnce(Return(mantle_api::Vec3<units::velocity::meters_per_second_t>{}));
std::ignore = entity_.GetVelocity();
}
TEST_F(EntityTest, SetAcceleration)
{
EXPECT_CALL(mock_entity_, SetAcceleration(_)).Times(1);
entity_.SetAcceleration({});
}
TEST_F(EntityTest, GetAcceleration)
{
EXPECT_CALL(Const(mock_entity_), GetAcceleration()) //
.Times(1)
.WillOnce(Return(mantle_api::Vec3<units::acceleration::meters_per_second_squared_t>{}));
std::ignore = entity_.GetAcceleration();
}
TEST_F(EntityTest, SetOrientation)
{
EXPECT_CALL(mock_entity_, SetOrientation(_)).Times(1);
entity_.SetOrientation({});
}
TEST_F(EntityTest, GetOrientation)
{
EXPECT_CALL(Const(mock_entity_), GetOrientation()) //
.Times(1)
.WillOnce(Return(mantle_api::Orientation3<units::angle::radian_t>{}));
std::ignore = entity_.GetOrientation();
}
TEST_F(EntityTest, SetOrientationRate)
{
EXPECT_CALL(mock_entity_, SetOrientationRate(_)).Times(1);
entity_.SetOrientationRate({});
}
TEST_F(EntityTest, GetOrientationRate)
{
EXPECT_CALL(Const(mock_entity_), GetOrientationRate()) //
.Times(1)
.WillOnce(Return(mantle_api::Orientation3<units::angular_velocity::radians_per_second_t>{}));
std::ignore = entity_.GetOrientationRate();
}
TEST_F(EntityTest, SetOrientationAcceleration)
{
EXPECT_CALL(mock_entity_, SetOrientationAcceleration(_)).Times(1);
entity_.SetOrientationAcceleration({});
}
TEST_F(EntityTest, GetOrientationAcceleration)
{
EXPECT_CALL(Const(mock_entity_), GetOrientationAcceleration()) //
.Times(1)
.WillOnce(Return(mantle_api::Orientation3<units::angular_acceleration::radians_per_second_squared_t>{}));
std::ignore = entity_.GetOrientationAcceleration();
}
TEST_F(EntityTest, SetProperties)
{
EXPECT_CALL(mock_entity_, SetProperties(_)).Times(1);
entity_.SetProperties({});
}
TEST_F(EntityTest, GetProperties)
{
EXPECT_CALL(Const(mock_entity_), GetProperties()) //
.Times(1)
.WillOnce(Return(nullptr));
std::ignore = entity_.GetProperties();
}
TEST_F(EntityTest, SetAssignedLaneIds)
{
EXPECT_CALL(mock_entity_, SetAssignedLaneIds(_)).Times(1);
entity_.SetAssignedLaneIds({});
}
TEST_F(EntityTest, GetAssignedLaneIds)
{
EXPECT_CALL(Const(mock_entity_), GetAssignedLaneIds()) //
.Times(1)
.WillOnce(Return(std::vector<std::uint64_t>{}));
std::ignore = entity_.GetAssignedLaneIds();
}
TEST_F(EntityTest, SetVisibility)
{
EXPECT_CALL(mock_entity_, SetVisibility(_)).Times(1);
entity_.SetVisibility({});
}
TEST_F(EntityTest, GetVisibility)
{
EXPECT_CALL(Const(mock_entity_), GetVisibility()).Times(1) //
.WillOnce(Return(mantle_api::EntityVisibilityConfig{}));
std::ignore = entity_.GetVisibility();
}
} // namespace
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <gmock/gmock.h>
#include "MantleAPI/Common/mock_identifiable.h"
#include "MantleAPI/Traffic/i_entity.h"
namespace mantle_api
{
class MockEntity final : public IEntity
{
public:
// IIdentifiable
MOCK_METHOD(UniqueId, GetUniqueId, (), (const, override));
MOCK_METHOD(void, SetName, (const std::string& name), (override));
MOCK_METHOD(const std::string&, GetName, (), (const, override));
// IEntity
MOCK_METHOD(void, SetPosition, (const Vec3<units::length::meter_t>& inert_pos), (override));
MOCK_METHOD(Vec3<units::length::meter_t>, GetPosition, (), (const, override));
MOCK_METHOD(void, SetVelocity, (const Vec3<units::velocity::meters_per_second_t>& velocity), (override));
MOCK_METHOD(Vec3<units::velocity::meters_per_second_t>, GetVelocity, (), (const, override));
MOCK_METHOD(void, SetAcceleration, (const Vec3<units::acceleration::meters_per_second_squared_t>& acceleration), (override));
MOCK_METHOD(Vec3<units::acceleration::meters_per_second_squared_t>, GetAcceleration, (), (const, override));
MOCK_METHOD(void, SetOrientation, (const Orientation3<units::angle::radian_t>& orientation), (override));
MOCK_METHOD(Orientation3<units::angle::radian_t>, GetOrientation, (), (const, override));
MOCK_METHOD(void, SetOrientationRate, (const Orientation3<units::angular_velocity::radians_per_second_t>& orientation_rate), (override));
MOCK_METHOD(Orientation3<units::angular_velocity::radians_per_second_t>, GetOrientationRate, (), (const, override));
MOCK_METHOD(void, SetOrientationAcceleration, (const Orientation3<units::angular_acceleration::radians_per_second_squared_t>& orientation_acceleration), (override));
MOCK_METHOD(Orientation3<units::angular_acceleration::radians_per_second_squared_t>, GetOrientationAcceleration, (), (const, override));
MOCK_METHOD(void, SetProperties, (std::unique_ptr<mantle_api::EntityProperties> properties), (override));
MOCK_METHOD(EntityProperties*, GetProperties, (), (const, override));
MOCK_METHOD(void, SetAssignedLaneIds, (const std::vector<std::uint64_t>& assigned_lane_ids), (override));
MOCK_METHOD(std::vector<std::uint64_t>, GetAssignedLaneIds, (), (const, override));
MOCK_METHOD(void, SetVisibility, (const EntityVisibilityConfig& visibility), (override));
MOCK_METHOD(EntityVisibilityConfig, GetVisibility, (), (const, override));
};
} // namespace mantle_api
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <gmock/gmock.h>
#include "MantleAPI/Traffic/i_entity_repository.h"
namespace mantle_api
{
class MockEntityRepository : public IEntityRepository
{
public:
MOCK_METHOD(IVehicle&, Create, (const std::string& name, const VehicleProperties& properties), (override));
MOCK_METHOD(IVehicle&, Create, (UniqueId id, const std::string& name, const VehicleProperties& properties), (override));
MOCK_METHOD(IPedestrian&, Create, (const std::string& name, const PedestrianProperties& properties), (override));
MOCK_METHOD(IPedestrian&, Create, (UniqueId id, const std::string& name, const PedestrianProperties& properties), (override));
MOCK_METHOD(IStaticObject&, Create, (const std::string& name, const mantle_api::StaticObjectProperties& properties), (override));
MOCK_METHOD(IStaticObject&, Create, (UniqueId id, const std::string& name, const StaticObjectProperties& properties), (override));
MOCK_METHOD(IVehicle&, GetHost, (), (override));
MOCK_METHOD(std::optional<std::reference_wrapper<IEntity>>, Get, (const std::string& name), (override));
MOCK_METHOD(std::optional<std::reference_wrapper<const IEntity>>, Get, (const std::string& name), (const, override));
MOCK_METHOD(std::optional<std::reference_wrapper<IEntity>>, Get, (UniqueId id), (override));
MOCK_METHOD(std::optional<std::reference_wrapper<const IEntity>>, Get, (UniqueId id), (const, override));
MOCK_METHOD(bool, Contains, (UniqueId id), (const, override));
MOCK_METHOD(void, Delete, (const std::string& name), (override));
MOCK_METHOD(void, Delete, (UniqueId id), (override));
MOCK_METHOD(const std::vector<std::unique_ptr<mantle_api::IEntity>>&, GetEntities, (), (const, override));
MOCK_METHOD(void, RegisterEntityCreatedCallback, (const std::function<void(IEntity&)>& callback), (override));
MOCK_METHOD(void, RegisterEntityDeletedCallback, (const std::function<void(const std::string&)>& callback), (override));
MOCK_METHOD(void, RegisterEntityDeletedCallback, (const std::function<void(UniqueId)>& callback), (override));
};
} // namespace mantle_api