~charlesk/indicator-datetime/lp-1424966-fix-ecanceled-errno-rtm-14.09

« back to all changes in this revision

Viewing changes to tests/test-menus.cpp

  • Committer: Charles Kerr
  • Date: 2014-03-22 07:25:50 UTC
  • mto: This revision was merged to the branch mainline in revision 332.
  • Revision ID: charles.kerr@canonical.com-20140322072550-5qwg2pkpigb4b0qv
make the phone and desktop actions more consistent with each other; eg, 'indicator.desktop.open-calendar-app' + 'indicator.phone.open-calendar-app'

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
    void InspectCalendar(GMenuModel* menu_model, Menu::Profile profile)
93
93
    {
94
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
105
        const auto calendar_expected = ((profile == Menu::Desktop) || (profile == Menu::DesktopGreeter))
97
106
                                    && (m_state->settings->show_calendar.get());
98
107
 
113
122
        g_clear_pointer(&str, g_free);
114
123
 
115
124
        g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str);
116
 
        if (actions_expected)
117
 
            EXPECT_STREQ("indicator.activate-planner", str);
 
125
        if (expected_action != nullptr)
 
126
            EXPECT_STREQ(expected_action, str);
118
127
        else
119
128
            EXPECT_TRUE(str == nullptr);
120
129
        g_clear_pointer(&str, g_free);
131
140
            g_clear_pointer(&str, g_free);
132
141
 
133
142
            g_menu_model_get_item_attribute(section, 1, "activation-action", "s", &str);
134
 
            if (actions_expected)
135
 
                EXPECT_STREQ("indicator.activate-planner", str);
 
143
            if (expected_action != nullptr)
 
144
                EXPECT_STREQ(expected_action, str);
136
145
            else
137
146
                EXPECT_TRUE(str == nullptr);
138
147
            g_clear_pointer(&str, g_free);
297
306
            // there should be an "add event" button even if there aren't any appointments
298
307
            gchar* action = nullptr;
299
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
310
            EXPECT_EQ(std::string("indicator.")+expected_action, action);
302
311
            EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action));
303
312
            g_free(action);
328
337
 
329
338
        // check that there's a "clock app" menuitem even when there are no appointments
330
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
341
        EXPECT_EQ(1, g_menu_model_get_n_items(section));
333
342
        gchar* action = nullptr;
334
343
        EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
354
363
 
355
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();
358
367
 
359
368
        switch (profile)
360
369
        {
443
452
        std::string expected_action;
444
453
 
445
454
        if (profile == Menu::Desktop)
446
 
            expected_action = "indicator.activate-desktop-settings";
 
455
            expected_action = "indicator.desktop.open-settings-app";
447
456
        else if (profile == Menu::Phone)
448
 
            expected_action = "indicator.activate-phone-settings";
 
457
            expected_action = "indicator.phone.open-settings-app";
449
458
 
450
459
        // get the Settings section
451
460
        auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
520
529
    // toggle can_open_planner() and test the desktop again
521
530
    // to confirm that the "Add Event…" menuitem appears iff
522
531
    // 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
533
    std::shared_ptr<Menu> menu = m_menu_factory->buildMenu(Menu::Desktop);
525
534
    InspectAppointments(menu->menu_model(), menu->profile());
526
535
}