diff options
author | Ted Gould <ted@gould.cx> | 2015-03-09 17:07:03 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2015-03-09 17:07:03 -0500 |
commit | 54ae3da705f9babeec8f2bf5c220d533eef425cc (patch) | |
tree | 11ec7b8cca85d99c3ca68b88f510d124e5f9fbbc | |
parent | 56801d13e16f29542f620c1e0e7f249d52705b09 (diff) | |
download | ayatana-indicator-messages-54ae3da705f9babeec8f2bf5c220d533eef425cc.tar.gz ayatana-indicator-messages-54ae3da705f9babeec8f2bf5c220d533eef425cc.tar.bz2 ayatana-indicator-messages-54ae3da705f9babeec8f2bf5c220d533eef425cc.zip |
Test the messaging menu changing color on and off
-rw-r--r-- | tests/applications/test2.desktop | 5 | ||||
-rw-r--r-- | tests/indicator-test.cpp | 63 |
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/applications/test2.desktop b/tests/applications/test2.desktop new file mode 100644 index 0000000..63ccb6b --- /dev/null +++ b/tests/applications/test2.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=Application +Name=Test +Exec=test +Icon=test-app diff --git a/tests/indicator-test.cpp b/tests/indicator-test.cpp index d8c79df..8f87191 100644 --- a/tests/indicator-test.cpp +++ b/tests/indicator-test.cpp @@ -144,3 +144,66 @@ TEST_F(IndicatorTest, MessageReply) { EXPECT_EVENTUALLY_ACTION_ENABLED("remove-all", false); } + +TEST_F(IndicatorTest, IconNotification) { + auto normalicon = std::shared_ptr<GVariant>(g_variant_ref_sink(g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-offline', 'indicator-messages', 'indicator']>)>, 'title': <'Notifications'>, 'accessible-desc': <'Messages'>, 'visible': <true>}")), [](GVariant *var) {if (var != nullptr) g_variant_unref(var); }); + auto blueicon = std::shared_ptr<GVariant>(g_variant_ref_sink(g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-new-offline', 'indicator-messages-new', 'indicator-messages', 'indicator']>)>, 'title': <'Notifications'>, 'accessible-desc': <'New Messages'>, 'visible': <true>}")), [](GVariant *var) {if (var != nullptr) g_variant_unref(var); }); + + setActions("/com/canonical/indicator/messages"); + + auto app = std::shared_ptr<MessagingMenuApp>(messaging_menu_app_new("test.desktop"), [](MessagingMenuApp * app) { g_clear_object(&app); }); + ASSERT_NE(nullptr, app); + messaging_menu_app_register(app.get()); + + EXPECT_EVENTUALLY_ACTION_EXISTS("test.launch"); + + EXPECT_ACTION_STATE("messages", normalicon); + + auto app2 = std::shared_ptr<MessagingMenuApp>(messaging_menu_app_new("test2.desktop"), [](MessagingMenuApp * app) { g_clear_object(&app); }); + ASSERT_NE(nullptr, app2); + messaging_menu_app_register(app2.get()); + + EXPECT_EVENTUALLY_ACTION_EXISTS("test2.launch"); + + messaging_menu_app_append_source_with_count(app2.get(), + "countsource", + nullptr, + "Count Source", + 500); + messaging_menu_app_draw_attention(app2.get(), "countsource"); + + EXPECT_EVENTUALLY_ACTION_STATE("messages", blueicon); + + auto msg = std::shared_ptr<MessagingMenuMessage>(messaging_menu_message_new( + "messageid", + nullptr, /* no icon */ + "Message", + "A secret message", + "asdfa;lkweraoweprijas;dvlknasvdoiewur;aslkd", + 0), [](MessagingMenuMessage * msg) { g_clear_object(&msg); }); + messaging_menu_message_set_draws_attention(msg.get(), true); + messaging_menu_app_append_message(app.get(), msg.get(), nullptr, FALSE); + + EXPECT_EVENTUALLY_ACTION_EXISTS("test.msg.messageid"); + EXPECT_ACTION_STATE("messages", blueicon); + + messaging_menu_app_unregister(app2.get()); + app2.reset(); + + EXPECT_EVENTUALLY_ACTION_DOES_NOT_EXIST("test2.msg.countsource"); + EXPECT_ACTION_STATE("messages", blueicon); + + messaging_menu_app_remove_message(app.get(), msg.get()); + + EXPECT_EVENTUALLY_ACTION_STATE("messages", normalicon); + EXPECT_ACTION_ENABLED("remove-all", false); + + messaging_menu_app_append_message(app.get(), msg.get(), nullptr, FALSE); + + EXPECT_EVENTUALLY_ACTION_STATE("messages", blueicon); + EXPECT_ACTION_ENABLED("remove-all", true); + + activateAction("remove-all"); + + EXPECT_EVENTUALLY_ACTION_STATE("messages", normalicon); +} |