10 #include <gtest/gtest.h>
11 #include <log4cplus/logger.h>
21 using namespace ::testing;
22 using namespace std::chrono_literals;
32 m_status = std::make_shared<ObservableStatus>(
"id",
"fileid");
37 std::shared_ptr<daq::ObservableStatus>
m_status;
45 ASSERT_TRUE(fut.is_ready());
46 auto result = fut.get();
47 EXPECT_FALSE(result.error);
48 EXPECT_EQ(result.result, *m_status);
55 auto [fut, abort] = op::InitiateAbortableOperation<op::AwaitStateAsync>(
56 m_io_ctx, m_status, State::Acquiring, 100ms);
59 EXPECT_FALSE(fut.is_ready());
61 EXPECT_FALSE(fut.is_ready());
63 m_status->SetState(State::Acquiring);
65 ASSERT_TRUE(fut.is_ready());
67 auto result = fut.get();
68 EXPECT_FALSE(result.error);
69 EXPECT_EQ(result.result, *m_status);
76 auto [fut, abort] = op::InitiateAbortableOperation<op::AwaitStateAsync>(
77 m_io_ctx, m_status, State::Acquiring, 0ms);
81 ASSERT_TRUE(fut.is_ready());
83 auto result = fut.get();
84 EXPECT_TRUE(result.error);
85 EXPECT_EQ(result.result, *m_status);
92 auto [fut, abort] = op::InitiateAbortableOperation<op::AwaitStateAsync>(
93 m_io_ctx, m_status, State::Acquiring, 100ms);
97 ASSERT_TRUE(fut.is_ready());
106 auto [fut, abort] = op::InitiateAbortableOperation<op::AwaitStateAsync>(
107 m_io_ctx, m_status, State::Acquiring, 0ms);
111 auto& mut_status =
const_cast<Status&
>(m_status->GetStatus());
112 mut_status.
state = State::Acquiring;
115 ASSERT_TRUE(fut.is_ready());
117 auto result = fut.get();
118 EXPECT_FALSE(result.error);
119 EXPECT_EQ(result.result, *m_status);