Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer/cloud/internal/handlers/add_odometry_data_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 ::testing::_;
00030 using ::testing::Eq;
00031 using ::testing::Pointee;
00032 using ::testing::Truly;
00033
00034 const std::string kMessage = R"(
00035 sensor_metadata {
00036 trajectory_id: 1
00037 sensor_id: "sensor_id"
00038 }
00039 odometry_data {
00040 timestamp: 2
00041 pose {
00042 translation {
00043 x: 3 y: 4 z: 5
00044 }
00045 rotation {
00046 w: 6 x: 7 y: 8 z: 9
00047 }
00048 }
00049 })";
00050
00051 using AddOdometryDataHandlerTest =
00052 testing::HandlerTest<AddOdometryDataSignature, AddOdometryDataHandler>;
00053
00054 TEST_F(AddOdometryDataHandlerTest, NoLocalSlamUploader) {
00055 proto::AddOdometryDataRequest request;
00056 EXPECT_TRUE(
00057 google::protobuf::TextFormat::ParseFromString(kMessage, &request));
00058 SetNoLocalTrajectoryUploader();
00059 EXPECT_CALL(
00060 *mock_map_builder_context_,
00061 CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
00062 Eq(request.sensor_metadata().trajectory_id())))
00063 .WillOnce(::testing::Return(true));
00064 EXPECT_CALL(*mock_map_builder_context_,
00065 DoEnqueueSensorData(
00066 Eq(request.sensor_metadata().trajectory_id()),
00067 Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
00068 test_server_->SendWrite(request);
00069 test_server_->SendWritesDone();
00070 test_server_->SendFinish();
00071 }
00072
00073 TEST_F(AddOdometryDataHandlerTest, WithMockLocalSlamUploader) {
00074 proto::AddOdometryDataRequest request;
00075 EXPECT_TRUE(
00076 google::protobuf::TextFormat::ParseFromString(kMessage, &request));
00077 SetMockLocalTrajectoryUploader();
00078 EXPECT_CALL(
00079 *mock_map_builder_context_,
00080 CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
00081 Eq(request.sensor_metadata().trajectory_id())))
00082 .WillOnce(::testing::Return(true));
00083 EXPECT_CALL(*mock_map_builder_context_,
00084 DoEnqueueSensorData(
00085 Eq(request.sensor_metadata().trajectory_id()),
00086 Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
00087 proto::SensorData sensor_data;
00088 *sensor_data.mutable_sensor_metadata() = request.sensor_metadata();
00089 *sensor_data.mutable_odometry_data() = request.odometry_data();
00090 EXPECT_CALL(*mock_local_trajectory_uploader_,
00091 DoEnqueueSensorData(Pointee(
00092 Truly(testing::BuildProtoPredicateEquals(&sensor_data)))));
00093 test_server_->SendWrite(request);
00094 test_server_->SendWritesDone();
00095 test_server_->SendFinish();
00096 }
00097
00098 }
00099 }
00100 }
00101 }