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_imu_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 imu_data {
00040 timestamp: 2
00041 linear_acceleration {
00042 x: 3 y: 4 z: 5
00043 }
00044 angular_velocity {
00045 x: 6 y: 7 z: 8
00046 }
00047 })";
00048
00049 using AddImuDataHandlerTest =
00050 testing::HandlerTest<AddImuDataSignature, AddImuDataHandler>;
00051
00052 TEST_F(AddImuDataHandlerTest, NoLocalSlamUploader) {
00053 proto::AddImuDataRequest request;
00054 EXPECT_TRUE(
00055 google::protobuf::TextFormat::ParseFromString(kMessage, &request));
00056 SetNoLocalTrajectoryUploader();
00057 EXPECT_CALL(
00058 *mock_map_builder_context_,
00059 CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
00060 Eq(request.sensor_metadata().trajectory_id())))
00061 .WillOnce(::testing::Return(true));
00062 EXPECT_CALL(*mock_map_builder_context_,
00063 DoEnqueueSensorData(
00064 Eq(request.sensor_metadata().trajectory_id()),
00065 Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
00066 test_server_->SendWrite(request);
00067 test_server_->SendWritesDone();
00068 test_server_->SendFinish();
00069 }
00070
00071 TEST_F(AddImuDataHandlerTest, WithMockLocalSlamUploader) {
00072 proto::AddImuDataRequest request;
00073 EXPECT_TRUE(
00074 google::protobuf::TextFormat::ParseFromString(kMessage, &request));
00075 SetMockLocalTrajectoryUploader();
00076 EXPECT_CALL(
00077 *mock_map_builder_context_,
00078 CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
00079 Eq(request.sensor_metadata().trajectory_id())))
00080 .WillOnce(::testing::Return(true));
00081 EXPECT_CALL(*mock_map_builder_context_,
00082 DoEnqueueSensorData(
00083 Eq(request.sensor_metadata().trajectory_id()),
00084 Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
00085 proto::SensorData sensor_data;
00086 *sensor_data.mutable_sensor_metadata() = request.sensor_metadata();
00087 *sensor_data.mutable_imu_data() = request.imu_data();
00088 EXPECT_CALL(*mock_local_trajectory_uploader_,
00089 DoEnqueueSensorData(Pointee(
00090 Truly(testing::BuildProtoPredicateEquals(&sensor_data)))));
00091 test_server_->SendWrite(request);
00092 test_server_->SendWritesDone();
00093 test_server_->SendFinish();
00094 }
00095
00096 }
00097 }
00098 }
00099 }