From 474099ef1d4010fa918da698707b644cbc3fe5da Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 6 Mar 2015 21:46:30 -0600 Subject: A test that puts a message in the menu --- tests/Makefile.am | 3 +++ tests/applications/test.desktop | 3 +++ tests/indicator-test.cpp | 25 ++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index ee0b9d7..6dabf89 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -47,6 +47,8 @@ indicator_test_SOURCES = \ indicator_test_CPPFLAGS = \ -DINDICATOR_MESSAGES_SERVICE_BINARY="\"$(abs_top_builddir)/src/indicator-messages-service\"" \ -DSCHEMA_DIR="\"$(abs_builddir)/gsettings-schemas-compiled/\"" \ + -DXDG_DATA_DIRS="\"$(abs_srcdir)/\"" \ + -I$(top_srcdir)/libmessaging-menu \ -std=c++11 \ $(APPLET_CFLAGS) \ $(DBUSTEST_CFLAGS) \ @@ -55,6 +57,7 @@ indicator_test_CPPFLAGS = \ indicator_test_LDADD = \ $(APPLET_LIBS) \ $(DBUSTEST_LIBS) \ + $(top_builddir)/libmessaging-menu/libmessaging-menu.la \ libgtest.la \ -lc -lpthread diff --git a/tests/applications/test.desktop b/tests/applications/test.desktop index c2332b9..63ccb6b 100644 --- a/tests/applications/test.desktop +++ b/tests/applications/test.desktop @@ -1,2 +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 3a5ef6d..afb55d0 100644 --- a/tests/indicator-test.cpp +++ b/tests/indicator-test.cpp @@ -23,6 +23,9 @@ #include "indicator-fixture.h" #include "accounts-service-mock.h" +#include "messaging-menu-app.h" +#include "messaging-menu-message.h" + class IndicatorTest : public IndicatorFixture { protected: @@ -38,6 +41,8 @@ protected: g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE); g_setenv("GSETTINGS_BACKEND", "memory", TRUE); + g_setenv("XDG_DATA_DIRS", XDG_DATA_DIRS, TRUE); + as = std::make_shared(); addMock(*as); @@ -60,6 +65,24 @@ TEST_F(IndicatorTest, RootAction) { EXPECT_EVENTUALLY_ACTION_EXISTS("messages"); EXPECT_ACTION_STATE_TYPE("messages", G_VARIANT_TYPE("a{sv}")); EXPECT_ACTION_STATE("messages", g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-offline', 'indicator-messages', 'indicator']>)>, 'title': <'Notifications'>, 'accessible-desc': <'Messages'>, 'visible': }")); - } +TEST_F(IndicatorTest, SingleMessage) { + setActions("/com/canonical/indicator/messages"); + + auto app = std::shared_ptr(messaging_menu_app_new("test.desktop"), [](MessagingMenuApp * app) { g_clear_object(&app); }); + ASSERT_NE(nullptr, app); + messaging_menu_app_register(app.get()); + + auto msg = std::shared_ptr(messaging_menu_message_new( + "test-id", + nullptr, /* no icon */ + "Test Title", + "A subtitle too", + "You only like me for my body", + 0), [](MessagingMenuMessage * msg) { g_clear_object(&msg); }); + messaging_menu_app_append_message(app.get(), msg.get(), nullptr, FALSE); + + EXPECT_EVENTUALLY_ACTION_EXISTS("test.launch"); + +} -- cgit v1.2.3