aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2015-03-06 21:46:30 -0600
committerTed Gould <ted@gould.cx>2015-03-06 21:46:30 -0600
commit474099ef1d4010fa918da698707b644cbc3fe5da (patch)
tree264ae602ee1390949470bbbfac13e39a92d6ca00 /tests
parentdf3f745d94c5bd0c5c0c2eaf85ed63a438981e3d (diff)
downloadayatana-indicator-messages-474099ef1d4010fa918da698707b644cbc3fe5da.tar.gz
ayatana-indicator-messages-474099ef1d4010fa918da698707b644cbc3fe5da.tar.bz2
ayatana-indicator-messages-474099ef1d4010fa918da698707b644cbc3fe5da.zip
A test that puts a message in the menu
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/applications/test.desktop3
-rw-r--r--tests/indicator-test.cpp25
3 files changed, 30 insertions, 1 deletions
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<AccountsServiceMock>();
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': <false>}"));
-
}
+TEST_F(IndicatorTest, SingleMessage) {
+ 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());
+
+ auto msg = std::shared_ptr<MessagingMenuMessage>(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");
+
+}