Merge lp:~charlesk/indicator-datetime/lp-1295799-date-menuitem-should-open-calendar into lp:indicator-datetime/14.04

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 329
Merged at revision: 332
Proposed branch: lp:~charlesk/indicator-datetime/lp-1295799-date-menuitem-should-open-calendar
Merge into: lp:indicator-datetime/14.04
Diff against target: 1162 lines (+537/-305)
11 files modified
README (+16/-8)
include/datetime/actions-live.h (+11/-8)
include/datetime/actions.h (+13/-7)
src/actions-live.cpp (+38/-25)
src/actions.cpp (+81/-61)
src/menu.cpp (+32/-24)
tests/actions-mock.h (+46/-23)
tests/test-actions.cpp (+192/-104)
tests/test-exporter.cpp (+8/-5)
tests/test-live-actions.cpp (+80/-29)
tests/test-menus.cpp (+20/-11)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1295799-date-menuitem-should-open-calendar
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+212277@code.launchpad.net

Commit message

Add support for opening the calendar app on the phone via the date menuitem.

Description of the change

Add support for opening the calendar app on the phone via the date menuitem.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

> * Ensure the project compiles and the test suite executes without error

Done on desktop + nexus phone.

> * Ensure that non-obvious code has comments explaining it

No new non-obvious code. The per-profile actions are actually more readable now.

> * If the change works on specific profiles, please include those in the merge description.

Changes phone behavior s.t. clicking on the date menuitem pops up the calendar app.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Wow, simple changes cause a lot of ripple. We should probably long term think about a way to get the action names into consts so that we're not duplicating them all over the codebase. Then we could "C++ namespace" as well as "GAction namespace" them. Not for this MR though.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README'
--- README 2014-01-22 15:04:30 +0000
+++ README 2014-03-22 07:33:30 +0000
@@ -1,18 +1,26 @@
1ACTIONS1ACTIONS
2=======2=======
33
4 * "activate-settings"4 * "desktop.open-settings-app"
5 Description: opens a page for changing indicator-datetime's settings5 * "phone.open-settings-app"
6 State: None6 Description: open the settings application.
7 Parameter: None7 State: None
88 Parameter: None
9 * "activate-planner"9
10 Description: opens an appointment editor.10 * "desktop.open-alarm-app"
11 * "phone.open-alarm-app"
12 Description: open the application for creating new alarms.
13 State: None
14 Parameter: None
15
16 * "desktop.open-calendar-app"
17 * "phone.open-calendar-app"
11 State: None18 State: None
12 Parameter: int64, a time_t hinting which day/time to show in the planner,19 Parameter: int64, a time_t hinting which day/time to show in the planner,
13 or 0 for the current day20 or 0 for the current day
1421
15 * "activate-appointment"22 * "desktop.open-appointment"
23 * "phone.open-appointment"
16 Description: opens an appointment editor to the specified appointment.24 Description: opens an appointment editor to the specified appointment.
17 State: None25 State: None
18 Parameter: string, an opaque uid to specify which appointment to use.26 Parameter: string, an opaque uid to specify which appointment to use.
1927
=== modified file 'include/datetime/actions-live.h'
--- include/datetime/actions-live.h 2014-03-06 23:54:57 +0000
+++ include/datetime/actions-live.h 2014-03-22 07:33:30 +0000
@@ -39,15 +39,18 @@
39 LiveActions(const std::shared_ptr<State>& state_in);39 LiveActions(const std::shared_ptr<State>& state_in);
40 ~LiveActions() =default;40 ~LiveActions() =default;
4141
42 void open_desktop_settings();42 bool desktop_has_calendar_app() const;
43 void open_phone_settings();43 void desktop_open_alarm_app();
44 void open_phone_clock_app();44 void desktop_open_appointment(const Appointment&);
45 bool can_open_planner() const;45 void desktop_open_calendar_app(const DateTime&);
46 void open_planner();46 void desktop_open_settings_app();
47 void open_planner_at(const DateTime&);47
48 void open_appointment(const std::string& uid);48 void phone_open_alarm_app();
49 void phone_open_appointment(const Appointment&);
50 void phone_open_calendar_app(const DateTime&);
51 void phone_open_settings_app();
52
49 void set_location(const std::string& zone, const std::string& name);53 void set_location(const std::string& zone, const std::string& name);
50 void set_calendar_date(const DateTime&);
5154
52protected:55protected:
53 virtual void execute_command(const std::string& command);56 virtual void execute_command(const std::string& command);
5457
=== modified file 'include/datetime/actions.h'
--- include/datetime/actions.h 2014-03-06 23:54:57 +0000
+++ include/datetime/actions.h 2014-03-22 07:33:30 +0000
@@ -42,14 +42,20 @@
42class Actions42class Actions
43{43{
44public:44public:
45 virtual void open_desktop_settings() =0;45
46 virtual void open_phone_settings() =0;46 virtual bool desktop_has_calendar_app() const =0;
47 virtual void open_phone_clock_app() =0;47 virtual void desktop_open_alarm_app() =0;
48 virtual bool can_open_planner() const = 0;48 virtual void desktop_open_appointment(const Appointment&) =0;
49 virtual void open_planner() =0;49 virtual void desktop_open_calendar_app(const DateTime&) =0;
50 virtual void open_planner_at(const DateTime&) =0;50 virtual void desktop_open_settings_app() =0;
51 virtual void open_appointment(const std::string& uid) =0;51
52 virtual void phone_open_alarm_app() =0;
53 virtual void phone_open_appointment(const Appointment&) =0;
54 virtual void phone_open_calendar_app(const DateTime&) =0;
55 virtual void phone_open_settings_app() =0;
56
52 virtual void set_location(const std::string& zone, const std::string& name)=0;57 virtual void set_location(const std::string& zone, const std::string& name)=0;
58
53 void set_calendar_date(const DateTime&);59 void set_calendar_date(const DateTime&);
54 GActionGroup* action_group();60 GActionGroup* action_group();
55 const std::shared_ptr<State> state() const;61 const std::shared_ptr<State> state() const;
5662
=== modified file 'src/actions-live.cpp'
--- src/actions-live.cpp 2014-03-14 17:37:21 +0000
+++ src/actions-live.cpp 2014-03-22 07:33:30 +0000
@@ -51,6 +51,7 @@
5151
52void LiveActions::dispatch_url(const std::string& url)52void LiveActions::dispatch_url(const std::string& url)
53{53{
54 g_debug("Dispatching url '%s'", url.c_str());
54 url_dispatch_send(url.c_str(), nullptr, nullptr);55 url_dispatch_send(url.c_str(), nullptr, nullptr);
55}56}
5657
@@ -58,7 +59,7 @@
58****59****
59***/60***/
6061
61void LiveActions::open_desktop_settings()62void LiveActions::desktop_open_settings_app()
62{63{
63 auto path = g_find_program_in_path("unity-control-center");64 auto path = g_find_program_in_path("unity-control-center");
6465
@@ -74,7 +75,7 @@
74 g_free (path);75 g_free (path);
75}76}
7677
77bool LiveActions::can_open_planner() const78bool LiveActions::desktop_has_calendar_app() const
78{79{
79 static bool inited = false;80 static bool inited = false;
80 static bool have_calendar = false;81 static bool have_calendar = false;
@@ -98,22 +99,17 @@
98 return have_calendar;99 return have_calendar;
99}100}
100101
101void LiveActions::open_planner()102void LiveActions::desktop_open_alarm_app()
102{103{
103 execute_command("evolution -c calendar");104 execute_command("evolution -c calendar");
104}105}
105106
106void LiveActions::open_phone_settings()107void LiveActions::desktop_open_appointment(const Appointment& appt)
107{108{
108 dispatch_url("settings:///system/time-date");109 desktop_open_calendar_app(appt.begin);
109}110}
110111
111void LiveActions::open_phone_clock_app()112void LiveActions::desktop_open_calendar_app(const DateTime& dt)
112{
113 dispatch_url("appid://com.ubuntu.clock/clock/current-user-version");
114}
115
116void LiveActions::open_planner_at(const DateTime& dt)
117{113{
118 const auto day_begins = dt.add_full(0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds());114 const auto day_begins = dt.add_full(0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds());
119 const auto gmt = day_begins.to_timezone("UTC");115 const auto gmt = day_begins.to_timezone("UTC");
@@ -121,17 +117,34 @@
121 execute_command(cmd.c_str());117 execute_command(cmd.c_str());
122}118}
123119
124void LiveActions::open_appointment(const std::string& uid)120/***
125{121****
126 for(const auto& appt : state()->calendar_upcoming->appointments().get())122***/
127 {123
128 if(appt.uid != uid)124void LiveActions::phone_open_alarm_app()
129 continue;125{
130126 dispatch_url("appid://com.ubuntu.clock/clock/current-user-version");
131 if (!appt.url.empty())127}
132 dispatch_url(appt.url);128
133 break;129void LiveActions::phone_open_appointment(const Appointment& appt)
134 }130{
131 if (!appt.url.empty())
132 dispatch_url(appt.url);
133 else if (appt.has_alarms)
134 phone_open_alarm_app();
135 else
136 phone_open_calendar_app(DateTime::NowLocal());
137}
138
139void LiveActions::phone_open_calendar_app(const DateTime&)
140{
141 // does calendar app have a mechanism for specifying dates?
142 dispatch_url("appid://com.ubuntu.calendar/calendar/current-user-version");
143}
144
145void LiveActions::phone_open_settings_app()
146{
147 dispatch_url("settings:///system/time-date");
135}148}
136149
137/***150/***
138151
=== modified file 'src/actions.cpp'
--- src/actions.cpp 2014-03-10 02:08:47 +0000
+++ src/actions.cpp 2014-03-22 07:33:30 +0000
@@ -34,67 +34,81 @@
34namespace34namespace
35{35{
3636
37void on_desktop_settings_activated(GSimpleAction * /*action*/,37DateTime datetime_from_timet_variant(GVariant* v)
38 GVariant * /*param*/,38{
39 gpointer gself)39 int64_t t = 0;
40{40
41 static_cast<Actions*>(gself)->open_desktop_settings();41 if (v != nullptr)
42}42 if (g_variant_type_equal(G_VARIANT_TYPE_INT64,g_variant_get_type(v)))
4343 t = g_variant_get_int64(v);
44void on_phone_settings_activated(GSimpleAction * /*action*/,44
45 GVariant * /*param*/,45 if (t != 0)
46 gpointer gself)46 return DateTime(t);
47{47 else
48 static_cast<Actions*>(gself)->open_phone_settings();48 return DateTime::NowLocal();
49}49}
5050
51void on_phone_clock_activated(GSimpleAction * /*action*/,51bool lookup_appointment_by_uid_variant(const std::shared_ptr<State>& state, GVariant* vuid, Appointment& setme)
52 GVariant * /*param*/,52{
53 gpointer gself)53 g_return_val_if_fail(vuid != nullptr, false);
54{54 g_return_val_if_fail(g_variant_type_equal(G_VARIANT_TYPE_STRING,g_variant_get_type(vuid)), false);
55 static_cast<Actions*>(gself)->open_phone_clock_app();55 const auto uid = g_variant_get_string(vuid, nullptr);
56}56 g_return_val_if_fail(uid && *uid, false);
5757
58void on_activate_appointment(GSimpleAction * /*action*/,58 for(const auto& appt : state->calendar_upcoming->appointments().get())
59 GVariant * param,
60 gpointer gself)
61{
62 const auto uid = g_variant_get_string(param, nullptr);
63 auto self = static_cast<Actions*>(gself);
64
65 g_return_if_fail(uid && *uid);
66
67 // find url of the upcoming appointment with this uid
68 for (const auto& appt : self->state()->calendar_upcoming->appointments().get())
69 {59 {
70 if (appt.uid == uid)60 if (appt.uid == uid)
71 {61 {
72 const auto url = appt.url;62 setme = appt;
73 g_debug("%s: uid[%s] -> url[%s]", G_STRFUNC, uid, url.c_str());63 return true;
74 self->open_appointment(url);
75 break;
76 }64 }
77 }65 }
78}66
7967 return false;
80void on_activate_planner(GSimpleAction * /*action*/,68}
81 GVariant * param,69
82 gpointer gself)70void on_desktop_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself)
83{71{
84 const auto at = g_variant_get_int64(param);72 auto self = static_cast<Actions*>(gself);
85 auto self = static_cast<Actions*>(gself);73 Appointment appt;
8674 if (lookup_appointment_by_uid_variant(self->state(), vuid, appt))
87 if (at)75 self->desktop_open_appointment(appt);
88 {76}
89 auto gdt = g_date_time_new_from_unix_local(at);77void on_desktop_alarm_activated (GSimpleAction*, GVariant*, gpointer gself)
90 self->open_planner_at(DateTime(gdt));78{
91 g_date_time_unref(gdt);79 static_cast<Actions*>(gself)->desktop_open_alarm_app();
92 }80}
93 else // no time specified...81void on_desktop_calendar_activated (GSimpleAction*, GVariant* vt, gpointer gself)
94 {82{
95 self->open_planner();83 const auto dt = datetime_from_timet_variant(vt);
96 }84 static_cast<Actions*>(gself)->desktop_open_calendar_app(dt);
97}85}
86void on_desktop_settings_activated (GSimpleAction*, GVariant*, gpointer gself)
87{
88 static_cast<Actions*>(gself)->desktop_open_settings_app();
89}
90
91void on_phone_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself)
92{
93 auto self = static_cast<Actions*>(gself);
94 Appointment appt;
95 if (lookup_appointment_by_uid_variant(self->state(), vuid, appt))
96 self->phone_open_appointment(appt);
97}
98void on_phone_alarm_activated (GSimpleAction*, GVariant*, gpointer gself)
99{
100 static_cast<Actions*>(gself)->phone_open_alarm_app();
101}
102void on_phone_calendar_activated (GSimpleAction*, GVariant* vt, gpointer gself)
103{
104 const auto dt = datetime_from_timet_variant(vt);
105 static_cast<Actions*>(gself)->phone_open_calendar_app(dt);
106}
107void on_phone_settings_activated (GSimpleAction*, GVariant*, gpointer gself)
108{
109 static_cast<Actions*>(gself)->phone_open_settings_app();
110}
111
98112
99void on_set_location(GSimpleAction * /*action*/,113void on_set_location(GSimpleAction * /*action*/,
100 GVariant * param,114 GVariant * param,
@@ -183,11 +197,17 @@
183 m_actions(g_simple_action_group_new())197 m_actions(g_simple_action_group_new())
184{198{
185 GActionEntry entries[] = {199 GActionEntry entries[] = {
186 { "activate-desktop-settings", on_desktop_settings_activated },200
187 { "activate-phone-settings", on_phone_settings_activated },201 { "desktop.open-appointment", on_desktop_appointment_activated, "s", nullptr },
188 { "activate-phone-clock-app", on_phone_clock_activated },202 { "desktop.open-alarm-app", on_desktop_alarm_activated },
189 { "activate-appointment", on_activate_appointment, "s", nullptr },203 { "desktop.open-calendar-app", on_desktop_calendar_activated, "x", nullptr },
190 { "activate-planner", on_activate_planner, "x", nullptr },204 { "desktop.open-settings-app", on_desktop_settings_activated },
205
206 { "phone.open-appointment", on_phone_appointment_activated, "s", nullptr },
207 { "phone.open-alarm-app", on_phone_alarm_activated },
208 { "phone.open-calendar-app", on_phone_calendar_activated, "x", nullptr },
209 { "phone.open-settings-app", on_phone_settings_activated },
210
191 { "calendar-active", nullptr, nullptr, "false", on_calendar_active_changed },211 { "calendar-active", nullptr, nullptr, "false", on_calendar_active_changed },
192 { "set-location", on_set_location, "s" }212 { "set-location", on_set_location, "s" }
193 };213 };
194214
=== modified file 'src/menu.cpp'
--- src/menu.cpp 2014-03-10 03:32:19 +0000
+++ src/menu.cpp 2014-03-22 07:33:30 +0000
@@ -225,22 +225,28 @@
225225
226 GMenuModel* create_calendar_section(Profile profile)226 GMenuModel* create_calendar_section(Profile profile)
227 {227 {
228 const bool allow_activation = (profile == Desktop)
229 || (profile == Phone);
230 const bool show_calendar = m_state->settings->show_calendar.get() &&228 const bool show_calendar = m_state->settings->show_calendar.get() &&
231 ((profile == Desktop) || (profile == DesktopGreeter));229 ((profile == Desktop) || (profile == DesktopGreeter));
232 auto menu = g_menu_new();230 auto menu = g_menu_new();
233231
232 const char * action_name;
233
234 if (profile == Phone)
235 action_name = "indicator.phone.open-calendar-app";
236 else if (profile == Desktop)
237 action_name = "indicator.desktop.open-calendar-app";
238 else
239 action_name = nullptr;
240
234 // add a menuitem that shows the current date241 // add a menuitem that shows the current date
235 auto label = m_state->clock->localtime().format(_("%A, %e %B %Y"));242 auto label = m_state->clock->localtime().format(_("%A, %e %B %Y"));
236 auto item = g_menu_item_new (label.c_str(), nullptr);243 auto item = g_menu_item_new (label.c_str(), nullptr);
237 auto v = get_serialized_calendar_icon();244 auto v = get_serialized_calendar_icon();
238 g_menu_item_set_attribute_value (item, G_MENU_ATTRIBUTE_ICON, v);245 g_menu_item_set_attribute_value (item, G_MENU_ATTRIBUTE_ICON, v);
239 if (allow_activation)246 if (action_name != nullptr)
240 {247 {
241 v = g_variant_new_int64(0);248 v = g_variant_new_int64(0);
242 const char* action = "indicator.activate-planner";249 g_menu_item_set_action_and_target_value (item, action_name, v);
243 g_menu_item_set_action_and_target_value (item, action, v);
244 }250 }
245 g_menu_append_item(menu, item);251 g_menu_append_item(menu, item);
246 g_object_unref(item);252 g_object_unref(item);
@@ -253,11 +259,8 @@
253 g_menu_item_set_action_and_target_value (item, "indicator.calendar", v);259 g_menu_item_set_action_and_target_value (item, "indicator.calendar", v);
254 g_menu_item_set_attribute (item, "x-canonical-type",260 g_menu_item_set_attribute (item, "x-canonical-type",
255 "s", "com.canonical.indicator.calendar");261 "s", "com.canonical.indicator.calendar");
256 if (allow_activation)262 if (action_name != nullptr)
257 {263 g_menu_item_set_attribute (item, "activation-action", "s", action_name);
258 g_menu_item_set_attribute (item, "activation-action",
259 "s", "indicator.activate-planner");
260 }
261 g_menu_append_item (menu, item);264 g_menu_append_item (menu, item);
262 g_object_unref (item);265 g_object_unref (item);
263 }266 }
@@ -270,6 +273,15 @@
270 const int MAX_APPTS = 5;273 const int MAX_APPTS = 5;
271 std::set<std::string> added;274 std::set<std::string> added;
272275
276 const char * action_name;
277
278 if (profile == Phone)
279 action_name = "indicator.phone.open-appointment";
280 else if ((profile == Desktop) && m_actions->desktop_has_calendar_app())
281 action_name = "indicator.desktop.open-appointment";
282 else
283 action_name = nullptr;
284
273 for (const auto& appt : m_upcoming)285 for (const auto& appt : m_upcoming)
274 {286 {
275 // don't show duplicates287 // don't show duplicates
@@ -303,15 +315,11 @@
303315
304 if (!appt.color.empty())316 if (!appt.color.empty())
305 g_menu_item_set_attribute (menu_item, "x-canonical-color", "s", appt.color.c_str());317 g_menu_item_set_attribute (menu_item, "x-canonical-color", "s", appt.color.c_str());
306 318
307 if (profile == Phone)319 if (action_name != nullptr)
308 g_menu_item_set_action_and_target_value (menu_item,320 g_menu_item_set_action_and_target_value (menu_item, action_name,
309 "indicator.activate-appointment",321 g_variant_new_string (appt.uid.c_str()));
310 g_variant_new_string (appt.uid.c_str()));322
311 else if (m_actions->can_open_planner())
312 g_menu_item_set_action_and_target_value (menu_item,
313 "indicator.activate-planner",
314 g_variant_new_int64 (unix_time));
315 g_menu_append_item (menu, menu_item);323 g_menu_append_item (menu, menu_item);
316 g_object_unref (menu_item);324 g_object_unref (menu_item);
317 }325 }
@@ -325,11 +333,11 @@
325 {333 {
326 add_appointments (menu, profile);334 add_appointments (menu, profile);
327335
328 if (m_actions->can_open_planner())336 if (m_actions->desktop_has_calendar_app())
329 {337 {
330 // add the 'Add Event…' menuitem338 // add the 'Add Event…' menuitem
331 auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);339 auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);
332 const gchar* action_name = "indicator.activate-planner";340 const gchar* action_name = "indicator.desktop.open-calendar-app";
333 auto v = g_variant_new_int64(0);341 auto v = g_variant_new_int64(0);
334 g_menu_item_set_action_and_target_value(menu_item, action_name, v);342 g_menu_item_set_action_and_target_value(menu_item, action_name, v);
335 g_menu_append_item(menu, menu_item);343 g_menu_append_item(menu, menu_item);
@@ -338,7 +346,7 @@
338 }346 }
339 else if (profile==Phone)347 else if (profile==Phone)
340 {348 {
341 auto menu_item = g_menu_item_new (_("Clock"), "indicator.activate-phone-clock-app");349 auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app");
342 g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());350 g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
343 g_menu_append_item (menu, menu_item);351 g_menu_append_item (menu, menu_item);
344 g_object_unref (menu_item);352 g_object_unref (menu_item);
@@ -383,11 +391,11 @@
383391
384 if (profile == Desktop)392 if (profile == Desktop)
385 {393 {
386 g_menu_append (menu, _("Date & Time Settings…"), "indicator.activate-desktop-settings");394 g_menu_append (menu, _("Date & Time Settings…"), "indicator.desktop.open-settings-app");
387 }395 }
388 else if (profile == Phone)396 else if (profile == Phone)
389 {397 {
390 g_menu_append (menu, _("Time & Date settings…"), "indicator.activate-phone-settings");398 g_menu_append (menu, _("Time & Date settings…"), "indicator.phone.open-settings-app");
391 }399 }
392400
393 return G_MENU_MODEL (menu);401 return G_MENU_MODEL (menu);
394402
=== modified file 'tests/actions-mock.h'
--- tests/actions-mock.h 2014-03-06 23:54:57 +0000
+++ tests/actions-mock.h 2014-03-22 07:33:30 +0000
@@ -34,28 +34,54 @@
34 MockActions(std::shared_ptr<State>& state_in): Actions(state_in) {}34 MockActions(std::shared_ptr<State>& state_in): Actions(state_in) {}
35 ~MockActions() =default;35 ~MockActions() =default;
3636
37 enum Action { OpenDesktopSettings, OpenPhoneSettings, OpenPhoneClockApp,37 enum Action { DesktopOpenAlarmApp,
38 OpenPlanner, OpenPlannerAt, OpenAppointment, SetLocation };38 DesktopOpenAppt,
39 DesktopOpenCalendarApp,
40 DesktopOpenSettingsApp,
41 PhoneOpenAlarmApp,
42 PhoneOpenAppt,
43 PhoneOpenCalendarApp,
44 PhoneOpenSettingsApp,
45 SetLocation };
46
39 const std::vector<Action>& history() const { return m_history; }47 const std::vector<Action>& history() const { return m_history; }
40 const DateTime& date_time() const { return m_date_time; }48 const DateTime& date_time() const { return m_date_time; }
41 const std::string& zone() const { return m_zone; }49 const std::string& zone() const { return m_zone; }
42 const std::string& name() const { return m_name; }50 const std::string& name() const { return m_name; }
43 const std::string& url() const { return m_url; }51 const Appointment& appointment() const { return m_appt; }
44 void clear() { m_history.clear(); m_zone.clear(); m_name.clear(); }52 void clear() { m_history.clear(); m_zone.clear(); m_name.clear(); }
4553
46 void open_desktop_settings() { m_history.push_back(OpenDesktopSettings); }54 bool desktop_has_calendar_app() const {
4755 return m_desktop_has_calendar_app;
48 void open_phone_settings() { m_history.push_back(OpenPhoneSettings); }56 }
4957 void desktop_open_alarm_app() {
50 void open_phone_clock_app() { m_history.push_back(OpenPhoneClockApp); }58 m_history.push_back(DesktopOpenAlarmApp);
5159 }
52 bool can_open_planner() const { return m_can_open_planner; }60 void desktop_open_appointment(const Appointment& appt) {
5361 m_appt = appt;
54 void open_planner() { m_history.push_back(OpenPlanner); }62 m_history.push_back(DesktopOpenAppt);
5563 }
56 void open_planner_at(const DateTime& date_time_) {64 void desktop_open_calendar_app(const DateTime& dt) {
57 m_history.push_back(OpenPlannerAt);65 m_date_time = dt;
58 m_date_time = date_time_;66 m_history.push_back(DesktopOpenCalendarApp);
67 }
68 void desktop_open_settings_app() {
69 m_history.push_back(DesktopOpenSettingsApp);
70 }
71
72 void phone_open_alarm_app() {
73 m_history.push_back(PhoneOpenAlarmApp);
74 }
75 void phone_open_appointment(const Appointment& appt) {
76 m_appt = appt;
77 m_history.push_back(PhoneOpenAppt);
78 }
79 void phone_open_calendar_app(const DateTime& dt) {
80 m_date_time = dt;
81 m_history.push_back(PhoneOpenCalendarApp);
82 }
83 void phone_open_settings_app() {
84 m_history.push_back(PhoneOpenSettingsApp);
59 }85 }
6086
61 void set_location(const std::string& zone_, const std::string& name_) {87 void set_location(const std::string& zone_, const std::string& name_) {
@@ -64,16 +90,13 @@
64 m_name = name_;90 m_name = name_;
65 }91 }
6692
67 void open_appointment(const std::string& url_) {93 void set_desktop_has_calendar_app(bool b) {
68 m_history.push_back(OpenAppointment);94 m_desktop_has_calendar_app = b;
69 m_url = url_;
70 }95 }
7196
72 void set_can_open_planner(bool b) { m_can_open_planner = b; }
73
74private:97private:
75 bool m_can_open_planner = true;98 bool m_desktop_has_calendar_app = true;
76 std::string m_url;99 Appointment m_appt;
77 std::string m_zone;100 std::string m_zone;
78 std::string m_name;101 std::string m_name;
79 DateTime m_date_time;102 DateTime m_date_time;
80103
=== modified file 'tests/test-actions.cpp'
--- tests/test-actions.cpp 2014-03-10 02:08:47 +0000
+++ tests/test-actions.cpp 2014-03-22 07:33:30 +0000
@@ -23,7 +23,130 @@
2323
24using namespace unity::indicator::datetime;24using namespace unity::indicator::datetime;
2525
26typedef StateFixture ActionsFixture;26class ActionsFixture: public StateFixture
27{
28 typedef StateFixture super;
29
30 std::vector<Appointment> build_some_appointments()
31 {
32 const auto now = m_state->clock->localtime();
33 auto gdt_tomorrow = g_date_time_add_days(now.get(), 1);
34 const auto tomorrow = DateTime(gdt_tomorrow);
35 g_date_time_unref(gdt_tomorrow);
36
37 Appointment a1; // an alarm clock appointment
38 a1.color = "red";
39 a1.summary = "Alarm";
40 a1.summary = "http://www.example.com/";
41 a1.uid = "example";
42 a1.has_alarms = true;
43 a1.begin = a1.end = tomorrow;
44
45 Appointment a2; // a non-alarm appointment
46 a2.color = "green";
47 a2.summary = "Other Text";
48 a2.summary = "http://www.monkey.com/";
49 a2.uid = "monkey";
50 a2.has_alarms = false;
51 a2.begin = a2.end = tomorrow;
52
53 return std::vector<Appointment>({a1, a2});
54 }
55
56protected:
57
58 virtual void SetUp()
59 {
60 super::SetUp();
61 }
62
63 virtual void TearDown()
64 {
65 super::TearDown();
66 }
67
68 void test_action_with_no_args(const char * action_name,
69 MockActions::Action expected_action)
70 {
71 // preconditions
72 EXPECT_TRUE(m_mock_actions->history().empty());
73 auto action_group = m_actions->action_group();
74 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));
75
76 // run the test
77 g_action_group_activate_action(action_group, action_name, nullptr);
78
79 // test the results
80 EXPECT_EQ(std::vector<MockActions::Action>({expected_action}),
81 m_mock_actions->history());
82 }
83
84 void test_action_with_time_arg(const char * action_name,
85 MockActions::Action expected_action)
86 {
87 // preconditions
88 EXPECT_TRUE(m_mock_actions->history().empty());
89 auto action_group = m_actions->action_group();
90 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));
91
92 // activate the action
93 const auto now = DateTime::NowLocal();
94 auto v = g_variant_new_int64(now.to_unix());
95 g_action_group_activate_action(action_group, action_name, v);
96
97 // test the results
98 EXPECT_EQ(std::vector<MockActions::Action>({expected_action}),
99 m_mock_actions->history());
100 EXPECT_EQ(now.format("%F %T"),
101 m_mock_actions->date_time().format("%F %T"));
102 }
103
104 void test_action_with_appt_arg(const char * action_name,
105 MockActions::Action expected_action)
106 {
107 ///
108 /// Test 1: activate an appointment that we know about
109 ///
110
111 // preconditions
112 EXPECT_TRUE(m_mock_actions->history().empty());
113 auto action_group = m_actions->action_group();
114 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));
115
116 // init some appointments to the state
117 const auto appointments = build_some_appointments();
118 m_mock_state->mock_range_planner->appointments().set(appointments);
119
120 // activate the action
121 auto v = g_variant_new_string(appointments[0].uid.c_str());
122 g_action_group_activate_action(action_group, action_name, v);
123
124 // test the results
125 EXPECT_EQ(std::vector<MockActions::Action>({expected_action}),
126 m_mock_actions->history());
127 EXPECT_EQ(appointments[0],
128 m_mock_actions->appointment());
129
130 ///
131 /// Test 2: activate an appointment we *don't* know about
132 ///
133
134 // setup
135 m_mock_actions->clear();
136 EXPECT_TRUE(m_mock_actions->history().empty());
137
138 // activate the action
139 v = g_variant_new_string("this-uid-is-not-one-that-we-have");
140 g_action_group_activate_action(action_group, action_name, v);
141
142 // test the results
143 EXPECT_TRUE(m_mock_actions->history().empty());
144 }
145};
146
147/***
148****
149***/
27150
28TEST_F(ActionsFixture, ActionsExist)151TEST_F(ActionsFixture, ActionsExist)
29{152{
@@ -32,92 +155,80 @@
32 const char* names[] = { "desktop-header",155 const char* names[] = { "desktop-header",
33 "calendar",156 "calendar",
34 "set-location",157 "set-location",
35 "activate-planner",158 "desktop.open-appointment",
36 "activate-appointment",159 "desktop.open-alarm-app",
37 "activate-phone-settings",160 "desktop.open-calendar-app",
38 "activate-phone-clock-app",161 "desktop.open-settings-app",
39 "activate-desktop-settings" };162 "phone.open-appointment",
163 "phone.open-alarm-app",
164 "phone.open-calendar-app",
165 "phone.open-settings-app" };
166
40 for(const auto& name: names)167 for(const auto& name: names)
41 {168 {
42 EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), name));169 EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), name));
43 }170 }
44}171}
45172
46TEST_F(ActionsFixture, ActivateDesktopSettings)173/***
47{174****
48 const auto action_name = "activate-desktop-settings";175***/
49 const auto expected_action = MockActions::OpenDesktopSettings;176
50177TEST_F(ActionsFixture, DesktopOpenAlarmApp)
51 auto action_group = m_actions->action_group();178{
52 auto history = m_mock_actions->history();179 test_action_with_no_args("desktop.open-alarm-app",
53 EXPECT_EQ(0, history.size());180 MockActions::DesktopOpenAlarmApp);
54 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));181}
55182
56 g_action_group_activate_action(action_group, action_name, nullptr);183TEST_F(ActionsFixture, DesktopOpenAppointment)
57 history = m_mock_actions->history();184{
58 EXPECT_EQ(1, history.size());185 test_action_with_appt_arg("desktop.open-appointment",
59 EXPECT_EQ(expected_action, history[0]);186 MockActions::DesktopOpenAppt);
60}187}
61188
62TEST_F(ActionsFixture, ActivatePhoneSettings)189TEST_F(ActionsFixture, DesktopOpenCalendarApp)
63{190{
64 const auto action_name = "activate-phone-settings";191 test_action_with_time_arg("desktop.open-calendar-app",
65 const auto expected_action = MockActions::OpenPhoneSettings;192 MockActions::DesktopOpenCalendarApp);
66193}
67 auto action_group = m_actions->action_group();194
68 EXPECT_TRUE(m_mock_actions->history().empty());195TEST_F(ActionsFixture, DesktopOpenSettingsApp)
69 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));196{
70197 test_action_with_no_args("desktop.open-settings-app",
71 g_action_group_activate_action(action_group, action_name, nullptr);198 MockActions::DesktopOpenSettingsApp);
72 auto history = m_mock_actions->history();199}
73 EXPECT_EQ(1, history.size());200
74 EXPECT_EQ(expected_action, history[0]);201/***
75}202****
76203***/
77TEST_F(ActionsFixture, ActivatePhoneClockApp)204
78{205TEST_F(ActionsFixture, PhoneOpenAlarmApp)
79 const auto action_name = "activate-phone-clock-app";206{
80 const auto expected_action = MockActions::OpenPhoneClockApp;207 test_action_with_no_args("phone.open-alarm-app",
81208 MockActions::PhoneOpenAlarmApp);
82 auto action_group = m_actions->action_group();209}
83 EXPECT_TRUE(m_mock_actions->history().empty());210
84 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));211TEST_F(ActionsFixture, PhoneOpenAppointment)
85212{
86 g_action_group_activate_action(action_group, action_name, nullptr);213 test_action_with_appt_arg("phone.open-appointment",
87 auto history = m_mock_actions->history();214 MockActions::PhoneOpenAppt);
88 EXPECT_EQ(1, history.size());215}
89 EXPECT_EQ(expected_action, history[0]);216
90}217TEST_F(ActionsFixture, PhoneOpenCalendarApp)
91218{
92TEST_F(ActionsFixture, ActivatePlanner)219 test_action_with_time_arg("phone.open-calendar-app",
93{220 MockActions::PhoneOpenCalendarApp);
94 const auto action_name = "activate-planner";221}
95 auto action_group = m_actions->action_group();222
96 EXPECT_TRUE(m_mock_actions->history().empty());223TEST_F(ActionsFixture, PhoneOpenSettingsApp)
97 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));224{
98225 test_action_with_no_args("phone.open-settings-app",
99 const auto expected_action = MockActions::OpenPlanner;226 MockActions::PhoneOpenSettingsApp);
100 auto v = g_variant_new_int64(0);227}
101 g_action_group_activate_action(action_group, action_name, v);228
102 auto history = m_mock_actions->history();229/***
103 EXPECT_EQ(1, history.size());230****
104 EXPECT_EQ(expected_action, history[0]);231***/
105}
106
107TEST_F(ActionsFixture, ActivatePlannerAt)
108{
109 const auto action_name = "activate-planner";
110 auto action_group = m_actions->action_group();
111 EXPECT_TRUE(m_mock_actions->history().empty());
112 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));
113
114 const auto now = DateTime::NowLocal();
115 auto v = g_variant_new_int64(now.to_unix());
116 g_action_group_activate_action(action_group, action_name, v);
117 const auto a = MockActions::OpenPlannerAt;
118 EXPECT_EQ(std::vector<MockActions::Action>({a}), m_mock_actions->history());
119 EXPECT_EQ(now.to_unix(), m_mock_actions->date_time().to_unix());
120}
121232
122TEST_F(ActionsFixture, SetLocation)233TEST_F(ActionsFixture, SetLocation)
123{234{
@@ -209,26 +320,3 @@
209 g_clear_pointer(&calendar_state, g_variant_unref);320 g_clear_pointer(&calendar_state, g_variant_unref);
210321
211}322}
212
213
214TEST_F(ActionsFixture, OpenAppointment)
215{
216 Appointment appt;
217 appt.uid = "some arbitrary uid";
218 appt.url = "http://www.canonical.com/";
219 appt.begin = m_state->clock->localtime();
220 m_state->calendar_upcoming->appointments().set(std::vector<Appointment>({appt}));
221
222 const auto action_name = "activate-appointment";
223 auto action_group = m_actions->action_group();
224 EXPECT_TRUE(m_mock_actions->history().empty());
225 EXPECT_TRUE(g_action_group_has_action(action_group, action_name));
226
227 auto v = g_variant_new_string(appt.uid.c_str());
228 g_action_group_activate_action(action_group, action_name, v);
229 const auto a = MockActions::OpenAppointment;
230 ASSERT_EQ(1, m_mock_actions->history().size());
231 ASSERT_EQ(a, m_mock_actions->history()[0]);
232 EXPECT_EQ(appt.url, m_mock_actions->url());
233}
234
235323
=== modified file 'tests/test-exporter.cpp'
--- tests/test-exporter.cpp 2014-01-27 07:26:52 +0000
+++ tests/test-exporter.cpp 2014-03-22 07:33:30 +0000
@@ -104,11 +104,14 @@
104 names.insert(names_strv[i]);104 names.insert(names_strv[i]);
105105
106 // confirm the actions that we expect106 // confirm the actions that we expect
107 EXPECT_EQ(1, names.count("activate-appointment"));107 EXPECT_EQ(1, names.count("desktop.open-alarm-app"));
108 EXPECT_EQ(1, names.count("activate-desktop-settings"));108 EXPECT_EQ(1, names.count("desktop.open-appointment"));
109 EXPECT_EQ(1, names.count("activate-phone-clock-app"));109 EXPECT_EQ(1, names.count("desktop.open-calendar-app"));
110 EXPECT_EQ(1, names.count("activate-phone-settings"));110 EXPECT_EQ(1, names.count("desktop.open-settings-app"));
111 EXPECT_EQ(1, names.count("activate-planner"));111 EXPECT_EQ(1, names.count("phone.open-alarm-app"));
112 EXPECT_EQ(1, names.count("phone.open-appointment"));
113 EXPECT_EQ(1, names.count("phone.open-calendar-app"));
114 EXPECT_EQ(1, names.count("phone.open-settings-app"));
112 EXPECT_EQ(1, names.count("calendar"));115 EXPECT_EQ(1, names.count("calendar"));
113 EXPECT_EQ(1, names.count("desktop_greeter-header"));116 EXPECT_EQ(1, names.count("desktop_greeter-header"));
114 EXPECT_EQ(1, names.count("desktop-header"));117 EXPECT_EQ(1, names.count("desktop-header"));
115118
=== modified file 'tests/test-live-actions.cpp'
--- tests/test-live-actions.cpp 2014-03-13 14:22:16 +0000
+++ tests/test-live-actions.cpp 2014-03-22 07:33:30 +0000
@@ -252,43 +252,94 @@
252 EXPECT_EQ(expected, m_state->settings->timezone_name.get());252 EXPECT_EQ(expected, m_state->settings->timezone_name.get());
253}253}
254254
255TEST_F(LiveActionsFixture, OpenDesktopSettings)255/***
256{256****
257 m_actions->open_desktop_settings();257***/
258
259TEST_F(LiveActionsFixture, DesktopOpenAlarmApp)
260{
261 m_actions->desktop_open_alarm_app();
262 const std::string expected = "evolution -c calendar";
263 EXPECT_EQ(expected, m_live_actions->last_cmd);
264}
265
266TEST_F(LiveActionsFixture, DesktopOpenAppointment)
267{
268 Appointment a;
269 a.uid = "some-uid";
270 a.begin = DateTime::NowLocal();
271 m_actions->desktop_open_appointment(a);
272 const std::string expected_substr = "evolution \"calendar:///?startdate=";
273 EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos);
274}
275
276TEST_F(LiveActionsFixture, DesktopOpenCalendarApp)
277{
278 m_actions->desktop_open_calendar_app(DateTime::NowLocal());
279 const std::string expected_substr = "evolution \"calendar:///?startdate=";
280 EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos);
281}
282
283TEST_F(LiveActionsFixture, DesktopOpenSettingsApp)
284{
285 m_actions->desktop_open_settings_app();
258 const std::string expected_substr = "control-center";286 const std::string expected_substr = "control-center";
259 EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos);287 EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos);
260}288}
261289
262TEST_F(LiveActionsFixture, OpenPlanner)290/***
263{291****
264 m_actions->open_planner();292***/
265 const std::string expected = "evolution -c calendar";293
266 EXPECT_EQ(expected, m_live_actions->last_cmd);294namespace
267}295{
268296 const std::string clock_app_url = "appid://com.ubuntu.clock/clock/current-user-version";
269TEST_F(LiveActionsFixture, OpenPhoneSettings)297
270{298 const std::string calendar_app_url = "appid://com.ubuntu.calendar/calendar/current-user-version";
271 m_actions->open_phone_settings();299}
300
301TEST_F(LiveActionsFixture, PhoneOpenAlarmApp)
302{
303 m_actions->phone_open_alarm_app();
304 EXPECT_EQ(clock_app_url, m_live_actions->last_url);
305}
306
307TEST_F(LiveActionsFixture, PhoneOpenAppointment)
308{
309 Appointment a;
310
311 a.uid = "some-uid";
312 a.begin = DateTime::NowLocal();
313 a.has_alarms = false;
314 m_actions->phone_open_appointment(a);
315 EXPECT_EQ(calendar_app_url, m_live_actions->last_url);
316
317 a.has_alarms = true;
318 m_actions->phone_open_appointment(a);
319 EXPECT_EQ(clock_app_url, m_live_actions->last_url);
320
321 a.url = "appid://blah";
322 m_actions->phone_open_appointment(a);
323 EXPECT_EQ(a.url, m_live_actions->last_url);
324}
325
326TEST_F(LiveActionsFixture, PhoneOpenCalendarApp)
327{
328 m_actions->phone_open_calendar_app(DateTime::NowLocal());
329 const std::string expected = "appid://com.ubuntu.calendar/calendar/current-user-version";
330 EXPECT_EQ(expected, m_live_actions->last_url);
331}
332
333TEST_F(LiveActionsFixture, PhoneOpenSettingsApp)
334{
335 m_actions->phone_open_settings_app();
272 const std::string expected = "settings:///system/time-date";336 const std::string expected = "settings:///system/time-date";
273 EXPECT_EQ(expected, m_live_actions->last_url);337 EXPECT_EQ(expected, m_live_actions->last_url);
274}338}
275339
276TEST_F(LiveActionsFixture, OpenPhoneClockApp)340/***
277{341****
278 m_actions->open_phone_clock_app();342***/
279 const std::string expected = "appid://com.ubuntu.clock/clock/current-user-version";
280 EXPECT_EQ(expected, m_live_actions->last_url);
281}
282
283TEST_F(LiveActionsFixture, OpenPlannerAt)
284{
285 const auto now = DateTime::NowLocal();
286 m_actions->open_planner_at(now);
287 const auto today_begins = now.add_full(0, 0, 0, -now.hour(), -now.minute(), -now.seconds());
288 const auto gmt = today_begins.to_timezone("UTC");
289 const auto expected = gmt.format("evolution \"calendar:///?startdate=%Y%m%dT%H%M%SZ\"");
290 EXPECT_EQ(expected, m_live_actions->last_cmd);
291}
292343
293TEST_F(LiveActionsFixture, CalendarState)344TEST_F(LiveActionsFixture, CalendarState)
294{345{
295346
=== modified file 'tests/test-menus.cpp'
--- tests/test-menus.cpp 2014-03-10 03:32:19 +0000
+++ tests/test-menus.cpp 2014-03-22 07:33:30 +0000
@@ -92,7 +92,16 @@
92 void InspectCalendar(GMenuModel* menu_model, Menu::Profile profile)92 void InspectCalendar(GMenuModel* menu_model, Menu::Profile profile)
93 {93 {
94 gchar* str = nullptr;94 gchar* str = nullptr;
95 const auto actions_expected = (profile == Menu::Desktop) || (profile == Menu::Phone);95
96 const char * expected_action;
97
98 if (profile == Menu::Desktop)
99 expected_action = "indicator.desktop.open-calendar-app";
100 else if (profile == Menu::Phone)
101 expected_action = "indicator.phone.open-calendar-app";
102 else
103 expected_action = nullptr;
104
96 const auto calendar_expected = ((profile == Menu::Desktop) || (profile == Menu::DesktopGreeter))105 const auto calendar_expected = ((profile == Menu::Desktop) || (profile == Menu::DesktopGreeter))
97 && (m_state->settings->show_calendar.get());106 && (m_state->settings->show_calendar.get());
98107
@@ -113,8 +122,8 @@
113 g_clear_pointer(&str, g_free);122 g_clear_pointer(&str, g_free);
114123
115 g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str);124 g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str);
116 if (actions_expected)125 if (expected_action != nullptr)
117 EXPECT_STREQ("indicator.activate-planner", str);126 EXPECT_STREQ(expected_action, str);
118 else127 else
119 EXPECT_TRUE(str == nullptr);128 EXPECT_TRUE(str == nullptr);
120 g_clear_pointer(&str, g_free);129 g_clear_pointer(&str, g_free);
@@ -131,8 +140,8 @@
131 g_clear_pointer(&str, g_free);140 g_clear_pointer(&str, g_free);
132141
133 g_menu_model_get_item_attribute(section, 1, "activation-action", "s", &str);142 g_menu_model_get_item_attribute(section, 1, "activation-action", "s", &str);
134 if (actions_expected)143 if (expected_action != nullptr)
135 EXPECT_STREQ("indicator.activate-planner", str);144 EXPECT_STREQ(expected_action, str);
136 else145 else
137 EXPECT_TRUE(str == nullptr);146 EXPECT_TRUE(str == nullptr);
138 g_clear_pointer(&str, g_free);147 g_clear_pointer(&str, g_free);
@@ -297,7 +306,7 @@
297 // there should be an "add event" button even if there aren't any appointments306 // there should be an "add event" button even if there aren't any appointments
298 gchar* action = nullptr;307 gchar* action = nullptr;
299 EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));308 EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
300 const char* expected_action = "activate-planner";309 const char* expected_action = "desktop.open-calendar-app";
301 EXPECT_EQ(std::string("indicator.")+expected_action, action);310 EXPECT_EQ(std::string("indicator.")+expected_action, action);
302 EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action));311 EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action));
303 g_free(action);312 g_free(action);
@@ -328,7 +337,7 @@
328337
329 // check that there's a "clock app" menuitem even when there are no appointments338 // check that there's a "clock app" menuitem even when there are no appointments
330 auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);339 auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
331 const char* expected_action = "activate-phone-clock-app";340 const char* expected_action = "phone.open-alarm-app";
332 EXPECT_EQ(1, g_menu_model_get_n_items(section));341 EXPECT_EQ(1, g_menu_model_get_n_items(section));
333 gchar* action = nullptr;342 gchar* action = nullptr;
334 EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));343 EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
@@ -354,7 +363,7 @@
354363
355 void InspectAppointments(GMenuModel* menu_model, Menu::Profile profile)364 void InspectAppointments(GMenuModel* menu_model, Menu::Profile profile)
356 {365 {
357 const auto can_open_planner = m_actions->can_open_planner();366 const auto can_open_planner = m_actions->desktop_has_calendar_app();
358367
359 switch (profile)368 switch (profile)
360 {369 {
@@ -443,9 +452,9 @@
443 std::string expected_action;452 std::string expected_action;
444453
445 if (profile == Menu::Desktop)454 if (profile == Menu::Desktop)
446 expected_action = "indicator.activate-desktop-settings";455 expected_action = "indicator.desktop.open-settings-app";
447 else if (profile == Menu::Phone)456 else if (profile == Menu::Phone)
448 expected_action = "indicator.activate-phone-settings";457 expected_action = "indicator.phone.open-settings-app";
449458
450 // get the Settings section459 // get the Settings section
451 auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);460 auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
@@ -520,7 +529,7 @@
520 // toggle can_open_planner() and test the desktop again529 // toggle can_open_planner() and test the desktop again
521 // to confirm that the "Add Event…" menuitem appears iff530 // to confirm that the "Add Event…" menuitem appears iff
522 // there's a calendar available user-agent531 // there's a calendar available user-agent
523 m_mock_actions->set_can_open_planner (!m_actions->can_open_planner());532 m_mock_actions->set_desktop_has_calendar_app (!m_actions->desktop_has_calendar_app());
524 std::shared_ptr<Menu> menu = m_menu_factory->buildMenu(Menu::Desktop);533 std::shared_ptr<Menu> menu = m_menu_factory->buildMenu(Menu::Desktop);
525 InspectAppointments(menu->menu_model(), menu->profile());534 InspectAppointments(menu->menu_model(), menu->profile());
526}535}

Subscribers

People subscribed via source and target branches