15 #include <gmock/gmock.h> 16 #include <gtest/gtest.h> 19 #include <condition_variable> 38 using namespace std::chrono_literals;
39 std::this_thread::sleep_for(100ms);
44 TEST(TestRosbagRecorder, TestRosbagRecorderRun)
49 ASSERT_FALSE(rosbag_recorder.
IsActive());
51 std::promise<bool> pre_invoked;
52 std::promise<bool> post_invoked;
54 std::future<bool> pre_invoked_f = pre_invoked.get_future();
55 std::future<bool> post_invoked_f = post_invoked.get_future();
56 auto result = rosbag_recorder.
Run(
60 pre_invoked.set_value(
true);
64 ASSERT_EQ(exit_code, 0);
65 post_invoked.set_value(
true);
69 ASSERT_TRUE(pre_invoked_f.get());
70 ASSERT_TRUE(post_invoked_f.get());
73 TEST(TestRosbagRecorder, TestRosbagRecorderIsActive)
78 std::promise<void> barrier;
79 std::future<void> barrier_future = barrier.get_future();
81 ASSERT_FALSE(rosbag_recorder.
IsActive());
83 auto result = rosbag_recorder.
Run(
90 ASSERT_EQ(exit_code, 0);
91 barrier_future.wait();
96 ASSERT_TRUE(rosbag_recorder.
IsActive());
98 result = rosbag_recorder.
Run(
113 using namespace std::chrono_literals;
114 std::this_thread::sleep_for(1
s);
116 ASSERT_FALSE(rosbag_recorder.
IsActive());
virtual RosbagRecorderRunResult Run(const RecorderOptions &recorder_options, const std::function< void()> &pre_record=nullptr, const std::function< void(int)> &post_record=nullptr)
TEST(TestRosbagRecorder, TestRosbagRecorderRun)
virtual bool IsActive() const
MockRecorder(RecorderOptions const &options)