get_landmark_poses_handler_test.cc
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 
20 #include "google/protobuf/text_format.h"
21 #include "gtest/gtest.h"
22 
23 namespace cartographer {
24 namespace cloud {
25 namespace handlers {
26 namespace {
27 
29 using ::testing::_;
30 using ::testing::Eq;
31 using ::testing::Pointee;
32 using ::testing::Truly;
33 
34 const std::string kMessage = R"(
35  landmark_poses {
36  landmark_id: "landmark_1"
37  global_pose {
38  translation {
39  x: 1 y: 2 z: 3
40  }
41  rotation {
42  w: 1 x: 0 y: 0 z: 0
43  }
44  }
45  }
46  landmark_poses {
47  landmark_id: "landmark_2"
48  global_pose {
49  translation {
50  x: 3 y: 2 z: 1
51  }
52  rotation {
53  w: 0 x: 1 y: 0 z: 0
54  }
55  }
56  }
57 )";
58 
59 using GetLandmarkPosesHandlerTest =
60  testing::HandlerTest<GetLandmarkPosesSignature, GetLandmarkPosesHandler>;
61 
62 TEST_F(GetLandmarkPosesHandlerTest, NoLocalSlamUploader) {
63  std::map<std::string, Rigid3d> landmark_poses{
64  {"landmark_1", Rigid3d(Eigen::Vector3d(1., 2., 3.),
65  Eigen::Quaterniond(1., 0., 0., 0.))},
66  {"landmark_2", Rigid3d(Eigen::Vector3d(3., 2., 1.),
67  Eigen::Quaterniond(0., 1., 0., 0.))}};
68  EXPECT_CALL(*mock_pose_graph_, GetLandmarkPoses())
69  .WillOnce(::testing::Return(landmark_poses));
70  test_server_->SendWrite(google::protobuf::Empty());
71 
72  proto::GetLandmarkPosesResponse expected_response;
73  EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(
74  kMessage, &expected_response));
75  EXPECT_THAT(
76  test_server_->response(),
77  ::testing::Truly(testing::BuildProtoPredicateEquals(&expected_response)));
78 }
79 
80 } // namespace
81 } // namespace handlers
82 } // namespace cloud
83 } // namespace cartographer
Rigid3< double > Rigid3d
std::unique_ptr< MockPoseGraph > mock_pose_graph_
ProtoPredicateType BuildProtoPredicateEquals(const google::protobuf::Message *proto)


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