aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-actions.cpp21
-rw-r--r--tests/test-alarm-queue.cpp19
-rw-r--r--tests/test-live-actions.cpp27
-rw-r--r--tests/test-menus.cpp8
4 files changed, 19 insertions, 56 deletions
diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp
index fc89426..74fc380 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);
+ const 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
@@ -280,16 +276,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 +295,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.
diff --git a/tests/test-alarm-queue.cpp b/tests/test-alarm-queue.cpp
index 12ffe92..0492539 100644
--- a/tests/test-alarm-queue.cpp
+++ b/tests/test-alarm-queue.cpp
@@ -68,12 +68,8 @@ protected:
std::vector<Appointment> build_some_appointments()
{
const auto now = m_state->clock->localtime();
- auto tomorrow = g_date_time_add_days (now.get(), 1);
- auto tomorrow_begin = g_date_time_add_full (tomorrow, 0, 0, 0,
- -g_date_time_get_hour(tomorrow),
- -g_date_time_get_minute(tomorrow),
- -g_date_time_get_seconds(tomorrow));
- auto tomorrow_end = g_date_time_add_full (tomorrow_begin, 0, 0, 1, 0, 0, -1);
+ const auto tomorrow_begin = now.add_days(1).start_of_day();
+ const auto tomorrow_end = tomorrow_begin.add_full(0, 0, 1, 0, 0, -1);
Appointment a1; // an alarm clock appointment
a1.color = "red";
@@ -84,8 +80,8 @@ protected:
a1.begin = tomorrow_begin;
a1.end = tomorrow_end;
- auto ubermorgen_begin = g_date_time_add_days (tomorrow, 1);
- auto ubermorgen_end = g_date_time_add_full (tomorrow_begin, 0, 0, 1, 0, 0, -1);
+ const auto ubermorgen_begin = now.add_days(2).start_of_day();
+ const auto ubermorgen_end = ubermorgen_begin.add_full(0, 0, 1, 0, 0, -1);
Appointment a2; // a non-alarm appointment
a2.color = "green";
@@ -96,13 +92,6 @@ protected:
a2.begin = ubermorgen_begin;
a2.end = ubermorgen_end;
- // cleanup
- g_date_time_unref(ubermorgen_end);
- g_date_time_unref(ubermorgen_begin);
- g_date_time_unref(tomorrow_end);
- g_date_time_unref(tomorrow_begin);
- g_date_time_unref(tomorrow);
-
return std::vector<Appointment>({a1, a2});
}
};
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index 1197e3e..98e9c58 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -346,9 +346,7 @@ TEST_F(LiveActionsFixture, PhoneOpenSettingsApp)
TEST_F(LiveActionsFixture, CalendarState)
{
// init the clock
- auto tmp = g_date_time_new_local (2014, 1, 1, 0, 0, 0);
- const DateTime now (tmp);
- g_date_time_unref (tmp);
+ auto now = DateTime::Local(2014, 1, 1, 0, 0, 0);
m_mock_state->mock_clock->set_localtime (now);
m_state->calendar_month->month().set(now);
//m_state->planner->time.set(now);
@@ -388,12 +386,8 @@ TEST_F(LiveActionsFixture, CalendarState)
/// Now add appointments to the planner and confirm that the state keeps in sync
///
- auto tomorrow = g_date_time_add_days (now.get(), 1);
- auto tomorrow_begin = g_date_time_add_full (tomorrow, 0, 0, 0,
- -g_date_time_get_hour(tomorrow),
- -g_date_time_get_minute(tomorrow),
- -g_date_time_get_seconds(tomorrow));
- auto tomorrow_end = g_date_time_add_full (tomorrow_begin, 0, 0, 1, 0, 0, -1);
+ auto tomorrow_begin = now.add_days(1).start_of_day();
+ auto tomorrow_end = tomorrow_begin.add_full(0,0,1,0,0,-1);
Appointment a1;
a1.color = "green";
a1.summary = "write unit tests";
@@ -402,8 +396,8 @@ TEST_F(LiveActionsFixture, CalendarState)
a1.begin = tomorrow_begin;
a1.end = tomorrow_end;
- auto next_begin = g_date_time_add_days (tomorrow_begin, 1);
- auto next_end = g_date_time_add_full (next_begin, 0, 0, 1, 0, 0, -1);
+ auto next_begin = now.add_days(2).start_of_day();
+ auto next_end = next_begin.add_days(1);
Appointment a2;
a2.color = "orange";
a2.summary = "code review";
@@ -424,19 +418,12 @@ TEST_F(LiveActionsFixture, CalendarState)
EXPECT_TRUE (v != nullptr);
int i;
g_variant_get_child (v, 0, "i", &i);
- EXPECT_EQ (g_date_time_get_day_of_month(a1.begin.get()), i);
+ EXPECT_EQ (a1.begin.day_of_month(), i);
g_variant_get_child (v, 1, "i", &i);
- EXPECT_EQ (g_date_time_get_day_of_month(a2.begin.get()), i);
+ EXPECT_EQ (a2.begin.day_of_month(), i);
g_clear_pointer(&v, g_variant_unref);
g_clear_pointer(&calendar_state, g_variant_unref);
- // cleanup this step
- g_date_time_unref (next_end);
- g_date_time_unref (next_begin);
- g_date_time_unref (tomorrow_end);
- g_date_time_unref (tomorrow_begin);
- g_date_time_unref (tomorrow);
-
///
/// Confirm that the action state's dictionary
/// keeps in sync with settings.show_week_numbers
diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp
index e0e63ac..fb9c50a 100644
--- a/tests/test-menus.cpp
+++ b/tests/test-menus.cpp
@@ -151,9 +151,7 @@ protected:
// now change the clock and see if the date label changes appropriately
- auto gdt_tomorrow = g_date_time_add_days(now.get(), 1);
- auto tomorrow = DateTime(gdt_tomorrow);
- g_date_time_unref(gdt_tomorrow);
+ auto tomorrow = now.add_days(1).start_of_day();
m_mock_state->mock_clock->set_localtime(tomorrow);
wait_msec();
@@ -182,9 +180,7 @@ private:
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";