2018-02-02 08:16:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2018 The Cartographer Authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-03-02 18:38:35 +08:00
|
|
|
#include "cartographer_grpc/internal/handlers/add_odometry_data_handler.h"
|
2018-03-02 21:16:49 +08:00
|
|
|
#include "cartographer_grpc/internal/testing/handler_test.h"
|
|
|
|
#include "cartographer_grpc/internal/testing/test_helpers.h"
|
2018-02-02 08:16:14 +08:00
|
|
|
#include "google/protobuf/text_format.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2018-03-03 06:21:28 +08:00
|
|
|
namespace cartographer {
|
|
|
|
namespace cloud {
|
2018-02-02 08:16:14 +08:00
|
|
|
namespace handlers {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
using ::testing::_;
|
|
|
|
using ::testing::Eq;
|
|
|
|
using ::testing::Pointee;
|
|
|
|
using ::testing::Truly;
|
|
|
|
|
2018-03-05 18:47:00 +08:00
|
|
|
const std::string kMessage = R"(
|
2018-02-02 08:16:14 +08:00
|
|
|
sensor_metadata {
|
|
|
|
trajectory_id: 1
|
|
|
|
sensor_id: "sensor_id"
|
|
|
|
}
|
|
|
|
odometry_data {
|
|
|
|
timestamp: 2
|
|
|
|
pose {
|
|
|
|
translation {
|
2018-02-07 17:14:59 +08:00
|
|
|
x: 3 y: 4 z: 5
|
2018-02-02 08:16:14 +08:00
|
|
|
}
|
|
|
|
rotation {
|
2018-02-07 17:14:59 +08:00
|
|
|
w: 6 x: 7 y: 8 z: 9
|
2018-02-02 08:16:14 +08:00
|
|
|
}
|
|
|
|
}
|
2018-03-05 18:47:00 +08:00
|
|
|
})";
|
2018-02-02 08:16:14 +08:00
|
|
|
|
2018-02-05 21:50:43 +08:00
|
|
|
using AddOdometryDataHandlerTest = testing::HandlerTest<AddOdometryDataHandler>;
|
2018-02-02 08:16:14 +08:00
|
|
|
|
|
|
|
TEST_F(AddOdometryDataHandlerTest, NoLocalSlamUploader) {
|
|
|
|
proto::AddOdometryDataRequest request;
|
|
|
|
EXPECT_TRUE(
|
|
|
|
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
|
|
|
|
SetNoLocalTrajectoryUploader();
|
|
|
|
EXPECT_CALL(*mock_map_builder_context_,
|
|
|
|
DoEnqueueSensorData(
|
|
|
|
Eq(request.sensor_metadata().trajectory_id()),
|
|
|
|
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
|
|
|
|
test_server_->SendWrite(request);
|
|
|
|
test_server_->SendWritesDone();
|
|
|
|
test_server_->SendFinish();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(AddOdometryDataHandlerTest, WithMockLocalSlamUploader) {
|
|
|
|
proto::AddOdometryDataRequest request;
|
|
|
|
EXPECT_TRUE(
|
|
|
|
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
|
|
|
|
SetMockLocalTrajectoryUploader();
|
|
|
|
EXPECT_CALL(*mock_map_builder_context_,
|
|
|
|
DoEnqueueSensorData(
|
|
|
|
Eq(request.sensor_metadata().trajectory_id()),
|
|
|
|
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
|
|
|
|
EXPECT_CALL(*mock_local_trajectory_uploader_,
|
|
|
|
DoEnqueueDataRequest(Pointee(
|
|
|
|
Truly(testing::BuildProtoPredicateEquals(&request)))));
|
|
|
|
test_server_->SendWrite(request);
|
|
|
|
test_server_->SendWritesDone();
|
|
|
|
test_server_->SendFinish();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace handlers
|
2018-03-03 06:21:28 +08:00
|
|
|
} // namespace cloud
|
|
|
|
} // namespace cartographer
|