diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-03-14 17:37:00 +0000 |
---|---|---|
committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-03-14 17:37:00 +0000 |
commit | 9f3136ba1c79020c10e58fa53e87a84bcce7dc29 (patch) | |
tree | fa0c19e8e5c7f362b7a04f0ad3e6f57d96c1462c /tests/test-clock-watcher.cpp | |
parent | 39d8fc602053397a3596d6d35afb5738b09b05a6 (diff) | |
parent | 35b0a3601f1d7d9f757467ffc7b909c461c2f49d (diff) | |
download | ayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.tar.gz ayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.tar.bz2 ayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.zip |
When the user clicks on a date in the calendar, update the "Upcoming Events" section to show events starting at that date. Fixes: 1290169, 1290171, 1291468
Diffstat (limited to 'tests/test-clock-watcher.cpp')
-rw-r--r-- | tests/test-clock-watcher.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/test-clock-watcher.cpp b/tests/test-clock-watcher.cpp index 79b8485..2425fe8 100644 --- a/tests/test-clock-watcher.cpp +++ b/tests/test-clock-watcher.cpp @@ -35,12 +35,16 @@ protected: std::vector<std::string> m_triggered; std::unique_ptr<ClockWatcher> m_watcher; + std::shared_ptr<RangePlanner> m_range_planner; + std::shared_ptr<UpcomingPlanner> m_upcoming; void SetUp() { super::SetUp(); - m_watcher.reset(new ClockWatcherImpl(m_state)); + m_range_planner.reset(new MockRangePlanner); + m_upcoming.reset(new UpcomingPlanner(m_range_planner, m_state->clock->localtime())); + m_watcher.reset(new ClockWatcherImpl(m_state->clock, m_upcoming)); m_watcher->alarm_reached().connect([this](const Appointment& appt){ m_triggered.push_back(appt.uid); }); @@ -52,6 +56,8 @@ protected: { m_triggered.clear(); m_watcher.reset(); + m_upcoming.reset(); + m_range_planner.reset(); super::TearDown(); } @@ -108,7 +114,7 @@ TEST_F(ClockWatcherFixture, AppointmentsChanged) // One of these matches our state's localtime, so that should get triggered. std::vector<Appointment> a = build_some_appointments(); a[0].begin = m_state->clock->localtime(); - m_state->planner->upcoming.set(a); + m_range_planner->appointments().set(a); // Confirm that it got fired EXPECT_EQ(1, m_triggered.size()); @@ -121,10 +127,10 @@ TEST_F(ClockWatcherFixture, TimeChanged) // Add some appointments to the planner. // Neither of these match the state's localtime, so nothing should be triggered. std::vector<Appointment> a = build_some_appointments(); - m_state->planner->upcoming.set(a); + m_range_planner->appointments().set(a); EXPECT_TRUE(m_triggered.empty()); - // Set the state's clock to a time that matches one of the appointments. + // Set the state's clock to a time that matches one of the appointments(). // That appointment should get triggered. m_mock_state->mock_clock->set_localtime(a[1].begin); EXPECT_EQ(1, m_triggered.size()); @@ -137,7 +143,7 @@ TEST_F(ClockWatcherFixture, MoreThanOne) const auto now = m_state->clock->localtime(); std::vector<Appointment> a = build_some_appointments(); a[0].begin = a[1].begin = now; - m_state->planner->upcoming.set(a); + m_range_planner->appointments().set(a); EXPECT_EQ(2, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); @@ -153,14 +159,14 @@ TEST_F(ClockWatcherFixture, NoDuplicates) std::vector<Appointment> a; a.push_back(appointments[0]); a[0].begin = now; - m_state->planner->upcoming.set(a); + m_range_planner->appointments().set(a); EXPECT_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 ClockWatcher doesn't re-trigger a[0] a.push_back(appointments[1]); - m_state->planner->upcoming.set(a); + m_range_planner->appointments().set(a); EXPECT_EQ(1, m_triggered.size()); EXPECT_EQ(a[0].uid, m_triggered[0]); } |