Skip to content
Snippets Groups Projects
Commit eacf33e2 authored by Matthias Greuter's avatar Matthias Greuter
Browse files

Make build and run the tests work

parent 7442fe1b
No related branches found
No related tags found
2 merge requests!17Draft: Implemented VisibilityAction,!9Bazel: Mantle api dependency as local repo
......@@ -86,9 +86,9 @@ cc_test(
data = [":open_scenario_engine_test_data"],
tags = ["test"],
deps = [
":open_scenario_engine",
":open_scenario_engine_test_utils",
"@googletest//:gtest_main",
"@open_scenario_engine",
],
)
......
/*******************************************************************************
* Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* 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 "ControllerCreator.h"
#include <MantleAPI/Test/test_utils.h>
#include <gtest/gtest.h>
#include <openScenarioLib/src/common/SimpleMessageLogger.h>
#include <openScenarioLib/src/loader/FileResourceLocator.h>
#include <openScenarioLib/src/v1_1/loader/XmlScenarioImportLoaderFactoryV1_1.h>
#include <string>
namespace OPENSCENARIO
{
using namespace units::literals;
class OpenScenarioEngineLibraryTestBase : public ::testing::Test
{
protected:
void SetUp() override { env_ = std::make_shared<mantle_api::MockEnvironment>(); }
std::shared_ptr<mantle_api::MockEnvironment> env_;
/// Once this is moved to a dedicated repository, this path will need to change to reflect that new structure.
const std::string relative_data_path{"./ThirdParty/OpenScenarioEngine/"};
const std::string xosc_path{relative_data_path + "test/data/Scenarios/"};
std::string xosc_file_path_with_odr_map_{
xosc_path + "AutomatedLaneKeepingSystemScenarios/ALKS_Scenario_4.1_1_FreeDriving_TEMPLATE.xosc"};
std::string xosc_file_path_with_nds_map_{
xosc_path + "AutomatedLaneKeepingSystemScenarios/ALKS_Scenario_4.1_1_FreeDriving_NDS_TEMPLATE.xosc"};
};
class EngineSubModuleTestBase : public OpenScenarioEngineLibraryTestBase
{
protected:
void SetUp() override
{
OpenScenarioEngineLibraryTestBase::SetUp();
auto message_logger =
std::make_shared<NET_ASAM_OPENSCENARIO::SimpleMessageLogger>(NET_ASAM_OPENSCENARIO::ErrorLevel::INFO);
auto catalog_message_logger =
std::make_shared<NET_ASAM_OPENSCENARIO::SimpleMessageLogger>(NET_ASAM_OPENSCENARIO::ErrorLevel::INFO);
auto loader_factory = NET_ASAM_OPENSCENARIO::v1_1::XmlScenarioImportLoaderFactory(catalog_message_logger,
xosc_file_path_with_odr_map_);
auto loader = loader_factory.CreateLoader(std::make_shared<NET_ASAM_OPENSCENARIO::FileResourceLocator>());
scenario_ptr_ = std::static_pointer_cast<NET_ASAM_OPENSCENARIO::v1_1::IOpenScenario>(
loader->Load(message_logger)->GetAdapter(typeid(NET_ASAM_OPENSCENARIO::v1_1::IOpenScenario).name()));
}
std::shared_ptr<NET_ASAM_OPENSCENARIO::v1_1::IOpenScenario> scenario_ptr_;
};
class OpenScenarioEngineTestBase : public OpenScenarioEngineLibraryTestBase
{
protected:
void SetUp() override
{
OpenScenarioEngineLibraryTestBase::SetUp();
mantle_api::VehicleProperties ego_properties{};
ego_properties.type = mantle_api::EntityType::kVehicle;
ego_properties.classification = mantle_api::VehicleClass::kMedium_car;
ego_properties.bounding_box.dimension.length = 5.0_m;
ego_properties.bounding_box.dimension.width = 2.0_m;
ego_properties.bounding_box.dimension.height = 1.8_m;
ego_properties.bounding_box.geometric_center.x = 1.4_m;
ego_properties.bounding_box.geometric_center.y = 0.0_m;
ego_properties.bounding_box.geometric_center.z = 0.9_m;
ego_properties.performance.max_acceleration = 10_mps_sq;
ego_properties.performance.max_deceleration = 10_mps_sq;
ego_properties.performance.max_speed = 70_mps;
ego_properties.front_axle.bb_center_to_axle_center = {2.98_m, 0.0_m, 0.4_m};
ego_properties.front_axle.max_steering = 0.5_rad;
ego_properties.front_axle.track_width = 1.68_m;
ego_properties.front_axle.wheel_diameter = 0.8_m;
ego_properties.rear_axle.bb_center_to_axle_center = {0.0_m, 0.0_m, 0.4_m};
ego_properties.rear_axle.max_steering = 0_rad;
ego_properties.rear_axle.track_width = 1.68_m;
ego_properties.rear_axle.wheel_diameter = 0.8_m;
ego_properties.is_host = true;
// Necessary because Create() is always called in engine init and will otherwise not return a MockVehicle ref
// which results in an exception
ON_CALL(dynamic_cast<mantle_api::MockEntityRepository&>(env_->GetEntityRepository()),
Create(testing::_, ego_properties))
.WillByDefault(testing::ReturnRef(mock_vehicle_));
}
mantle_api::MockVehicle mock_vehicle_{};
};
} // namespace OPENSCENARIO
......@@ -31,7 +31,7 @@ class OpenScenarioEngineLibraryTestBase : public ::testing::Test
std::shared_ptr<mantle_api::MockEnvironment> env_;
/// Once this is moved to a dedicated repository, this path will need to change to reflect that new structure.
const std::string relative_data_path{"./ThirdParty/OpenScenarioEngine/"};
const std::string relative_data_path{"./external/open_scenario_engine/"};
const std::string xosc_path{relative_data_path + "test/data/Scenarios/"};
std::string xosc_file_path_with_odr_map_{
xosc_path + "AutomatedLaneKeepingSystemScenarios/ALKS_Scenario_4.1_1_FreeDriving_TEMPLATE.xosc"};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment