diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-alarm-queue.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/test-alarm-queue.cpp b/tests/test-alarm-queue.cpp index 881a4ad..d2de8ac 100644 --- a/tests/test-alarm-queue.cpp +++ b/tests/test-alarm-queue.cpp @@ -17,7 +17,8 @@ * Charles Kerr <charles.kerr@canonical.com> */ -#include <datetime/alarm-queue.h> +#include <datetime/alarm-queue-simple.h> +#include <datetime/wakeup-timer-mainloop.h> #include <gtest/gtest.h> @@ -34,6 +35,7 @@ private: protected: std::vector<std::string> m_triggered; + std::shared_ptr<WakeupTimer> m_wakeup_timer; std::unique_ptr<AlarmQueue> m_watcher; std::shared_ptr<RangePlanner> m_range_planner; std::shared_ptr<UpcomingPlanner> m_upcoming; @@ -42,9 +44,10 @@ protected: { super::SetUp(); + m_wakeup_timer.reset(new MainloopWakeupTimer(m_state->clock)); m_range_planner.reset(new MockRangePlanner); m_upcoming.reset(new UpcomingPlanner(m_range_planner, m_state->clock->localtime())); - m_watcher.reset(new AlarmQueueImpl(m_state->clock, m_upcoming)); + m_watcher.reset(new SimpleAlarmQueue(m_state->clock, m_upcoming, m_wakeup_timer)); m_watcher->alarm_reached().connect([this](const Appointment& appt){ m_triggered.push_back(appt.uid); }); @@ -117,7 +120,7 @@ TEST_F(AlarmQueueFixture, AppointmentsChanged) m_range_planner->appointments().set(a); // Confirm that it got fired - EXPECT_EQ(1, m_triggered.size()); + ASSERT_EQ(1, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); } @@ -132,8 +135,9 @@ TEST_F(AlarmQueueFixture, TimeChanged) // Set the state's clock to a time that matches one of the appointments(). // That appointment should get triggered. +g_message ("%s setting clock to %s", G_STRLOC, a[1].begin.format("%F %T").c_str()); m_mock_state->mock_clock->set_localtime(a[1].begin); - EXPECT_EQ(1, m_triggered.size()); + ASSERT_EQ(1, m_triggered.size()); EXPECT_EQ(a[1].uid, m_triggered[0]); } @@ -145,7 +149,7 @@ TEST_F(AlarmQueueFixture, MoreThanOne) a[0].begin = a[1].begin = now; m_range_planner->appointments().set(a); - EXPECT_EQ(2, m_triggered.size()); + ASSERT_EQ(2, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); EXPECT_EQ(a[1].uid, m_triggered[1]); } @@ -160,13 +164,13 @@ TEST_F(AlarmQueueFixture, NoDuplicates) a.push_back(appointments[0]); a[0].begin = now; m_range_planner->appointments().set(a); - EXPECT_EQ(1, m_triggered.size()); + ASSERT_EQ(1, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); // Now change the appointment vector by adding one to it. // Confirm that the AlarmQueue doesn't re-trigger a[0] a.push_back(appointments[1]); m_range_planner->appointments().set(a); - EXPECT_EQ(1, m_triggered.size()); + ASSERT_EQ(1, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); } |