aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/planner-mock.c178
-rw-r--r--tests/test-clock.cpp8
-rw-r--r--tests/test-formatter.cc98
-rw-r--r--tests/test-formatter.cpp10
-rw-r--r--tests/test-live-actions.cpp4
-rw-r--r--tests/test-menus.cpp242
-rw-r--r--tests/test-planner.cpp6
-rw-r--r--tests/test-settings.cpp6
-rw-r--r--tests/test-timezone-geoclue.cpp59
9 files changed, 194 insertions, 417 deletions
diff --git a/tests/planner-mock.c b/tests/planner-mock.c
deleted file mode 100644
index df5413e..0000000
--- a/tests/planner-mock.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2013 Canonical Ltd.
- *
- * Authors:
- * Charles Kerr <charles.kerr@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "planner-mock.h"
-
-struct _IndicatorDatetimePlannerMockPriv
-{
- gboolean is_configured;
-};
-
-typedef IndicatorDatetimePlannerMockPriv priv_t;
-
-G_DEFINE_TYPE (IndicatorDatetimePlannerMock,
- indicator_datetime_planner_mock,
- INDICATOR_TYPE_DATETIME_PLANNER)
-
-/***
-**** IndicatorDatetimePlanner virtual funcs
-***/
-
-static void
-my_get_appointments (IndicatorDatetimePlanner * planner,
- GDateTime * begin_datetime,
- GDateTime * /*end_datetime*/,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GTask * task;
- GSList * appointments;
- struct IndicatorDatetimeAppt * appt;
- struct IndicatorDatetimeAppt * prev;
-
- task = g_task_new (planner, NULL, callback, user_data);
-
- /**
- *** Build the appointments list
- **/
-
- appointments = NULL;
-
- /* add a daily appointment that occurs at the beginning of the next minute */
- appt = g_slice_new0 (struct IndicatorDatetimeAppt);
- appt->is_daily = TRUE;
- appt->begin = g_date_time_add_seconds (begin_datetime, 60-g_date_time_get_seconds(begin_datetime));
- appt->end = g_date_time_add_minutes (appt->begin, 1);
- appt->color = g_strdup ("#00FF00");
- appt->is_event = TRUE;
- appt->summary = g_strdup ("Daily alarm");
- appt->uid = g_strdup ("this uid isn't very random.");
- appt->has_alarms = TRUE;
- appt->url = g_strdup ("alarm:///some-alarm-info-goes-here");
- appointments = g_slist_prepend (appointments, appt);
- prev = appt;
-
- /* and add one for a minute later that has an alarm uri */
- appt = g_slice_new0 (struct IndicatorDatetimeAppt);
- appt->is_daily = TRUE;
- appt->begin = g_date_time_add_minutes (prev->end, 1);
- appt->end = g_date_time_add_minutes (appt->begin, 1);
- appt->color = g_strdup ("#0000FF");
- appt->is_event = TRUE;
- appt->summary = g_strdup ("Second Daily alarm");
- appt->uid = g_strdup ("this uid isn't very random either.");
- appt->has_alarms = FALSE;
- appointments = g_slist_prepend (appointments, appt);
-
- /* done */
- g_task_return_pointer (task, appointments, NULL);
- g_object_unref (task);
-}
-
-static GSList *
-my_get_appointments_finish (IndicatorDatetimePlanner* /*self*/,
- GAsyncResult* res,
- GError** error)
-{
- return g_task_propagate_pointer(G_TASK(res), error);
-}
-
-static gboolean
-my_is_configured(IndicatorDatetimePlanner* planner)
-{
- IndicatorDatetimePlannerMock * self;
- self = INDICATOR_DATETIME_PLANNER_MOCK(planner);
- return self->priv->is_configured;
-}
-
-static void
-my_activate(IndicatorDatetimePlanner* /*self*/)
-{
- g_message("%s %s", G_STRLOC, G_STRFUNC);
-}
-
-static void
-my_activate_time(IndicatorDatetimePlanner* /*self*/,
- GDateTime* activate_time)
-{
- gchar * str = g_date_time_format(activate_time, "%F %T");
- g_message("%s %s: %s", G_STRLOC, G_STRFUNC, str);
- g_free(str);
-}
-
-/***
-**** GObject virtual funcs
-***/
-
-static void
-my_dispose(GObject * o)
-{
- G_OBJECT_CLASS(indicator_datetime_planner_mock_parent_class)->dispose(o);
-}
-
-/***
-**** Instantiation
-***/
-
-static void
-indicator_datetime_planner_mock_class_init(IndicatorDatetimePlannerMockClass* klass)
-{
- GObjectClass * object_class;
- IndicatorDatetimePlannerClass * planner_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = my_dispose;
-
- planner_class = INDICATOR_DATETIME_PLANNER_CLASS (klass);
- planner_class->is_configured = my_is_configured;
- planner_class->activate = my_activate;
- planner_class->activate_time = my_activate_time;
- planner_class->get_appointments = my_get_appointments;
- planner_class->get_appointments_finish = my_get_appointments_finish;
-
- g_type_class_add_private (klass, sizeof (IndicatorDatetimePlannerMockPriv));
-}
-
-static void
-indicator_datetime_planner_mock_init (IndicatorDatetimePlannerMock * self)
-{
- priv_t * p;
-
- p = G_TYPE_INSTANCE_GET_PRIVATE (self,
- INDICATOR_TYPE_DATETIME_PLANNER_MOCK,
- IndicatorDatetimePlannerMockPriv);
-
- p->is_configured = TRUE;
-
- self->priv = p;
-}
-
-/***
-**** Public
-***/
-
-IndicatorDatetimePlanner *
-indicator_datetime_planner_mock_new (void)
-{
- gpointer o = g_object_new (INDICATOR_TYPE_DATETIME_PLANNER_MOCK, NULL);
-
- return INDICATOR_DATETIME_PLANNER (o);
-}
diff --git a/tests/test-clock.cpp b/tests/test-clock.cpp
index 4271374..4287e1c 100644
--- a/tests/test-clock.cpp
+++ b/tests/test-clock.cpp
@@ -54,12 +54,12 @@ TEST_F(ClockFixture, MinuteChangedSignalShouldTriggerOncePerMinute)
LiveClock clock(zones);
wait_msec(500); // wait for the bus to set up
- // count how many times clock.minuteChanged() is emitted over the next minute
+ // count how many times clock.minute_changed() is emitted over the next minute
const DateTime now = clock.localtime();
const auto gnow = now.get();
auto gthen = g_date_time_add_minutes(gnow, 1);
int count = 0;
- clock.minuteChanged.connect([&count](){count++;});
+ clock.minute_changed.connect([&count](){count++;});
const auto msec = g_date_time_difference(gthen,gnow) / 1000;
wait_msec(msec);
EXPECT_EQ(1, count);
@@ -95,7 +95,7 @@ TEST_F(ClockFixture, TimezoneChangeTriggersSkew)
g_time_zone_unref(tz_nyc);
/// change the timezones!
- clock.minuteChanged.connect([this](){
+ clock.minute_changed.connect([this](){
g_main_loop_quit(loop);
});
g_idle_add([](gpointer gs){
@@ -124,7 +124,7 @@ TEST_F(ClockFixture, SleepTriggersSkew)
wait_msec(500); // wait for the bus to set up
bool skewed = false;
- clock.minuteChanged.connect([&skewed, this](){
+ clock.minute_changed.connect([&skewed, this](){
skewed = true;
g_main_loop_quit(loop);
return G_SOURCE_REMOVE;
diff --git a/tests/test-formatter.cc b/tests/test-formatter.cc
deleted file mode 100644
index 6a408ab..0000000
--- a/tests/test-formatter.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-
-/*
- * Copyright 2013 Canonical Ltd.
- *
- * Authors:
- * Charles Kerr <charles.kerr@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <langinfo.h>
-#include <locale.h>
-
-#include <glib/gi18n.h>
-
-#include "utils.h"
-
-#include "glib-fixture.h"
-
-/***
-****
-***/
-
-class FormatterFixture: public GlibFixture
-{
- private:
-
- typedef GlibFixture super;
- gchar * original_locale = nullptr;
-
- protected:
-
- virtual void SetUp ()
- {
- super::SetUp ();
-
- original_locale = g_strdup (setlocale (LC_TIME, NULL));
- }
-
- virtual void TearDown ()
- {
- setlocale (LC_TIME, original_locale);
- g_clear_pointer (&original_locale, g_free);
-
- super::TearDown ();
- }
-
- bool SetLocale (const char * expected_locale, const char * name)
- {
- setlocale (LC_TIME, expected_locale);
- const char * actual_locale = setlocale (LC_TIME, NULL);
- if (!g_strcmp0 (expected_locale, actual_locale))
- {
- return true;
- }
- else
- {
- g_warning ("Unable to set locale to %s; skipping %s locale tests.", expected_locale, name);
- return false;
- }
- }
-
- inline bool Set24hLocale () { return SetLocale ("C", "24h"); }
- inline bool Set12hLocale () { return SetLocale ("en_US.utf8", "12h"); }
-};
-
-
-/**
- * Test the phone header format
- */
-TEST_F (FormatterFixture, TestPhoneHeader)
-{
- // test the default value in a 24h locale
- if (Set24hLocale ())
- {
- const gchar * format = get_terse_header_time_format_string ();
- ASSERT_NE (nullptr, format);
- ASSERT_STREQ ("%H:%M", format);
- }
-
- // test the default value in a 12h locale
- if (Set12hLocale ())
- {
- const gchar * format = get_terse_header_time_format_string ();
- ASSERT_NE (nullptr, format);
- ASSERT_STREQ ("%l:%M %p", format);
- }
-}
diff --git a/tests/test-formatter.cpp b/tests/test-formatter.cpp
index 9950453..01df4f2 100644
--- a/tests/test-formatter.cpp
+++ b/tests/test-formatter.cpp
@@ -97,7 +97,7 @@ TEST_F(FormatterFixture, TestPhoneHeader)
if(Set24hLocale())
{
PhoneFormatter formatter(clock);
- EXPECT_EQ(std::string("%H:%M"), formatter.headerFormat.get());
+ EXPECT_EQ(std::string("%H:%M"), formatter.header_format.get());
EXPECT_EQ(std::string("18:30"), formatter.header.get());
}
@@ -105,7 +105,7 @@ TEST_F(FormatterFixture, TestPhoneHeader)
if(Set12hLocale())
{
PhoneFormatter formatter(clock);
- EXPECT_EQ(std::string("%l:%M %p"), formatter.headerFormat.get());
+ EXPECT_EQ(std::string("%l:%M %p"), formatter.header_format.get());
EXPECT_EQ(std::string(" 6:30 PM"), formatter.header.get());
}
}
@@ -156,7 +156,7 @@ TEST_F(FormatterFixture, TestDesktopHeader)
m_settings->show_date.set(test_case.show_date);
m_settings->show_year.set(test_case.show_year);
- ASSERT_STREQ(test_case.expected_format_string, f.headerFormat.get().c_str());
+ ASSERT_STREQ(test_case.expected_format_string, f.header_format.get().c_str());
}
}
}
@@ -196,7 +196,7 @@ TEST_F(FormatterFixture, TestUpcomingTimes)
std::shared_ptr<Clock> clock (new MockClock(DateTime(test_case.now)));
DesktopFormatter f(clock, m_settings);
- const auto fmt = f.getRelativeFormat(test_case.then);
+ const auto fmt = f.relative_format(test_case.then);
ASSERT_EQ(test_case.expected_format_string, fmt);
g_clear_pointer(&test_case.now, g_date_time_unref);
@@ -239,7 +239,7 @@ TEST_F(FormatterFixture, TestEventTimes)
std::shared_ptr<Clock> clock(new MockClock(DateTime(test_case.now)));
DesktopFormatter f(clock, m_settings);
- const auto fmt = f.getRelativeFormat(test_case.then, test_case.then_end);
+ const auto fmt = f.relative_format(test_case.then, test_case.then_end);
ASSERT_STREQ(test_case.expected_format_string, fmt.c_str());
g_clear_pointer(&test_case.now, g_date_time_unref);
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index 562b358..eab8596 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -356,11 +356,11 @@ TEST_F(LiveActionsFixture, CalendarState)
a2.begin = next_begin;
a2.end = next_end;
- m_state->planner->thisMonth.set(std::vector<Appointment>({a1, a2}));
+ m_state->planner->this_month.set(std::vector<Appointment>({a1, a2}));
///
/// Now test the calendar state again.
- /// The thisMonth field should now contain the appointments we just added.
+ /// The this_month field should now contain the appointments we just added.
///
calendar_state = g_action_group_get_action_state (action_group, "calendar");
diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp
index e9dd7df..73d6036 100644
--- a/tests/test-menus.cpp
+++ b/tests/test-menus.cpp
@@ -158,42 +158,20 @@ protected:
g_object_unref(submenu);
}
- void InspectAppointments(GMenuModel* menu_model, Menu::Profile profile)
- {
- const bool appointments_expected = (profile == Menu::Desktop)
- || (profile == Menu::Phone);
+private:
+ void InspectEmptySection(GMenuModel* menu_model, Menu::Section section)
+ {
// get the Appointments section
auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+ auto menu_section = g_menu_model_get_item_link(submenu, section, G_MENU_LINK_SECTION);
+ EXPECT_EQ(0, g_menu_model_get_n_items(menu_section));
+ g_clear_object(&menu_section);
+ g_clear_object(&submenu);
+ }
- // there shouldn't be any menuitems when "show events" is false
- m_state->settings->show_events.set(false);
- wait_msec();
- auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
- EXPECT_EQ(0, g_menu_model_get_n_items(section));
- g_clear_object(&section);
-
- // when "show_events" is true,
- // there should be an "add event" button even if there aren't any appointments
- std::vector<Appointment> appointments;
- m_state->settings->show_events.set(true);
- m_state->planner->upcoming.set(appointments);
- wait_msec();
- section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
- int expected_n = appointments_expected ? 1 : 0;
- EXPECT_EQ(expected_n, g_menu_model_get_n_items(section));
- if (appointments_expected)
- {
- gchar* action = nullptr;
- EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
- EXPECT_STREQ("indicator.activate-planner", action);
- EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), "activate-planner"));
- g_free(action);
- }
- g_clear_object(&section);
-
- // try adding a few appointments and see if the menu updates itself
-
+ 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);
@@ -206,7 +184,6 @@ protected:
a1.uid = "example";
a1.has_alarms = true;
a1.begin = a1.end = tomorrow;
- appointments.push_back(a1);
Appointment a2; // a non-alarm appointment
a2.color = "green";
@@ -215,52 +192,183 @@ protected:
a2.uid = "monkey";
a2.has_alarms = false;
a2.begin = a2.end = tomorrow;
- appointments.push_back(a2);
- m_state->planner->upcoming.set(appointments);
- wait_msec(); // wait a moment for the menu to update
+ return std::vector<Appointment>({a1, a2});
+ }
- section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
- expected_n = appointments_expected ? 3 : 0;
- EXPECT_EQ(expected_n, g_menu_model_get_n_items(section));
- if (appointments_expected)
+ void InspectAppointmentMenuItem(GMenuModel* section,
+ int index,
+ const Appointment& appt)
+ {
+ // confirm it has the right x-canonical-type
+ gchar * str = nullptr;
+ g_menu_model_get_item_attribute(section, index, "x-canonical-type", "s", &str);
+ if (appt.has_alarms)
+ EXPECT_STREQ("com.canonical.indicator.alarm", str);
+ else
+ EXPECT_STREQ("com.canonical.indicator.appointment", str);
+ g_clear_pointer(&str, g_free);
+
+ // confirm it has a nonempty x-canonical-time-format
+ g_menu_model_get_item_attribute(section, index, "x-canonical-time-format", "s", &str);
+ EXPECT_TRUE(str && *str);
+ g_clear_pointer(&str, g_free);
+
+ // confirm the color hint, if it exists,
+ // is in the x-canonical-color attribute
+ if (appt.color.empty())
{
- gchar * str = nullptr;
+ EXPECT_FALSE(g_menu_model_get_item_attribute(section,
+ index,
+ "x-canonical-color",
+ "s",
+ &str));
+ }
+ else
+ {
+ EXPECT_TRUE(g_menu_model_get_item_attribute(section,
+ index,
+ "x-canonical-color",
+ "s",
+ &str));
+ EXPECT_EQ(appt.color, str);
+ }
+ g_clear_pointer(&str, g_free);
- // test the alarm
- // - confirm it has an x-canonical-type of "alarm"
- g_menu_model_get_item_attribute(section, 0, "x-canonical-type", "s", &str);
- EXPECT_STREQ("com.canonical.indicator.alarm", str);
- g_clear_pointer(&str, g_free);
- // - confirm it has a nonempty x-canonical-time-format
- g_menu_model_get_item_attribute(section, 0, "x-canonical-time-format", "s", &str);
- EXPECT_TRUE(str && *str);
- g_clear_pointer(&str, g_free);
- // - confirm it has a serialized icon attribute
- auto v = g_menu_model_get_item_attribute_value(section, 0, G_MENU_ATTRIBUTE_ICON, nullptr);
+ // confirm that alarms have an icon
+ if (appt.has_alarms)
+ {
+ auto v = g_menu_model_get_item_attribute_value(section,
+ index,
+ G_MENU_ATTRIBUTE_ICON,
+ nullptr);
EXPECT_TRUE(v != nullptr);
auto icon = g_icon_deserialize(v);
EXPECT_TRUE(icon != nullptr);
g_clear_object(&icon);
g_clear_pointer(&v, g_variant_unref);
-
- // test the appointment
- // - confirm it has an x-canonical-type of "appointment"
- g_menu_model_get_item_attribute(section, 1, "x-canonical-type", "s", &str);
- EXPECT_STREQ("com.canonical.indicator.appointment", str);
- g_clear_pointer(&str, g_free);
- // - confirm it has a nonempty x-canonical-time-format
- g_menu_model_get_item_attribute(section, 0, "x-canonical-time-format", "s", &str);
- EXPECT_TRUE(str && *str);
- g_clear_pointer(&str, g_free);
- // - confirm its color matches the one we fed the appointments vector
- g_menu_model_get_item_attribute(section, 1, "x-canonical-color", "s", &str);
- EXPECT_EQ(a2.color, str);
- g_clear_pointer(&str, g_free);
}
+ }
+
+ void InspectAppointmentMenuItems(GMenuModel* section,
+ int first_appt_index,
+ const std::vector<Appointment>& appointments)
+ {
+ // try adding a few appointments and see if the menu updates itself
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+
+ //auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+ //auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(appointments.size()+1, g_menu_model_get_n_items(section));
+
+ for (int i=0, n=appointments.size(); i<n; i++)
+ InspectAppointmentMenuItem(section, first_appt_index+i, appointments[i]);
+
+ //g_clear_object(&section);
+ //g_clear_object(&submenu);
+ }
+
+ void InspectDesktopAppointments(GMenuModel* menu_model)
+ {
+ // get the Appointments section
+ auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+
+ // there shouldn't be any menuitems when "show events" is false
+ m_state->settings->show_events.set(false);
+ wait_msec();
+ auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(0, g_menu_model_get_n_items(section));
g_clear_object(&section);
- g_object_unref(submenu);
+ // when "show_events" is true,
+ // there should be an "add event" button even if there aren't any appointments
+ std::vector<Appointment> appointments;
+ m_state->settings->show_events.set(true);
+ m_state->planner->upcoming.set(appointments);
+ wait_msec();
+ section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(1, g_menu_model_get_n_items(section));
+ gchar* action = nullptr;
+ EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
+ const char* expected_action = "activate-planner";
+ EXPECT_EQ(std::string("indicator.")+expected_action, action);
+ EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action));
+ g_free(action);
+ g_clear_object(&section);
+
+ // try adding a few appointments and see if the menu updates itself
+ appointments = build_some_appointments();
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+ section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(3, g_menu_model_get_n_items(section));
+ InspectAppointmentMenuItems(section, 0, appointments);
+ g_clear_object(&section);
+
+ // cleanup
+ g_clear_object(&submenu);
+ }
+
+ void InspectPhoneAppointments(GMenuModel* menu_model)
+ {
+ auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+
+ // clear all the appointments
+ std::vector<Appointment> appointments;
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+
+ // check that there's a "clock app" menuitem even when there are no appointments
+ auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ const char* expected_action = "activate-phone-clock-app";
+ EXPECT_EQ(1, g_menu_model_get_n_items(section));
+ gchar* action = nullptr;
+ EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
+ EXPECT_EQ(std::string("indicator.")+expected_action, action);
+ EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action));
+ g_free(action);
+ g_clear_object(&section);
+
+ // add some appointments and test them
+ appointments = build_some_appointments();
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+ section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(3, g_menu_model_get_n_items(section));
+ InspectAppointmentMenuItems(section, 1, appointments);
+ g_clear_object(&section);
+
+ // cleanup
+ g_clear_object(&submenu);
+ }
+
+protected:
+
+ void InspectAppointments(GMenuModel* menu_model, Menu::Profile profile)
+ {
+ switch (profile)
+ {
+ case Menu::Desktop:
+ InspectDesktopAppointments(menu_model);
+ break;
+
+ case Menu::DesktopGreeter:
+ InspectEmptySection(menu_model, Menu::Appointments);
+ break;
+
+ case Menu::Phone:
+ InspectPhoneAppointments(menu_model);
+ break;
+
+ case Menu::PhoneGreeter:
+ InspectEmptySection(menu_model, Menu::Appointments);
+ break;
+
+ default:
+ g_warn_if_reached();
+ break;
+ }
}
void CompareLocationsTo(GMenuModel* menu_model, const std::vector<Location>& locations)
diff --git a/tests/test-planner.cpp b/tests/test-planner.cpp
index 3072aea..b476ee8 100644
--- a/tests/test-planner.cpp
+++ b/tests/test-planner.cpp
@@ -47,9 +47,9 @@ TEST_F(PlannerFixture, EDS)
planner.time.set(DateTime(now));
wait_msec(2500);
- std::vector<Appointment> thisMonth = planner.thisMonth.get();
- std::cerr << thisMonth.size() << " appointments this month" << std::endl;
- for(const auto& a : thisMonth)
+ std::vector<Appointment> this_month = planner.this_month.get();
+ std::cerr << this_month.size() << " appointments this month" << std::endl;
+ for(const auto& a : this_month)
std::cerr << a.summary << std::endl;
}
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index df01cd7..980e7fa 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -189,9 +189,3 @@ TEST_F(SettingsFixture, Locations)
g_strfreev(tmp);
EXPECT_EQ(bv, vtmp);
}
-
-#if 0
- core::Property<std::vector<std::string>> locations;
- core::Property<TimeFormatMode> time_format_mode;
-
-#endif
diff --git a/tests/test-timezone-geoclue.cpp b/tests/test-timezone-geoclue.cpp
index 4bf08a7..3cc1393 100644
--- a/tests/test-timezone-geoclue.cpp
+++ b/tests/test-timezone-geoclue.cpp
@@ -21,64 +21,17 @@
#include <datetime/timezone-geoclue.h>
-//#include <libdbustest/dbus-test.h>
-
using unity::indicator::datetime::GeoclueTimezone;
-/***
-****
-***/
-
-class TimezoneGeoclueFixture : public GeoclueFixture
-{
-};
-
-#if 0
-namespace
+// This test looks small because the interesting
+// work is all happening in GeoclueFixture...
+TEST_F(GeoclueFixture, ChangeDetected)
{
- struct EmitAddressChangedData
- {
- DbusTestDbusMock * mock = nullptr;
- DbusTestDbusMockObject * obj_client = nullptr;
- std::string timezone;
- EmitAddressChangedData(DbusTestDbusMock * mock_,
- DbusTestDbusMockObject * obj_client_,
- const std::string& timezone_): mock(mock_), obj_client(obj_client_), timezone(timezone_) {}
- };
-
- gboolean emit_address_changed_idle(gpointer gdata)
- {
- auto data = static_cast<EmitAddressChangedData*>(gdata);
-
- GError * error = nullptr;
- dbus_test_dbus_mock_object_emit_signal(data->mock, data->obj_client,
- "org.freedesktop.Geoclue.Address",
- "AddressChanged",
- G_VARIANT_TYPE("(ia{ss}(idd))"),
- g_variant_new_parsed("(1385238033, {'timezone': 'America/Chicago'}, (3, 0.0, 0.0))"),
- &error);
- if (error)
- {
- g_warning("%s: %s", G_STRFUNC, error->message);
- g_error_free(error);
- }
-
- delete data;
- return G_SOURCE_REMOVE;
- }
-}
-#endif
-
-TEST_F(TimezoneGeoclueFixture, ChangeDetected)
-{
-// const std::string timezone_1 = "America/Denver";
- const std::string timezone_2 = "America/Chicago";
-
GeoclueTimezone tz;
wait_msec(500); // wait for the bus to get set up
EXPECT_EQ(timezone_1, tz.timezone.get());
- // start listening for a timezone change, then change the timezone
+ // Start listening for a timezone change, then change the timezone.
bool changed = false;
auto connection = tz.timezone.changed().connect(
@@ -88,10 +41,8 @@ TEST_F(TimezoneGeoclueFixture, ChangeDetected)
g_main_loop_quit(loop);
});
+ const std::string timezone_2 = "America/Chicago";
setGeoclueTimezoneOnIdle(timezone_2);
- //g_timeout_add(50, emit_address_changed_idle, new EmitAddressChangedData(mock, obj_client, timezone_2.c_str()));
g_main_loop_run(loop);
EXPECT_EQ(timezone_2, tz.timezone.get());
}
-
-