From 583033cb8dbf95d224bc9cc4bf4d4d097b7950f3 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 18 May 2012 23:26:54 +0200 Subject: Remove default applications This gets rid of the "Set Up " sections for Email, Chat, and Broadcast. Also, default apps don't get to override the icon and names anymore. Every app gets its real name and icon displayed. Overriding the icon with X-Ayatana-Messaging-Menu-Icon is still possible. --- test/Makefile.am | 3 --- 1 file changed, 3 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 1d28dc4..09bd861 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -39,8 +39,6 @@ lib_LTLIBRARIES = \ libindicator-messages-service.la libindicator_messages_service_la_HEADERS = \ - $(top_srcdir)/src/default-applications.h \ - $(top_srcdir)/src/messages-service-dbus.h \ $(top_srcdir)/src/gen-messages-service.xml.h \ $(top_srcdir)/src/im-menu-item.h \ $(top_srcdir)/src/app-menu-item.h \ @@ -51,7 +49,6 @@ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/status-items.h libindicator_messages_service_la_SOURCES = \ - $(top_srcdir)/src/default-applications.c \ $(top_srcdir)/src/messages-service.c \ $(top_srcdir)/src/messages-service-dbus.c \ $(top_srcdir)/src/gen-messages-service.xml.c \ -- cgit v1.2.3 From ab416588f88aa199193f234220f102788c0493c0 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 18 May 2012 23:41:22 +0200 Subject: Remove the seen db It was only really used to figure out whether one of the default apps was ever running, so that "Set up..." or the app name and actions would be shown in the menu. Since there are no default apps anymore, this is not needed either. --- test/Makefile.am | 2 -- 1 file changed, 2 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 09bd861..466de1e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -43,7 +43,6 @@ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/im-menu-item.h \ $(top_srcdir)/src/app-menu-item.h \ $(top_srcdir)/src/launcher-menu-item.h \ - $(top_srcdir)/src/seen-db.h \ $(top_srcdir)/src/dirs.h \ $(top_srcdir)/src/dbus-data.h \ $(top_srcdir)/src/status-items.h @@ -55,7 +54,6 @@ libindicator_messages_service_la_SOURCES = \ $(top_srcdir)/src/im-menu-item.c \ $(top_srcdir)/src/app-menu-item.c \ $(top_srcdir)/src/launcher-menu-item.c \ - $(top_srcdir)/src/seen-db.c \ $(top_srcdir)/src/status-items.c libindicator_messages_service_ladir = \ -- cgit v1.2.3 From 14716e2d8d8bf7ccd8ba3ee2e9607a718bf2ff66 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 21 May 2012 16:45:58 +0200 Subject: Use a gsettings list for finding out which apps should appear in the menu Previously, this was handled by looking for .desktop files in various system and user directories. The messaging menu should not display any applications by default anymore, so a simple per-user gsettings list suffices. A neat side effect is that the hairy blacklist handling is not needed anymore, either. Small regression: apps are not configurable at runtime anymore (settings key is not listened to for changes). --- test/Makefile.am | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 466de1e..9206036 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -43,7 +43,6 @@ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/im-menu-item.h \ $(top_srcdir)/src/app-menu-item.h \ $(top_srcdir)/src/launcher-menu-item.h \ - $(top_srcdir)/src/dirs.h \ $(top_srcdir)/src/dbus-data.h \ $(top_srcdir)/src/status-items.h -- cgit v1.2.3 From 8960bbafb9805c1e787e70bb2289cb8bc95a5f30 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 23 May 2012 21:30:00 +0200 Subject: Merge launcher- and appmenuitems --- test/Makefile.am | 2 -- 1 file changed, 2 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 9206036..bb58ab2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -42,7 +42,6 @@ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/gen-messages-service.xml.h \ $(top_srcdir)/src/im-menu-item.h \ $(top_srcdir)/src/app-menu-item.h \ - $(top_srcdir)/src/launcher-menu-item.h \ $(top_srcdir)/src/dbus-data.h \ $(top_srcdir)/src/status-items.h @@ -52,7 +51,6 @@ libindicator_messages_service_la_SOURCES = \ $(top_srcdir)/src/gen-messages-service.xml.c \ $(top_srcdir)/src/im-menu-item.c \ $(top_srcdir)/src/app-menu-item.c \ - $(top_srcdir)/src/launcher-menu-item.c \ $(top_srcdir)/src/status-items.c libindicator_messages_service_ladir = \ -- cgit v1.2.3 From e1c600ba95e4520caf471ebf2eb9f41e2580fa98 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 24 May 2012 22:28:40 +0200 Subject: Port to gmenu, act I Work-in-progress of the gmenu port for the service. The bulk of this patch removes everything related to libindicate from the service. Only the static app launchers and their configured shortcut actions are exported for now. --- test/Makefile.am | 2 -- 1 file changed, 2 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index bb58ab2..847d857 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -40,7 +40,6 @@ lib_LTLIBRARIES = \ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/gen-messages-service.xml.h \ - $(top_srcdir)/src/im-menu-item.h \ $(top_srcdir)/src/app-menu-item.h \ $(top_srcdir)/src/dbus-data.h \ $(top_srcdir)/src/status-items.h @@ -49,7 +48,6 @@ libindicator_messages_service_la_SOURCES = \ $(top_srcdir)/src/messages-service.c \ $(top_srcdir)/src/messages-service-dbus.c \ $(top_srcdir)/src/gen-messages-service.xml.c \ - $(top_srcdir)/src/im-menu-item.c \ $(top_srcdir)/src/app-menu-item.c \ $(top_srcdir)/src/status-items.c -- cgit v1.2.3 From 4f2dd60a130dcaeb4378219baca1f3d4e9637824 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 31 May 2012 18:55:06 +0200 Subject: Rename AppMenuItem to AppSection --- test/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 847d857..2b0f67e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -40,7 +40,7 @@ lib_LTLIBRARIES = \ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/gen-messages-service.xml.h \ - $(top_srcdir)/src/app-menu-item.h \ + $(top_srcdir)/src/app-section.h \ $(top_srcdir)/src/dbus-data.h \ $(top_srcdir)/src/status-items.h @@ -48,7 +48,7 @@ libindicator_messages_service_la_SOURCES = \ $(top_srcdir)/src/messages-service.c \ $(top_srcdir)/src/messages-service-dbus.c \ $(top_srcdir)/src/gen-messages-service.xml.c \ - $(top_srcdir)/src/app-menu-item.c \ + $(top_srcdir)/src/app-section.c \ $(top_srcdir)/src/status-items.c libindicator_messages_service_ladir = \ -- cgit v1.2.3 From 6872c840672049695904d61c1a3baba22c6d9627 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Sun, 3 Jun 2012 08:33:31 +0200 Subject: Add GActionMuxer This is a new implementation of an action muxer with the same interface as the one in the gtk tree. Its implementation is considerably simpler, mostly because it doesn't need to implement GActionObservable. In addition to muxing different action groups with the . scheme, it has the notion of global, prefix-less actions. Indicator-messages needs those for the status and clear actions. --- test/Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 2b0f67e..977c1ed 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -42,14 +42,16 @@ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/gen-messages-service.xml.h \ $(top_srcdir)/src/app-section.h \ $(top_srcdir)/src/dbus-data.h \ - $(top_srcdir)/src/status-items.h + $(top_srcdir)/src/status-items.h \ + $(top_srcdir)/src/gactionmuxer.h libindicator_messages_service_la_SOURCES = \ $(top_srcdir)/src/messages-service.c \ $(top_srcdir)/src/messages-service-dbus.c \ $(top_srcdir)/src/gen-messages-service.xml.c \ $(top_srcdir)/src/app-section.c \ - $(top_srcdir)/src/status-items.c + $(top_srcdir)/src/status-items.c \ + $(top_srcdir)/src/gactionmuxer.c libindicator_messages_service_ladir = \ $(includedir)/libindicator-messages-service/ -- cgit v1.2.3 From 3eb45ac840a66511537cdf2bd2c9f7c68c6e1761 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 12:23:51 +0200 Subject: Include different header in test case to fix `make check` --- test/test-gtest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-gtest.cpp b/test/test-gtest.cpp index 1cc97be..fd9fec1 100644 --- a/test/test-gtest.cpp +++ b/test/test-gtest.cpp @@ -3,10 +3,10 @@ #include extern "C" { - #include "launcher-menu-item.h" + #include "app-section.h" } -TEST(LauncherMenuItem, NameInitialized) { +TEST(AppSection, NameInitialized) { g_type_init(); EXPECT_TRUE(true); } -- cgit v1.2.3 From 7d4fcf06c92e71fa0abb1927ac21705ab88478c0 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 18:13:24 +0200 Subject: Add a first gactionmuxer test --- test/Makefile.am | 13 +++++++- test/test-gactionmuxer.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 test/test-gactionmuxer.cpp (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 977c1ed..f1ab408 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ check_LIBRARIES = libgtest.a -check_PROGRAMS = test-gtest +check_PROGRAMS = test-gtest test-gactionmuxer TESTS = @@ -31,6 +31,17 @@ test_gtest_LDADD = \ libgtest.a +TESTS += test-gactionmuxer + +test_gactionmuxer_SOURCES = \ + test-gactionmuxer.cpp \ + $(top_srcdir)/src/gactionmuxer.c \ + $(top_srcdir)/src/gactionmuxer.h + +test_gactionmuxer_CPPFLAGS = $(APPLET_CFLAGS) $(AM_CPPFLAGS) +test_gactionmuxer_LDADD = $(APPLET_LIBS) libgtest.a + + ###################################### # Lib containing code under test ###################################### diff --git a/test/test-gactionmuxer.cpp b/test/test-gactionmuxer.cpp new file mode 100644 index 0000000..fb32452 --- /dev/null +++ b/test/test-gactionmuxer.cpp @@ -0,0 +1,76 @@ + +#include +#include +#include + +extern "C" { +#include "app-section.h" +#include "gactionmuxer.h" +} + +static gboolean +strv_contains (gchar **str_array, + const gchar *str) +{ + gchar **it; + + for (it = str_array; *it; it++) { + if (!g_strcmp0 (*it, str)) + return TRUE; + } + + return FALSE; +} + +TEST(GActionMuxerTest, General) { + const GActionEntry entries1[] = { { "one" }, { "two" }, { "three" } }; + const GActionEntry entries2[] = { { "gb" }, { "es" }, { "fr" } }; + const GActionEntry entries3[] = { { "foo" }, { "bar" } }; + GSimpleActionGroup *group1; + GSimpleActionGroup *group2; + GSimpleActionGroup *group3; + GActionMuxer *muxer; + gchar **actions; + + g_type_init (); + + group1 = g_simple_action_group_new (); + g_simple_action_group_add_entries (group1, + entries1, + G_N_ELEMENTS (entries1), + NULL); + + group2 = g_simple_action_group_new (); + g_simple_action_group_add_entries (group2, + entries2, + G_N_ELEMENTS (entries2), + NULL); + + group3 = g_simple_action_group_new (); + g_simple_action_group_add_entries (group3, + entries3, + G_N_ELEMENTS (entries3), + NULL); + + muxer = g_action_muxer_new (); + g_action_muxer_insert (muxer, "first", G_ACTION_GROUP (group1)); + g_action_muxer_insert (muxer, "second", G_ACTION_GROUP (group2)); + g_action_muxer_insert (muxer, NULL, G_ACTION_GROUP (group3)); + + actions = g_action_group_list_actions (G_ACTION_GROUP (muxer)); + EXPECT_EQ (8, g_strv_length (actions)); + EXPECT_TRUE (strv_contains (actions, "first.one")); + EXPECT_TRUE (strv_contains (actions, "first.two")); + EXPECT_TRUE (strv_contains (actions, "first.three")); + EXPECT_TRUE (strv_contains (actions, "second.gb")); + EXPECT_TRUE (strv_contains (actions, "second.es")); + EXPECT_TRUE (strv_contains (actions, "second.fr")); + EXPECT_TRUE (strv_contains (actions, "foo")); + EXPECT_TRUE (strv_contains (actions, "bar")); + g_strfreev (actions); + + g_object_unref (muxer); + g_object_unref (group1); + g_object_unref (group2); + g_object_unref (group3); +} -- cgit v1.2.3 From 6ee454ecc225d186195206465254133473bfd749 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 18:15:46 +0200 Subject: Remove dummy test case --- test/Makefile.am | 16 +--------------- test/test-gtest.cpp | 12 ------------ 2 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 test/test-gtest.cpp (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index f1ab408..6ceb1d4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ check_LIBRARIES = libgtest.a -check_PROGRAMS = test-gtest test-gactionmuxer +check_PROGRAMS = test-gactionmuxer TESTS = @@ -17,20 +17,6 @@ libgtest_a_CXXFLAGS = \ libgtest_a_CPPFLAGS = \ $(AM_CPPFLAGS) -TESTS += test-gtest - -test_gtest_SOURCES = \ - test-gtest.cpp -test_gtest_CPPFLAGS = \ - $(APPLET_CFLAGS) \ - $(AM_CPPFLAGS) -test_gtest_LDFLAGS = -pthread -test_gtest_LDADD = \ - $(APPLET_LIBS) \ - $(top_builddir)/src/.libs/libindicator-messages-status-provider.la \ - libgtest.a - - TESTS += test-gactionmuxer test_gactionmuxer_SOURCES = \ diff --git a/test/test-gtest.cpp b/test/test-gtest.cpp deleted file mode 100644 index fd9fec1..0000000 --- a/test/test-gtest.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -#include -#include - -extern "C" { - #include "app-section.h" -} - -TEST(AppSection, NameInitialized) { - g_type_init(); - EXPECT_TRUE(true); -} -- cgit v1.2.3 From 2fee65e88f9a5de775df5fe99fe8a9a160bbbdf8 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 18:21:11 +0200 Subject: test: remove warnings in Makefile.am (duplicate vars) --- test/Makefile.am | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 6ceb1d4..a790ba2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,7 @@ check_LIBRARIES = libgtest.a check_PROGRAMS = test-gactionmuxer -TESTS = +TESTS = $(check_PROGRAMS) AM_CPPFLAGS = $(GTEST_CPPFLAGS) \ -I${top_srcdir}/src @@ -11,13 +11,11 @@ nodist_libgtest_a_SOURCES = \ $(GTEST_SOURCE)/src/gtest-all.cc \ $(GTEST_SOURCE)/src/gtest_main.cc libgtest_a_CPPFLAGS = \ - $(GTEST_CPPFLAGS) -w + $(GTEST_CPPFLAGS) -w \ + $(AM_CPPFLAGS) libgtest_a_CXXFLAGS = \ $(AM_CXXFLAGS) -libgtest_a_CPPFLAGS = \ - $(AM_CPPFLAGS) -TESTS += test-gactionmuxer test_gactionmuxer_SOURCES = \ test-gactionmuxer.cpp \ -- cgit v1.2.3 From 2c7ad39202242c83265dcd94e384b8ad12979d83 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 18:56:44 +0200 Subject: gactionmuxer: don't crash when no global actions are given --- test/test-gactionmuxer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/test-gactionmuxer.cpp b/test/test-gactionmuxer.cpp index fb32452..9f0ac3b 100644 --- a/test/test-gactionmuxer.cpp +++ b/test/test-gactionmuxer.cpp @@ -22,6 +22,21 @@ strv_contains (gchar **str_array, return FALSE; } +TEST(GActionMuxerTest, Empty) { + GActionMuxer *muxer; + gchar **actions; + + g_type_init (); + + muxer = g_action_muxer_new (); + + actions = g_action_group_list_actions (G_ACTION_GROUP (muxer)); + EXPECT_EQ (0, g_strv_length (actions)); + + g_strfreev (actions); + g_object_unref (muxer); +} + TEST(GActionMuxerTest, General) { const GActionEntry entries1[] = { { "one" }, { "two" }, { "three" } }; const GActionEntry entries2[] = { { "gb" }, { "es" }, { "fr" } }; -- cgit v1.2.3 From a2efe98ce72aedae472637154a3e45f5ddd25675 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 20:03:15 +0200 Subject: Test gactionmuxer more extensively --- test/test-gactionmuxer.cpp | 167 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-gactionmuxer.cpp b/test/test-gactionmuxer.cpp index 9f0ac3b..aa877fb 100644 --- a/test/test-gactionmuxer.cpp +++ b/test/test-gactionmuxer.cpp @@ -37,7 +37,7 @@ TEST(GActionMuxerTest, Empty) { g_object_unref (muxer); } -TEST(GActionMuxerTest, General) { +TEST(GActionMuxerTest, AddAndRemove) { const GActionEntry entries1[] = { { "one" }, { "two" }, { "three" } }; const GActionEntry entries2[] = { { "gb" }, { "es" }, { "fr" } }; const GActionEntry entries3[] = { { "foo" }, { "bar" } }; @@ -73,6 +73,8 @@ TEST(GActionMuxerTest, General) { g_action_muxer_insert (muxer, NULL, G_ACTION_GROUP (group3)); actions = g_action_group_list_actions (G_ACTION_GROUP (muxer)); + EXPECT_TRUE (g_action_group_has_action (G_ACTION_GROUP (muxer), "first.one")); + EXPECT_FALSE (g_action_group_has_action (G_ACTION_GROUP (muxer), "one")); EXPECT_EQ (8, g_strv_length (actions)); EXPECT_TRUE (strv_contains (actions, "first.one")); EXPECT_TRUE (strv_contains (actions, "first.two")); @@ -84,8 +86,171 @@ TEST(GActionMuxerTest, General) { EXPECT_TRUE (strv_contains (actions, "bar")); g_strfreev (actions); + g_action_muxer_remove (muxer, NULL); + EXPECT_FALSE (g_action_group_has_action (G_ACTION_GROUP (muxer), "foo")); + EXPECT_TRUE (g_action_group_has_action (G_ACTION_GROUP (muxer), "first.one")); + actions = g_action_group_list_actions (G_ACTION_GROUP (muxer)); + EXPECT_EQ (6, g_strv_length (actions)); + EXPECT_FALSE (strv_contains (actions, "foo")); + EXPECT_TRUE (strv_contains (actions, "first.one")); + g_strfreev (actions); + + g_action_muxer_remove (muxer, "first"); + EXPECT_FALSE (g_action_group_has_action (G_ACTION_GROUP (muxer), "first.two")); + EXPECT_TRUE (g_action_group_has_action (G_ACTION_GROUP (muxer), "second.es")); + actions = g_action_group_list_actions (G_ACTION_GROUP (muxer)); + EXPECT_EQ (3, g_strv_length (actions)); + EXPECT_FALSE (strv_contains (actions, "first.two")); + EXPECT_TRUE (strv_contains (actions, "second.es")); + g_strfreev (actions); + g_object_unref (muxer); g_object_unref (group1); g_object_unref (group2); g_object_unref (group3); } + +static gboolean +g_variant_equal0 (gconstpointer one, + gconstpointer two) +{ + if (one == NULL) + return two == NULL; + else + return g_variant_equal (one, two); +} + +TEST(GActionMuxerTest, ActionAttributes) { + GSimpleActionGroup *group; + GSimpleAction *action; + GActionMuxer *muxer; + gboolean enabled[2]; + const GVariantType *param_type[2]; + const GVariantType *state_type[2]; + GVariant *state_hint[2]; + GVariant *state[2]; + + g_type_init (); + + group = g_simple_action_group_new (); + action = g_simple_action_new ("one", G_VARIANT_TYPE_STRING); + g_simple_action_group_insert (group, G_ACTION (action)); + + muxer = g_action_muxer_new (); + g_action_muxer_insert (muxer, "first", G_ACTION_GROUP (group)); + + /* test two of the convenience functions */ + ASSERT_TRUE (g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), "first.one")); + g_simple_action_set_enabled (action, FALSE); + ASSERT_FALSE (g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), "first.one")); + + ASSERT_STREQ ((gchar *) g_action_group_get_action_parameter_type (G_ACTION_GROUP (muxer), "first.one"), + (gchar *) G_VARIANT_TYPE_STRING); + + /* query_action */ + g_action_group_query_action (G_ACTION_GROUP (group), "one", + &enabled[0], ¶m_type[0], &state_type[0], &state_hint[0], &state[0]); + g_action_group_query_action (G_ACTION_GROUP (muxer), "first.one", + &enabled[1], ¶m_type[1], &state_type[1], &state_hint[1], &state[1]); + ASSERT_EQ (enabled[0], enabled[1]); + ASSERT_STREQ ((gchar *) param_type[0], (gchar *) param_type[1]); + ASSERT_STREQ ((gchar *) state_type[0], (gchar *) state_type[1]); + ASSERT_TRUE (g_variant_equal0 ((gconstpointer) state_hint[0], (gconstpointer) state_hint[1])); + ASSERT_TRUE (g_variant_equal0 ((gconstpointer) state[0], (gconstpointer) state[1])); + + g_object_unref (action); + g_object_unref (group); + g_object_unref (muxer); +} + +typedef struct { + gboolean signal_ran; + const gchar *name; +} TestSignalClosure; + +static void +action_added (GActionGroup *group, + gchar *action_name, + gpointer user_data) +{ + TestSignalClosure *c = (TestSignalClosure *)user_data; + EXPECT_STREQ (c->name, action_name); + c->signal_ran = TRUE; +} + +static void +action_enabled_changed (GActionGroup *group, + gchar *action_name, + gboolean enabled, + gpointer user_data) +{ + TestSignalClosure *c = (TestSignalClosure *)user_data; + EXPECT_EQ (enabled, FALSE); + c->signal_ran = TRUE; +} + +static void +action_removed (GActionGroup *group, + gchar *action_name, + gpointer user_data) +{ + TestSignalClosure *c = (TestSignalClosure *)user_data; + EXPECT_STREQ (c->name, action_name); + c->signal_ran = TRUE; +} + +TEST(GActionMuxerTest, Signals) { + GSimpleActionGroup *group; + GSimpleAction *action; + GActionMuxer *muxer; + TestSignalClosure closure; + + group = g_simple_action_group_new (); + + action = g_simple_action_new ("one", G_VARIANT_TYPE_STRING); + g_simple_action_group_insert (group, G_ACTION (action)); + g_object_unref (action); + + muxer = g_action_muxer_new (); + + g_signal_connect (muxer, "action-added", + G_CALLBACK (action_added), (gpointer) &closure); + g_signal_connect (muxer, "action-enabled-changed", + G_CALLBACK (action_enabled_changed), (gpointer) &closure); + g_signal_connect (muxer, "action-removed", + G_CALLBACK (action_removed), (gpointer) &closure); + + /* add the group with "one" action and check whether the signal is emitted */ + closure.signal_ran = FALSE; + closure.name = "first.one"; + g_action_muxer_insert (muxer, "first", G_ACTION_GROUP (group)); + ASSERT_TRUE (closure.signal_ran); + + /* add a second action after the group was added to the muxer */ + closure.signal_ran = FALSE; + closure.name = "first.two"; + action = g_simple_action_new ("two", G_VARIANT_TYPE_STRING); + g_simple_action_group_insert (group, G_ACTION (action)); + ASSERT_TRUE (closure.signal_ran); + + /* disable the action */ + closure.signal_ran = FALSE; + g_simple_action_set_enabled (action, FALSE); + ASSERT_TRUE (closure.signal_ran); + g_object_unref (action); + + /* remove the first action */ + closure.signal_ran = FALSE; + closure.name = "first.one"; + g_simple_action_group_remove (group, "one"); + ASSERT_TRUE (closure.signal_ran); + + /* remove the whole group, should be notified about "first.two" */ + closure.signal_ran = FALSE; + closure.name = "first.two"; + g_action_muxer_remove (muxer, "first"); + ASSERT_TRUE (closure.signal_ran); + + g_object_unref (group); + g_object_unref (muxer); +} -- cgit v1.2.3 From 26d7cfc736224403c4cb9f6f0a91aaa78020f80c Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 22:18:31 +0200 Subject: Link test against a static lib to clean up lcov reporting If specifying the sources in src/ directly for each test, lcov generates reports for tests itself. That's fairly useless, as the ASSERT_* branches in the tests should (hopefully) never be taken. --- test/Makefile.am | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index a790ba2..26dd867 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -18,12 +18,16 @@ libgtest_a_CXXFLAGS = \ test_gactionmuxer_SOURCES = \ - test-gactionmuxer.cpp \ - $(top_srcdir)/src/gactionmuxer.c \ - $(top_srcdir)/src/gactionmuxer.h + test-gactionmuxer.cpp -test_gactionmuxer_CPPFLAGS = $(APPLET_CFLAGS) $(AM_CPPFLAGS) -test_gactionmuxer_LDADD = $(APPLET_LIBS) libgtest.a +test_gactionmuxer_CPPFLAGS = \ + $(APPLET_CFLAGS) \ + $(AM_CPPFLAGS) + +test_gactionmuxer_LDADD = \ + $(APPLET_LIBS) \ + libindicator-messages-service.la \ + libgtest.a ###################################### @@ -41,7 +45,6 @@ libindicator_messages_service_la_HEADERS = \ $(top_srcdir)/src/gactionmuxer.h libindicator_messages_service_la_SOURCES = \ - $(top_srcdir)/src/messages-service.c \ $(top_srcdir)/src/messages-service-dbus.c \ $(top_srcdir)/src/gen-messages-service.xml.c \ $(top_srcdir)/src/app-section.c \ -- cgit v1.2.3 From 0eda2f38aeb7abdb4c342305fef15388ec3fa248 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 23:44:13 +0200 Subject: gactionmuxer: more tests --- test/test-gactionmuxer.cpp | 111 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-gactionmuxer.cpp b/test/test-gactionmuxer.cpp index aa877fb..64c0d20 100644 --- a/test/test-gactionmuxer.cpp +++ b/test/test-gactionmuxer.cpp @@ -22,6 +22,26 @@ strv_contains (gchar **str_array, return FALSE; } +TEST(GActionMuxerTest, Sanity) { + GActionMuxer *muxer; + + g_type_init (); + + g_action_muxer_insert (NULL, NULL, NULL); + g_action_muxer_remove (NULL, NULL); + + muxer = g_action_muxer_new (); + + g_action_muxer_insert (muxer, NULL, NULL); + g_action_muxer_remove (muxer, NULL); + EXPECT_FALSE (g_action_group_has_action (G_ACTION_GROUP (muxer), NULL)); + EXPECT_FALSE (g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), NULL)); + EXPECT_FALSE (g_action_group_query_action (G_ACTION_GROUP (muxer), NULL, NULL, NULL, NULL, NULL, NULL)); + g_action_group_activate_action (G_ACTION_GROUP (muxer), NULL, NULL); + + g_object_unref (muxer); +} + TEST(GActionMuxerTest, Empty) { GActionMuxer *muxer; gchar **actions; @@ -104,6 +124,16 @@ TEST(GActionMuxerTest, AddAndRemove) { EXPECT_TRUE (strv_contains (actions, "second.es")); g_strfreev (actions); + g_action_muxer_insert (muxer, "second", G_ACTION_GROUP (group2)); + actions = g_action_group_list_actions (G_ACTION_GROUP (muxer)); + EXPECT_EQ (3, g_strv_length (actions)); + g_strfreev (actions); + + g_action_muxer_insert (muxer, NULL, G_ACTION_GROUP (group3)); + actions = g_action_group_list_actions (G_ACTION_GROUP (muxer)); + EXPECT_EQ (5, g_strv_length (actions)); + g_strfreev (actions); + g_object_unref (muxer); g_object_unref (group1); g_object_unref (group2); @@ -189,6 +219,17 @@ action_enabled_changed (GActionGroup *group, c->signal_ran = TRUE; } +static void +action_state_changed (GActionGroup *group, + gchar *action_name, + GVariant *value, + gpointer user_data) +{ + TestSignalClosure *c = (TestSignalClosure *)user_data; + EXPECT_STREQ (g_variant_get_string (value, NULL), "off"); + c->signal_ran = TRUE; +} + static void action_removed (GActionGroup *group, gchar *action_name, @@ -217,6 +258,8 @@ TEST(GActionMuxerTest, Signals) { G_CALLBACK (action_added), (gpointer) &closure); g_signal_connect (muxer, "action-enabled-changed", G_CALLBACK (action_enabled_changed), (gpointer) &closure); + g_signal_connect (muxer, "action-state-changed", + G_CALLBACK (action_state_changed), (gpointer) &closure); g_signal_connect (muxer, "action-removed", G_CALLBACK (action_removed), (gpointer) &closure); @@ -229,7 +272,8 @@ TEST(GActionMuxerTest, Signals) { /* add a second action after the group was added to the muxer */ closure.signal_ran = FALSE; closure.name = "first.two"; - action = g_simple_action_new ("two", G_VARIANT_TYPE_STRING); + action = g_simple_action_new_stateful ("two", G_VARIANT_TYPE_STRING, + g_variant_new_string ("on")); g_simple_action_group_insert (group, G_ACTION (action)); ASSERT_TRUE (closure.signal_ran); @@ -237,6 +281,11 @@ TEST(GActionMuxerTest, Signals) { closure.signal_ran = FALSE; g_simple_action_set_enabled (action, FALSE); ASSERT_TRUE (closure.signal_ran); + + /* change its state */ + closure.signal_ran = FALSE; + g_simple_action_set_state (action, g_variant_new_string ("off")); + ASSERT_TRUE (closure.signal_ran); g_object_unref (action); /* remove the first action */ @@ -254,3 +303,63 @@ TEST(GActionMuxerTest, Signals) { g_object_unref (group); g_object_unref (muxer); } + +static void +action_activated (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + gboolean *signal_ran = (gboolean *)user_data; + + ASSERT_STREQ (g_variant_get_string (parameter, NULL), "value"); + *signal_ran = TRUE; +} + +static void +action_change_state (GSimpleAction *simple, + GVariant *value, + gpointer user_data) +{ + gboolean *signal_ran = (gboolean *)user_data; + + ASSERT_STREQ (g_variant_get_string (value, NULL), "off"); + *signal_ran = TRUE; +} + +TEST(GActionMuxerTest, ActivateAction) { + GSimpleActionGroup *group; + GSimpleAction *action; + GActionMuxer *muxer; + gboolean signal_ran; + + group = g_simple_action_group_new (); + + action = g_simple_action_new ("one", G_VARIANT_TYPE_STRING); + g_simple_action_group_insert (group, G_ACTION (action)); + g_signal_connect (action, "activate", + G_CALLBACK (action_activated), (gpointer) &signal_ran); + g_object_unref (action); + + action = g_simple_action_new_stateful ("two", NULL, + g_variant_new_string ("on")); + g_simple_action_group_insert (group, G_ACTION (action)); + g_signal_connect (action, "change-state", + G_CALLBACK (action_change_state), (gpointer) &signal_ran); + g_object_unref (action); + + muxer = g_action_muxer_new (); + g_action_muxer_insert (muxer, "first", G_ACTION_GROUP (group)); + + signal_ran = FALSE; + g_action_group_activate_action (G_ACTION_GROUP (muxer), "first.one", + g_variant_new_string ("value")); + ASSERT_TRUE (signal_ran); + + signal_ran = FALSE; + g_action_group_change_action_state (G_ACTION_GROUP (muxer), "first.two", + g_variant_new_string ("off")); + ASSERT_TRUE (signal_ran); + + g_object_unref (group); + g_object_unref (muxer); +} -- cgit v1.2.3 From 368b17f9ab5cbe934d796ddd19f4510bbf01cab8 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 4 Jun 2012 23:47:13 +0200 Subject: testing: use EXPECT_* instead of ASSERT_* --- test/test-gactionmuxer.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'test') diff --git a/test/test-gactionmuxer.cpp b/test/test-gactionmuxer.cpp index 64c0d20..6304853 100644 --- a/test/test-gactionmuxer.cpp +++ b/test/test-gactionmuxer.cpp @@ -170,11 +170,11 @@ TEST(GActionMuxerTest, ActionAttributes) { g_action_muxer_insert (muxer, "first", G_ACTION_GROUP (group)); /* test two of the convenience functions */ - ASSERT_TRUE (g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), "first.one")); + EXPECT_TRUE (g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), "first.one")); g_simple_action_set_enabled (action, FALSE); - ASSERT_FALSE (g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), "first.one")); + EXPECT_FALSE (g_action_group_get_action_enabled (G_ACTION_GROUP (muxer), "first.one")); - ASSERT_STREQ ((gchar *) g_action_group_get_action_parameter_type (G_ACTION_GROUP (muxer), "first.one"), + EXPECT_STREQ ((gchar *) g_action_group_get_action_parameter_type (G_ACTION_GROUP (muxer), "first.one"), (gchar *) G_VARIANT_TYPE_STRING); /* query_action */ @@ -182,11 +182,11 @@ TEST(GActionMuxerTest, ActionAttributes) { &enabled[0], ¶m_type[0], &state_type[0], &state_hint[0], &state[0]); g_action_group_query_action (G_ACTION_GROUP (muxer), "first.one", &enabled[1], ¶m_type[1], &state_type[1], &state_hint[1], &state[1]); - ASSERT_EQ (enabled[0], enabled[1]); - ASSERT_STREQ ((gchar *) param_type[0], (gchar *) param_type[1]); - ASSERT_STREQ ((gchar *) state_type[0], (gchar *) state_type[1]); - ASSERT_TRUE (g_variant_equal0 ((gconstpointer) state_hint[0], (gconstpointer) state_hint[1])); - ASSERT_TRUE (g_variant_equal0 ((gconstpointer) state[0], (gconstpointer) state[1])); + EXPECT_EQ (enabled[0], enabled[1]); + EXPECT_STREQ ((gchar *) param_type[0], (gchar *) param_type[1]); + EXPECT_STREQ ((gchar *) state_type[0], (gchar *) state_type[1]); + EXPECT_TRUE (g_variant_equal0 ((gconstpointer) state_hint[0], (gconstpointer) state_hint[1])); + EXPECT_TRUE (g_variant_equal0 ((gconstpointer) state[0], (gconstpointer) state[1])); g_object_unref (action); g_object_unref (group); @@ -267,7 +267,7 @@ TEST(GActionMuxerTest, Signals) { closure.signal_ran = FALSE; closure.name = "first.one"; g_action_muxer_insert (muxer, "first", G_ACTION_GROUP (group)); - ASSERT_TRUE (closure.signal_ran); + EXPECT_TRUE (closure.signal_ran); /* add a second action after the group was added to the muxer */ closure.signal_ran = FALSE; @@ -275,30 +275,30 @@ TEST(GActionMuxerTest, Signals) { action = g_simple_action_new_stateful ("two", G_VARIANT_TYPE_STRING, g_variant_new_string ("on")); g_simple_action_group_insert (group, G_ACTION (action)); - ASSERT_TRUE (closure.signal_ran); + EXPECT_TRUE (closure.signal_ran); /* disable the action */ closure.signal_ran = FALSE; g_simple_action_set_enabled (action, FALSE); - ASSERT_TRUE (closure.signal_ran); + EXPECT_TRUE (closure.signal_ran); /* change its state */ closure.signal_ran = FALSE; g_simple_action_set_state (action, g_variant_new_string ("off")); - ASSERT_TRUE (closure.signal_ran); + EXPECT_TRUE (closure.signal_ran); g_object_unref (action); /* remove the first action */ closure.signal_ran = FALSE; closure.name = "first.one"; g_simple_action_group_remove (group, "one"); - ASSERT_TRUE (closure.signal_ran); + EXPECT_TRUE (closure.signal_ran); /* remove the whole group, should be notified about "first.two" */ closure.signal_ran = FALSE; closure.name = "first.two"; g_action_muxer_remove (muxer, "first"); - ASSERT_TRUE (closure.signal_ran); + EXPECT_TRUE (closure.signal_ran); g_object_unref (group); g_object_unref (muxer); @@ -311,7 +311,7 @@ action_activated (GSimpleAction *simple, { gboolean *signal_ran = (gboolean *)user_data; - ASSERT_STREQ (g_variant_get_string (parameter, NULL), "value"); + EXPECT_STREQ (g_variant_get_string (parameter, NULL), "value"); *signal_ran = TRUE; } @@ -322,7 +322,7 @@ action_change_state (GSimpleAction *simple, { gboolean *signal_ran = (gboolean *)user_data; - ASSERT_STREQ (g_variant_get_string (value, NULL), "off"); + EXPECT_STREQ (g_variant_get_string (value, NULL), "off"); *signal_ran = TRUE; } @@ -353,12 +353,12 @@ TEST(GActionMuxerTest, ActivateAction) { signal_ran = FALSE; g_action_group_activate_action (G_ACTION_GROUP (muxer), "first.one", g_variant_new_string ("value")); - ASSERT_TRUE (signal_ran); + EXPECT_TRUE (signal_ran); signal_ran = FALSE; g_action_group_change_action_state (G_ACTION_GROUP (muxer), "first.two", g_variant_new_string ("off")); - ASSERT_TRUE (signal_ran); + EXPECT_TRUE (signal_ran); g_object_unref (group); g_object_unref (muxer); -- cgit v1.2.3 From bc9cd727c2bb0116c94e1bf258e257d5bff406f8 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 13 Jun 2012 17:57:09 +0200 Subject: Don't install convenience library used for the tests --- test/Makefile.am | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index 26dd867..ca4965e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -34,22 +34,20 @@ test_gactionmuxer_LDADD = \ # Lib containing code under test ###################################### -lib_LTLIBRARIES = \ +noinst_LTLIBRARIES = \ libindicator-messages-service.la -libindicator_messages_service_la_HEADERS = \ - $(top_srcdir)/src/gen-messages-service.xml.h \ - $(top_srcdir)/src/app-section.h \ - $(top_srcdir)/src/dbus-data.h \ - $(top_srcdir)/src/status-items.h \ - $(top_srcdir)/src/gactionmuxer.h - libindicator_messages_service_la_SOURCES = \ $(top_srcdir)/src/messages-service-dbus.c \ $(top_srcdir)/src/gen-messages-service.xml.c \ + $(top_srcdir)/src/gen-messages-service.xml.h \ $(top_srcdir)/src/app-section.c \ + $(top_srcdir)/src/app-section.h \ $(top_srcdir)/src/status-items.c \ - $(top_srcdir)/src/gactionmuxer.c + $(top_srcdir)/src/status-items.h \ + $(top_srcdir)/src/gactionmuxer.c \ + $(top_srcdir)/src/gactionmuxer.h + $(top_srcdir)/src/dbus-data.h libindicator_messages_service_ladir = \ $(includedir)/libindicator-messages-service/ -- cgit v1.2.3 From 3da349e33e434c13a27f956374e97c75ef0480a0 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 25 Jun 2012 22:40:59 +0200 Subject: Remove status providers Applications will be able to set and retrieve status through libmessaging-menu and telepathy. --- test/Makefile.am | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index ca4965e..d0ea499 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -43,8 +43,6 @@ libindicator_messages_service_la_SOURCES = \ $(top_srcdir)/src/gen-messages-service.xml.h \ $(top_srcdir)/src/app-section.c \ $(top_srcdir)/src/app-section.h \ - $(top_srcdir)/src/status-items.c \ - $(top_srcdir)/src/status-items.h \ $(top_srcdir)/src/gactionmuxer.c \ $(top_srcdir)/src/gactionmuxer.h $(top_srcdir)/src/dbus-data.h @@ -60,12 +58,10 @@ libindicator_messages_service_la_CFLAGS = \ -Wl,-z,defs \ -Wl,--as-needed \ -Werror \ - -DG_LOG_DOMAIN=\"Indicator-Messages\" \ - -DSTATUS_PROVIDER_DIR=\"$(STATUS_PROVIDER_DIR)\" + -DG_LOG_DOMAIN=\"Indicator-Messages\" libindicator_messages_service_la_LIBADD = \ - $(APPLET_LIBS) \ - $(top_builddir)/src/.libs/libindicator-messages-status-provider.la + $(APPLET_LIBS) libindicator_messages_service_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) -- cgit v1.2.3 From 193886f467b636a91d546656017de3fd0fa62677 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 27 Jun 2012 21:42:23 +0200 Subject: Use gdbus-codegen also for the server side messages service --- test/Makefile.am | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index d0ea499..ebf2da2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -38,9 +38,8 @@ noinst_LTLIBRARIES = \ libindicator-messages-service.la libindicator_messages_service_la_SOURCES = \ - $(top_srcdir)/src/messages-service-dbus.c \ - $(top_srcdir)/src/gen-messages-service.xml.c \ - $(top_srcdir)/src/gen-messages-service.xml.h \ + $(top_srcdir)/src/indicator-messages-service.c \ + $(top_srcdir)/src/indicator-messages-service.h \ $(top_srcdir)/src/app-section.c \ $(top_srcdir)/src/app-section.h \ $(top_srcdir)/src/gactionmuxer.c \ -- cgit v1.2.3 From 5df53a2c98d806f3b266d0032986d4dab3beb7a3 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Tue, 21 Aug 2012 12:03:21 +0200 Subject: Fix out-of-tree builds (for make distcheck) --- test/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/Makefile.am b/test/Makefile.am index ebf2da2..4671446 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -38,8 +38,8 @@ noinst_LTLIBRARIES = \ libindicator-messages-service.la libindicator_messages_service_la_SOURCES = \ - $(top_srcdir)/src/indicator-messages-service.c \ - $(top_srcdir)/src/indicator-messages-service.h \ + $(top_builddir)/src/indicator-messages-service.c \ + $(top_builddir)/src/indicator-messages-service.h \ $(top_srcdir)/src/app-section.c \ $(top_srcdir)/src/app-section.h \ $(top_srcdir)/src/gactionmuxer.c \ @@ -52,6 +52,7 @@ libindicator_messages_service_ladir = \ libindicator_messages_service_la_CFLAGS = \ $(APPLET_CFLAGS) \ $(COVERAGE_CFLAGS) \ + -I$(top_builddir)/src \ -Wall \ -Wl,-Bsymbolic-functions \ -Wl,-z,defs \ -- cgit v1.2.3