diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2015-03-17 15:23:49 +0000 |
---|---|---|
committer | CI Train Bot <ci-train-bot@canonical.com> | 2015-03-17 15:23:49 +0000 |
commit | ddde67df581dea8c5a261e43d5b12a3821f06ed1 (patch) | |
tree | e3c2859c54b0bba9c72ad221ea41c95ed8f5a70f /tests/test-actions.cpp | |
parent | 15ec7f61fa84a9a8b40c1c9fcfa6c2a268d3232b (diff) | |
parent | 273c3b3829c9a3e853d0b6b0a32ae87cc3c6852b (diff) | |
download | ayatana-indicator-datetime-ddde67df581dea8c5a261e43d5b12a3821f06ed1.tar.gz ayatana-indicator-datetime-ddde67df581dea8c5a261e43d5b12a3821f06ed1.tar.bz2 ayatana-indicator-datetime-ddde67df581dea8c5a261e43d5b12a3821f06ed1.zip |
Fix bug that prevented clicking on calendar days where DST sprang forward. Fixes: #1429388
Approved by: Ted Gould, PS Jenkins bot
Diffstat (limited to 'tests/test-actions.cpp')
-rw-r--r-- | tests/test-actions.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp index fc89426..2a8e370 100644 --- a/tests/test-actions.cpp +++ b/tests/test-actions.cpp @@ -30,9 +30,7 @@ class ActionsFixture: public StateFixture std::vector<Appointment> build_some_appointments() { const auto now = m_state->clock->localtime(); - auto gdt_tomorrow = g_date_time_add_days(now.get(), 1); - const auto tomorrow = DateTime(gdt_tomorrow); - g_date_time_unref(gdt_tomorrow); + const auto tomorrow = now.add_days(1); Appointment a1; // an alarm clock appointment a1.color = "red"; @@ -255,9 +253,7 @@ TEST_F(ActionsFixture, SetCalendarDate) EXPECT_TRUE(g_action_group_has_action(action_group, action_name)); // pick an arbitrary DateTime... - auto tmp = g_date_time_new_local(2010, 1, 2, 3, 4, 5); - const auto now = DateTime(tmp); - g_date_time_unref(tmp); + auto now = DateTime::Local(2010, 1, 2, 3, 4, 5); // confirm that Planner.time gets changed to that date when we // activate the 'calendar' action with that date's time_t as the arg @@ -265,6 +261,18 @@ TEST_F(ActionsFixture, SetCalendarDate) auto v = g_variant_new_int64(now.to_unix()); g_action_group_activate_action (action_group, action_name, v); EXPECT_TRUE(DateTime::is_same_day (now, m_state->calendar_month->month().get())); + + // DST change in US + now = DateTime::Local(2015, 3, 8, 9, 0, 0); + v = g_variant_new_int64(now.to_unix()); + g_action_group_activate_action (action_group, action_name, v); + EXPECT_TRUE(DateTime::is_same_day (now, m_state->calendar_month->month().get())); + + // DST change in Europe + now = DateTime::Local(2015, 3, 29, 9, 0, 0); + v = g_variant_new_int64(now.to_unix()); + g_action_group_activate_action (action_group, action_name, v); + EXPECT_TRUE(DateTime::is_same_day (now, m_state->calendar_month->month().get())); } TEST_F(ActionsFixture, ActivatingTheCalendarResetsItsDate) @@ -280,16 +288,14 @@ TEST_F(ActionsFixture, ActivatingTheCalendarResetsItsDate) // move calendar-date a week into the future... const auto now = m_state->clock->localtime(); - auto next_week = g_date_time_add_weeks(now.get(), 1); - const auto next_week_unix = g_date_time_to_unix(next_week); + const auto next_week = now.add_days(7); + const auto next_week_unix = next_week.to_unix(); g_action_group_activate_action (action_group, "calendar", g_variant_new_int64(next_week_unix)); // confirm the planner and calendar action state moved a week into the future // but that m_state->clock is unchanged - auto expected = g_date_time_add_full (next_week, 0, 0, 0, -g_date_time_get_hour(next_week), - -g_date_time_get_minute(next_week), - -g_date_time_get_seconds(next_week)); - const auto expected_unix = g_date_time_to_unix(expected); + auto expected = next_week.start_of_day(); + const auto expected_unix = expected.to_unix(); EXPECT_EQ(expected_unix, m_state->calendar_month->month().get().to_unix()); EXPECT_EQ(now, m_state->clock->localtime()); auto calendar_state = g_action_group_get_action_state(action_group, "calendar"); @@ -301,9 +307,6 @@ TEST_F(ActionsFixture, ActivatingTheCalendarResetsItsDate) g_clear_pointer(&v, g_variant_unref); g_clear_pointer(&calendar_state, g_variant_unref); - g_date_time_unref(expected); - g_date_time_unref(next_week); - /// /// Now the actual test. /// We set the state of 'calendar-active' to true, which should reset the calendar date. |