Apollo 11.0
自动驾驶开放平台
planning_test_base.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#include <memory>
18#include <set>
19#include <string>
20
21#include "gtest/gtest.h"
22
23// TODO(all) #include "modules/planning/planning_component/navi_planning.h"
26
27namespace apollo {
28namespace planning {
29
30#define RUN_GOLDEN_TEST(sub_case_num) \
31 { \
32 const ::testing::TestInfo* const test_info = \
33 ::testing::UnitTest::GetInstance()->current_test_info(); \
34 bool no_trajectory_point = false; \
35 bool run_planning_success = \
36 RunPlanning(test_info->name(), sub_case_num, no_trajectory_point); \
37 EXPECT_TRUE(run_planning_success); \
38 }
39
40#define RUN_GOLDEN_TEST_DECISION(sub_case_num) \
41 { \
42 const ::testing::TestInfo* const test_info = \
43 ::testing::UnitTest::GetInstance()->current_test_info(); \
44 bool no_trajectory_point = true; \
45 bool run_planning_success = \
46 RunPlanning(test_info->name(), sub_case_num, no_trajectory_point); \
47 EXPECT_TRUE(run_planning_success); \
48 }
49
50#define TMAIN \
51 int main(int argc, char** argv) { \
52 ::apollo::cyber::Init("planning_test"); \
53 ::testing::InitGoogleTest(&argc, argv); \
54 ::google::ParseCommandLineFlags(&argc, &argv, true); \
55 return RUN_ALL_TESTS(); \
56 }
57
58#define ENABLE_RULE(RULE_ID) this->rule_enabled_.emplace(RULE_ID)
59
60DECLARE_string(test_routing_response_file);
61DECLARE_string(test_localization_file);
62DECLARE_string(test_chassis_file);
63DECLARE_string(test_data_dir);
64DECLARE_string(test_prediction_file);
65DECLARE_string(test_traffic_light_file);
66DECLARE_string(test_relative_map_file);
67DECLARE_string(test_previous_planning_file);
68
69class PlanningTestBase : public ::testing::Test {
70 public:
71 virtual ~PlanningTestBase() = default;
72
73 static void SetUpTestCase();
74 virtual void SetUp();
75 void UpdateData();
76
82 bool RunPlanning(const std::string& test_case_name, int case_num,
83 bool no_trajectory_point);
84
85 std::shared_ptr<TrafficRule> GetTrafficRuleConfig(const std::string& rule_id);
86
87 protected:
88 void TrimPlanning(ADCTrajectory* origin, bool no_trajectory_point);
89 bool FeedTestData();
90 bool IsValidTrajectory(const ADCTrajectory& trajectory);
91
92 protected:
93 std::unique_ptr<PlanningBase> planning_ = nullptr;
94 std::set<std::string> rule_enabled_;
98 std::shared_ptr<DependencyInjector> injector_;
99};
100
101} // namespace planning
102} // namespace apollo
void TrimPlanning(ADCTrajectory *origin, bool no_trajectory_point)
std::set< std::string > rule_enabled_
std::shared_ptr< TrafficRule > GetTrafficRuleConfig(const std::string &rule_id)
bool RunPlanning(const std::string &test_case_name, int case_num, bool no_trajectory_point)
Execute the planning code.
bool IsValidTrajectory(const ADCTrajectory &trajectory)
std::shared_ptr< DependencyInjector > injector_
std::unique_ptr< PlanningBase > planning_
Planning module main class.
DECLARE_string(test_routing_response_file)
class register implement
Definition arena_queue.h:37