handler_test.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The Cartographer Authors
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 #ifndef CARTOGRAPHER_CLOUD_INTERNAL_TESTING_HANDLER_TEST_H
18 #define CARTOGRAPHER_CLOUD_INTERNAL_TESTING_HANDLER_TEST_H
19 
20 #include "async_grpc/testing/rpc_handler_test_server.h"
24 #include "gtest/gtest.h"
27 
28 namespace cartographer {
29 namespace cloud {
30 namespace testing {
31 
32 using ::testing::Return;
33 using ::testing::Test;
34 
35 template <typename HandlerConcept, typename HandlerType>
36 class HandlerTest : public Test {
37  public:
38  void SetUp() override {
40  async_grpc::testing::RpcHandlerTestServer<HandlerConcept, HandlerType>>(
41  common::make_unique<MockMapBuilderContext>());
44  ->template GetUnsynchronizedContext<MockMapBuilderContext>();
46  common::make_unique<MockLocalTrajectoryUploader>();
47  mock_map_builder_ = common::make_unique<mapping::testing::MockMapBuilder>();
48  mock_pose_graph_ = common::make_unique<mapping::testing::MockPoseGraph>();
49 
50  EXPECT_CALL(*mock_map_builder_context_, map_builder())
51  .Times(::testing::AnyNumber())
52  .WillRepeatedly(::testing::ReturnPointee(mock_map_builder_.get()));
53  EXPECT_CALL(*mock_map_builder_, pose_graph())
54  .Times(::testing::AnyNumber())
55  .WillRepeatedly(Return(mock_pose_graph_.get()));
56  }
57 
59  EXPECT_CALL(*mock_map_builder_context_, local_trajectory_uploader())
60  .WillOnce(Return(nullptr));
61  }
62 
64  EXPECT_CALL(*mock_map_builder_context_, local_trajectory_uploader())
65  .WillRepeatedly(Return(mock_local_trajectory_uploader_.get()));
66  }
67 
68  protected:
69  std::unique_ptr<
70  async_grpc::testing::RpcHandlerTestServer<HandlerConcept, HandlerType>>
73  std::unique_ptr<MockLocalTrajectoryUploader> mock_local_trajectory_uploader_;
74  std::unique_ptr<mapping::testing::MockMapBuilder> mock_map_builder_;
75  std::unique_ptr<mapping::testing::MockPoseGraph> mock_pose_graph_;
76 };
77 
78 } // namespace testing
79 } // namespace cloud
80 } // namespace cartographer
81 
82 #endif // CARTOGRAPHER_CLOUD_INTERNAL_TESTING_HANDLER_TEST_H
MockMapBuilderContext * mock_map_builder_context_
Definition: handler_test.h:72
_Unique_if< T >::_Single_object make_unique(Args &&... args)
Definition: make_unique.h:46
std::unique_ptr< async_grpc::testing::RpcHandlerTestServer< HandlerConcept, HandlerType > > test_server_
Definition: handler_test.h:71
std::unique_ptr< mapping::testing::MockMapBuilder > mock_map_builder_
Definition: handler_test.h:74
std::unique_ptr< MockLocalTrajectoryUploader > mock_local_trajectory_uploader_
Definition: handler_test.h:73
std::unique_ptr< mapping::testing::MockPoseGraph > mock_pose_graph_
Definition: handler_test.h:75


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58