~indicator-applet-developers/indicator-messages/trunk.15.04

« back to all changes in this revision

Viewing changes to tests/indicator-test.cpp

  • Committer: Ted Gould
  • Date: 2015-03-07 03:46:30 UTC
  • mto: This revision was merged to the branch mainline in revision 441.
  • Revision ID: ted@gould.cx-20150307034630-zjkqp8tc241jqwmw
A test that puts a message in the menu

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "indicator-fixture.h"
24
24
#include "accounts-service-mock.h"
25
25
 
 
26
#include "messaging-menu-app.h"
 
27
#include "messaging-menu-message.h"
 
28
 
26
29
class IndicatorTest : public IndicatorFixture
27
30
{
28
31
protected:
38
41
                g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE);
39
42
                g_setenv("GSETTINGS_BACKEND", "memory", TRUE);
40
43
 
 
44
                g_setenv("XDG_DATA_DIRS", XDG_DATA_DIRS, TRUE);
 
45
 
41
46
                as = std::make_shared<AccountsServiceMock>();
42
47
                addMock(*as);
43
48
 
60
65
        EXPECT_EVENTUALLY_ACTION_EXISTS("messages");
61
66
        EXPECT_ACTION_STATE_TYPE("messages", G_VARIANT_TYPE("a{sv}"));
62
67
        EXPECT_ACTION_STATE("messages", g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-offline', 'indicator-messages', 'indicator']>)>, 'title': <'Notifications'>, 'accessible-desc': <'Messages'>, 'visible': <false>}"));
63
 
 
64
 
}
65
 
 
 
68
}
 
69
 
 
70
TEST_F(IndicatorTest, SingleMessage) {
 
71
        setActions("/com/canonical/indicator/messages");
 
72
 
 
73
        auto app = std::shared_ptr<MessagingMenuApp>(messaging_menu_app_new("test.desktop"), [](MessagingMenuApp * app) { g_clear_object(&app); });
 
74
        ASSERT_NE(nullptr, app);
 
75
        messaging_menu_app_register(app.get());
 
76
 
 
77
        auto msg = std::shared_ptr<MessagingMenuMessage>(messaging_menu_message_new(
 
78
                "test-id",
 
79
                nullptr, /* no icon */
 
80
                "Test Title",
 
81
                "A subtitle too",
 
82
                "You only like me for my body",
 
83
                0), [](MessagingMenuMessage * msg) { g_clear_object(&msg); });
 
84
        messaging_menu_app_append_message(app.get(), msg.get(), nullptr, FALSE);
 
85
 
 
86
        EXPECT_EVENTUALLY_ACTION_EXISTS("test.launch");
 
87
 
 
88
}