aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2015-03-09 14:20:27 -0500
committerTed Gould <ted@gould.cx>2015-03-09 14:20:27 -0500
commit3bd0c14d33d444f02f3a35961fafa11d866b1b0d (patch)
treef17bef07f493fd056b80c8683a371eafd31e9290 /tests
parent9c16722dc9a6799d600a86fea48f3a3c71da895f (diff)
downloadayatana-indicator-messages-3bd0c14d33d444f02f3a35961fafa11d866b1b0d.tar.gz
ayatana-indicator-messages-3bd0c14d33d444f02f3a35961fafa11d866b1b0d.tar.bz2
ayatana-indicator-messages-3bd0c14d33d444f02f3a35961fafa11d866b1b0d.zip
Added a test for message replying
Diffstat (limited to 'tests')
-rw-r--r--tests/indicator-test.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/indicator-test.cpp b/tests/indicator-test.cpp
index 2a711f0..d8c79df 100644
--- a/tests/indicator-test.cpp
+++ b/tests/indicator-test.cpp
@@ -90,7 +90,57 @@ TEST_F(IndicatorTest, SingleMessage) {
setMenu("/com/canonical/indicator/messages/phone");
EXPECT_EVENTUALLY_MENU_ATTRIB(std::vector<int>({0, 0, 0}), "x-canonical-type", "com.canonical.indicator.messages.messageitem");
+ EXPECT_MENU_ATTRIB(std::vector<int>({0, 0, 0}), "label", "Test Title");
EXPECT_MENU_ATTRIB(std::vector<int>({0, 0, 0}), "x-canonical-message-id", "testid");
EXPECT_MENU_ATTRIB(std::vector<int>({0, 0, 0}), "x-canonical-subtitle", "A subtitle too");
EXPECT_MENU_ATTRIB(std::vector<int>({0, 0, 0}), "x-canonical-text", "You only like me for my body");
}
+
+static void
+messageReplyActivate (GObject * obj, gchar * name, GVariant * value, gpointer user_data) {
+ std::string * res = reinterpret_cast<std::string *>(user_data);
+ *res = g_variant_get_string(value, nullptr);
+}
+
+TEST_F(IndicatorTest, MessageReply) {
+ 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");
+
+ auto msg = std::shared_ptr<MessagingMenuMessage>(messaging_menu_message_new(
+ "messageid",
+ nullptr, /* no icon */
+ "Reply Message",
+ "A message to reply to",
+ "In-app replies are for wimps, reply here to save yourself time and be cool.",
+ 0), [](MessagingMenuMessage * msg) { g_clear_object(&msg); });
+ messaging_menu_message_add_action(msg.get(),
+ "replyid",
+ "Reply",
+ G_VARIANT_TYPE_STRING,
+ nullptr);
+ messaging_menu_app_append_message(app.get(), msg.get(), nullptr, FALSE);
+
+ EXPECT_EVENTUALLY_ACTION_EXISTS("test.msg.messageid");
+ EXPECT_EVENTUALLY_ACTION_EXISTS("test.msg-actions.messageid.replyid");
+ EXPECT_ACTION_ACTIVATION_TYPE("test.msg-actions.messageid.replyid", G_VARIANT_TYPE_STRING);
+
+ EXPECT_ACTION_ENABLED("remove-all", true);
+
+ setMenu("/com/canonical/indicator/messages/phone");
+
+ EXPECT_EVENTUALLY_MENU_ATTRIB(std::vector<int>({0, 0, 0}), "x-canonical-type", "com.canonical.indicator.messages.messageitem");
+
+ std::string activateResponse;
+ g_signal_connect(msg.get(), "activate", G_CALLBACK(messageReplyActivate), &activateResponse);
+
+ activateAction("test.msg-actions.messageid.replyid", g_variant_new_string("Reply to me"));
+
+ EXPECT_EVENTUALLY_EQ("Reply to me", activateResponse);
+
+ EXPECT_EVENTUALLY_ACTION_ENABLED("remove-all", false);
+}