get_landmark_poses_handler_test.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include "cartographer/cloud/internal/handlers/get_landmark_poses_handler.h"
00018 
00019 #include "cartographer/cloud/internal/testing/handler_test.h"
00020 #include "cartographer/cloud/internal/testing/test_helpers.h"
00021 #include "google/protobuf/text_format.h"
00022 #include "gtest/gtest.h"
00023 
00024 namespace cartographer {
00025 namespace cloud {
00026 namespace handlers {
00027 namespace {
00028 
00029 using ::cartographer::transform::Rigid3d;
00030 using ::testing::_;
00031 using ::testing::Eq;
00032 using ::testing::Pointee;
00033 using ::testing::Truly;
00034 
00035 const std::string kMessage = R"(
00036   landmark_poses {
00037     landmark_id: "landmark_1"
00038     global_pose {
00039       translation {
00040         x: 1 y: 2 z: 3
00041       }
00042       rotation {
00043         w: 1 x: 0 y: 0 z: 0
00044       }
00045     }
00046   }
00047   landmark_poses {
00048     landmark_id: "landmark_2"
00049     global_pose {
00050       translation {
00051         x: 3 y: 2 z: 1
00052       }
00053       rotation {
00054         w: 0 x: 1 y: 0 z: 0
00055       }
00056     }
00057   }
00058 )";
00059 
00060 using GetLandmarkPosesHandlerTest =
00061     testing::HandlerTest<GetLandmarkPosesSignature, GetLandmarkPosesHandler>;
00062 
00063 TEST_F(GetLandmarkPosesHandlerTest, NoLocalSlamUploader) {
00064   std::map<std::string, Rigid3d> landmark_poses{
00065       {"landmark_1", Rigid3d(Eigen::Vector3d(1., 2., 3.),
00066                              Eigen::Quaterniond(1., 0., 0., 0.))},
00067       {"landmark_2", Rigid3d(Eigen::Vector3d(3., 2., 1.),
00068                              Eigen::Quaterniond(0., 1., 0., 0.))}};
00069   EXPECT_CALL(*mock_pose_graph_, GetLandmarkPoses())
00070       .WillOnce(::testing::Return(landmark_poses));
00071   test_server_->SendWrite(google::protobuf::Empty());
00072 
00073   proto::GetLandmarkPosesResponse expected_response;
00074   EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(
00075       kMessage, &expected_response));
00076   EXPECT_THAT(
00077       test_server_->response(),
00078       ::testing::Truly(testing::BuildProtoPredicateEquals(&expected_response)));
00079 }
00080 
00081 }  // namespace
00082 }  // namespace handlers
00083 }  // namespace cloud
00084 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35