From cf180a0b195237b20adf3f477569cd178e2bb85f Mon Sep 17 00:00:00 2001 From: Alexander Belyaev <32522095+pifon2a@users.noreply.github.com> Date: Mon, 5 Mar 2018 14:09:04 +0100 Subject: [PATCH] Move mapping:: related mocks to cartographer/internal/testing. (#960) --- cartographer/cloud/internal/client_server_test.cc | 15 ++++++++------- .../handlers/add_trajectory_handler_test.cc | 6 +++--- .../cloud/internal/testing/handler_test.h | 12 ++++++------ .../internal/testing/mock_map_builder.h | 4 ++-- .../internal/testing/mock_pose_graph.h | 4 ++-- .../internal/testing/mock_trajectory_builder.h | 4 ++-- 6 files changed, 23 insertions(+), 22 deletions(-) rename cartographer/{cloud => mapping}/internal/testing/mock_map_builder.h (98%) rename cartographer/{cloud => mapping}/internal/testing/mock_pose_graph.h (97%) rename cartographer/{cloud => mapping}/internal/testing/mock_trajectory_builder.h (98%) diff --git a/cartographer/cloud/internal/client_server_test.cc b/cartographer/cloud/internal/client_server_test.cc index 799e577..38deb23 100644 --- a/cartographer/cloud/internal/client_server_test.cc +++ b/cartographer/cloud/internal/client_server_test.cc @@ -19,10 +19,10 @@ #include "cartographer/cloud/client/map_builder_stub.h" #include "cartographer/cloud/internal/map_builder_server.h" -#include "cartographer/cloud/internal/testing/mock_map_builder.h" -#include "cartographer/cloud/internal/testing/mock_trajectory_builder.h" #include "cartographer/cloud/map_builder_server_options.h" #include "cartographer/mapping/internal/test_helpers.h" +#include "cartographer/mapping/internal/testing/mock_map_builder.h" +#include "cartographer/mapping/internal/testing/mock_trajectory_builder.h" #include "cartographer/mapping/local_slam_result_data.h" #include "glog/logging.h" #include "gmock/gmock.h" @@ -32,6 +32,8 @@ using ::cartographer::mapping::MapBuilder; using ::cartographer::mapping::MapBuilderInterface; using ::cartographer::mapping::PoseGraphInterface; using ::cartographer::mapping::TrajectoryBuilderInterface; +using ::cartographer::mapping::testing::MockMapBuilder; +using ::cartographer::mapping::testing::MockTrajectoryBuilder; using ::testing::_; using SensorId = ::cartographer::mapping::TrajectoryBuilderInterface::SensorId; @@ -92,13 +94,12 @@ class ClientServerTest : public ::testing::Test { } void InitializeServerWithMockMapBuilder() { - auto mock_map_builder = common::make_unique(); + auto mock_map_builder = common::make_unique(); mock_map_builder_ = mock_map_builder.get(); server_ = common::make_unique( map_builder_server_options_, std::move(mock_map_builder)); EXPECT_TRUE(server_ != nullptr); - mock_trajectory_builder_ = - common::make_unique(); + mock_trajectory_builder_ = common::make_unique(); } void InitializeStub() { @@ -114,8 +115,8 @@ class ClientServerTest : public ::testing::Test { } proto::MapBuilderServerOptions map_builder_server_options_; - testing::MockMapBuilder* mock_map_builder_; - std::unique_ptr mock_trajectory_builder_; + MockMapBuilder* mock_map_builder_; + std::unique_ptr mock_trajectory_builder_; ::cartographer::mapping::proto::TrajectoryBuilderOptions trajectory_builder_options_; std::unique_ptr server_; diff --git a/cartographer/cloud/internal/handlers/add_trajectory_handler_test.cc b/cartographer/cloud/internal/handlers/add_trajectory_handler_test.cc index a02c9ef..b873d8e 100644 --- a/cartographer/cloud/internal/handlers/add_trajectory_handler_test.cc +++ b/cartographer/cloud/internal/handlers/add_trajectory_handler_test.cc @@ -17,8 +17,8 @@ #include "cartographer/cloud/internal/handlers/add_trajectory_handler.h" #include "cartographer/cloud/internal/sensor/serialization.h" #include "cartographer/cloud/internal/testing/handler_test.h" -#include "cartographer/cloud/internal/testing/mock_map_builder.h" #include "cartographer/cloud/internal/testing/test_helpers.h" +#include "cartographer/mapping/internal/testing/mock_map_builder.h" #include "google/protobuf/text_format.h" #include "gtest/gtest.h" @@ -70,7 +70,7 @@ class AddTrajectoryHandlerTest public: void SetUp() override { testing::HandlerTest::SetUp(); - mock_map_builder_ = common::make_unique(); + mock_map_builder_ = common::make_unique(); EXPECT_CALL(*mock_map_builder_context_, GetLocalSlamResultCallbackForSubscriptions()) .WillOnce(Return(nullptr)); @@ -88,7 +88,7 @@ class AddTrajectoryHandlerTest return expected_sensor_ids; } - std::unique_ptr mock_map_builder_; + std::unique_ptr mock_map_builder_; }; TEST_F(AddTrajectoryHandlerTest, NoLocalSlamUploader) { diff --git a/cartographer/cloud/internal/testing/handler_test.h b/cartographer/cloud/internal/testing/handler_test.h index 5d3441a..6da1c91 100644 --- a/cartographer/cloud/internal/testing/handler_test.h +++ b/cartographer/cloud/internal/testing/handler_test.h @@ -19,11 +19,11 @@ #include "cartographer/cloud/internal/framework/testing/rpc_handler_test_server.h" #include "cartographer/common/make_unique.h" +#include "cartographer/mapping/internal/testing/mock_map_builder.h" +#include "cartographer/mapping/internal/testing/mock_pose_graph.h" #include "gtest/gtest.h" #include "mock_local_trajectory_uploader.h" -#include "mock_map_builder.h" #include "mock_map_builder_context.h" -#include "mock_pose_graph.h" namespace cartographer { namespace cloud { @@ -44,8 +44,8 @@ class HandlerTest : public Test { ->template GetUnsynchronizedContext(); mock_local_trajectory_uploader_ = common::make_unique(); - mock_map_builder_ = common::make_unique(); - mock_pose_graph_ = common::make_unique(); + mock_map_builder_ = common::make_unique(); + mock_pose_graph_ = common::make_unique(); EXPECT_CALL(*mock_map_builder_context_, map_builder()) .Times(::testing::AnyNumber()) @@ -70,8 +70,8 @@ class HandlerTest : public Test { test_server_; MockMapBuilderContext* mock_map_builder_context_; std::unique_ptr mock_local_trajectory_uploader_; - std::unique_ptr mock_map_builder_; - std::unique_ptr mock_pose_graph_; + std::unique_ptr mock_map_builder_; + std::unique_ptr mock_pose_graph_; }; } // namespace testing diff --git a/cartographer/cloud/internal/testing/mock_map_builder.h b/cartographer/mapping/internal/testing/mock_map_builder.h similarity index 98% rename from cartographer/cloud/internal/testing/mock_map_builder.h rename to cartographer/mapping/internal/testing/mock_map_builder.h index e2cdb3c..cb492ec 100644 --- a/cartographer/cloud/internal/testing/mock_map_builder.h +++ b/cartographer/mapping/internal/testing/mock_map_builder.h @@ -26,7 +26,7 @@ using testing::_; namespace cartographer { -namespace cloud { +namespace mapping { namespace testing { class MockMapBuilder : public mapping::MapBuilderInterface { @@ -57,7 +57,7 @@ class MockMapBuilder : public mapping::MapBuilderInterface { }; } // namespace testing -} // namespace cloud +} // namespace mapping } // namespace cartographer #endif // CARTOGRAPHER_GRPC_INTERNAL_TESTING_MOCK_MAP_BUILDER_H diff --git a/cartographer/cloud/internal/testing/mock_pose_graph.h b/cartographer/mapping/internal/testing/mock_pose_graph.h similarity index 97% rename from cartographer/cloud/internal/testing/mock_pose_graph.h rename to cartographer/mapping/internal/testing/mock_pose_graph.h index d27cfcb..4ba520d 100644 --- a/cartographer/cloud/internal/testing/mock_pose_graph.h +++ b/cartographer/mapping/internal/testing/mock_pose_graph.h @@ -23,7 +23,7 @@ #include "gtest/gtest.h" namespace cartographer { -namespace cloud { +namespace mapping { namespace testing { class MockPoseGraph : public mapping::PoseGraphInterface { @@ -51,7 +51,7 @@ class MockPoseGraph : public mapping::PoseGraphInterface { }; } // namespace testing -} // namespace cloud +} // namespace mapping } // namespace cartographer #endif // CARTOGRAPHER_GRPC_INTERNAL_TESTING_MOCK_POSE_GRAPH_H diff --git a/cartographer/cloud/internal/testing/mock_trajectory_builder.h b/cartographer/mapping/internal/testing/mock_trajectory_builder.h similarity index 98% rename from cartographer/cloud/internal/testing/mock_trajectory_builder.h rename to cartographer/mapping/internal/testing/mock_trajectory_builder.h index b2ef52b..6e07224 100644 --- a/cartographer/cloud/internal/testing/mock_trajectory_builder.h +++ b/cartographer/mapping/internal/testing/mock_trajectory_builder.h @@ -23,7 +23,7 @@ #include "gtest/gtest.h" namespace cartographer { -namespace cloud { +namespace mapping { namespace testing { class MockTrajectoryBuilder : public mapping::TrajectoryBuilderInterface { @@ -52,7 +52,7 @@ class MockTrajectoryBuilder : public mapping::TrajectoryBuilderInterface { }; } // namespace testing -} // namespace cloud +} // namespace mapping } // namespace cartographer #endif // CARTOGRAPHER_GRPC_INTERNAL_TESTING_MOCK_TRAJECTORY_BUILDER_CONTEXT_H