2018-02-01 20:05:08 +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 21:16:49 +08:00
|
|
|
#ifndef CARTOGRAPHER_GRPC_INTERNAL_TESTING_MOCK_MAP_BUILDER_CONTEXT_H
|
|
|
|
#define CARTOGRAPHER_GRPC_INTERNAL_TESTING_MOCK_MAP_BUILDER_CONTEXT_H
|
2018-02-01 20:05:08 +08:00
|
|
|
|
|
|
|
#include "cartographer/mapping/local_slam_result_data.h"
|
2018-03-02 21:16:49 +08:00
|
|
|
#include "cartographer_grpc/internal/map_builder_context_interface.h"
|
2018-02-01 20:05:08 +08:00
|
|
|
#include "glog/logging.h"
|
|
|
|
#include "gmock/gmock.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2018-03-03 06:21:28 +08:00
|
|
|
namespace cartographer {
|
|
|
|
namespace cloud {
|
2018-02-01 20:05:08 +08:00
|
|
|
namespace testing {
|
|
|
|
|
|
|
|
class MockMapBuilderContext : public MapBuilderContextInterface {
|
|
|
|
public:
|
2018-03-03 06:21:28 +08:00
|
|
|
MOCK_METHOD0(map_builder, mapping::MapBuilderInterface &());
|
|
|
|
MOCK_METHOD0(
|
|
|
|
sensor_data_queue,
|
|
|
|
common::BlockingQueue<std::unique_ptr<MapBuilderContextInterface::Data>>
|
|
|
|
&());
|
2018-02-01 20:05:08 +08:00
|
|
|
MOCK_METHOD0(GetLocalSlamResultCallbackForSubscriptions,
|
2018-03-03 06:21:28 +08:00
|
|
|
mapping::TrajectoryBuilderInterface::LocalSlamResultCallback());
|
2018-02-01 20:05:08 +08:00
|
|
|
MOCK_METHOD1(AddSensorDataToTrajectory,
|
|
|
|
void(const MapBuilderContextInterface::Data &));
|
|
|
|
MOCK_METHOD2(SubscribeLocalSlamResults,
|
|
|
|
MapBuilderContextInterface::SubscriptionId(
|
|
|
|
int,
|
|
|
|
MapBuilderContextInterface::LocalSlamSubscriptionCallback));
|
|
|
|
MOCK_METHOD1(UnsubscribeLocalSlamResults,
|
|
|
|
void(const MapBuilderContextInterface::SubscriptionId &));
|
|
|
|
MOCK_METHOD1(NotifyFinishTrajectory, void(int));
|
|
|
|
MOCK_METHOD3(DoProcessLocalSlamResultData,
|
2018-03-03 06:21:28 +08:00
|
|
|
mapping::LocalSlamResultData *(
|
|
|
|
const std::string &, common::Time,
|
|
|
|
const mapping::proto::LocalSlamResultData &));
|
|
|
|
std::unique_ptr<mapping::LocalSlamResultData> ProcessLocalSlamResultData(
|
|
|
|
const std::string &sensor_id, common::Time time,
|
|
|
|
const mapping::proto::LocalSlamResultData &proto) override {
|
|
|
|
return std::unique_ptr<mapping::LocalSlamResultData>(
|
2018-02-01 20:05:08 +08:00
|
|
|
DoProcessLocalSlamResultData(sensor_id, time, proto));
|
|
|
|
}
|
|
|
|
MOCK_METHOD0(local_trajectory_uploader, LocalTrajectoryUploaderInterface *());
|
|
|
|
|
2018-03-03 06:21:28 +08:00
|
|
|
MOCK_METHOD2(DoEnqueueSensorData, void(int, sensor::Data *));
|
|
|
|
void EnqueueSensorData(int trajectory_id,
|
|
|
|
std::unique_ptr<sensor::Data> data) override {
|
2018-02-01 20:05:08 +08:00
|
|
|
DoEnqueueSensorData(trajectory_id, data.get());
|
|
|
|
}
|
|
|
|
MOCK_METHOD3(DoEnqueueLocalSlamResultData,
|
2018-03-03 06:21:28 +08:00
|
|
|
void(int, const std::string &, mapping::LocalSlamResultData *));
|
|
|
|
void EnqueueLocalSlamResultData(int trajectory_id,
|
|
|
|
const std::string &sensor_id,
|
|
|
|
std::unique_ptr<mapping::LocalSlamResultData>
|
|
|
|
local_slam_result_data) override {
|
2018-02-01 20:05:08 +08:00
|
|
|
DoEnqueueLocalSlamResultData(trajectory_id, sensor_id,
|
|
|
|
local_slam_result_data.get());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace testing
|
2018-03-03 06:21:28 +08:00
|
|
|
} // namespace cloud
|
|
|
|
} // namespace cartographer
|
2018-02-01 20:05:08 +08:00
|
|
|
|
2018-03-02 21:16:49 +08:00
|
|
|
#endif // CARTOGRAPHER_GRPC_INTERNAL_TESTING_MOCK_MAP_BUILDER_CONTEXT_H
|