From d28010e3f12c8d7e03fa6ef9233b3f1d3ebfaac2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 23:23:31 -0500 Subject: Tests directory. --- tests/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/Makefile.am (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..82ec364 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,3 @@ + +# Something here + -- cgit v1.2.3 From 5e928c9ce0cbeaa1a1050a7c0e8f10fb7027514c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 23:47:20 -0500 Subject: Now we're building a test, woot! --- tests/Makefile.am | 25 ++++++++++++++++++++++++- tests/test-libcustomindicator.c | 14 ++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/test-libcustomindicator.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 82ec364..4044617 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,3 +1,26 @@ -# Something here +check_PROGRAMS = \ + test-libcustomindicator + +test_libcustomindicator_SOURCES = \ + test-libcustomindicator.c + +test_libcustomindicator_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -I$(top_srcdir)/src + +test_libcustomindicator_LDADD = \ + $(INDICATOR_LIBS) \ + $(top_builddir)/src/libcustomindicator.la + +XML_REPORT = libcustomindicator-check-results.xml +HTML_REPORT = libcustomindicator-check-results.html + +libcustomindicator-tester: test-libcustomindicator + gtester -o=$(XML_REPORT) ./test-libcustomindicator + +check-local: libcustomindicator-tester + +DISTCLEANFILES = $(XML_REPORT) $(HTML_REPORT) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c new file mode 100644 index 0000000..fab411d --- /dev/null +++ b/tests/test-libcustomindicator.c @@ -0,0 +1,14 @@ + +#include +#include + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + + return g_test_run (); +} -- cgit v1.2.3 From 10e95506d81335d394b9cd955b7728b528c0fe4e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 09:23:21 -0500 Subject: Woot! We can build a custom indicator, and it exists. --- tests/test-libcustomindicator.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index fab411d..6dc9fe9 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -2,6 +2,25 @@ #include #include +#include + +void +test_libcustomindicator_init (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); + g_assert(ci != NULL); + g_object_unref(G_OBJECT(ci)); +} + +void +test_libcustomindicator_props_suite (void) +{ + g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); + + + return; +} + gint main (gint argc, gchar * argv[]) { @@ -9,6 +28,8 @@ main (gint argc, gchar * argv[]) g_test_init(&argc, &argv, NULL); /* Test suites */ + test_libcustomindicator_props_suite(); + return g_test_run (); } -- cgit v1.2.3 From 0093c378498e9d203012a143e49137f72d8168ce Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Wed, 21 Oct 2009 09:33:57 -0500 Subject: Ah, forgot a return. Cody would kill me! Oh, no. --- tests/test-libcustomindicator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index 6dc9fe9..c264bfa 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -10,6 +10,7 @@ test_libcustomindicator_init (void) CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); g_assert(ci != NULL); g_object_unref(G_OBJECT(ci)); + return; } void -- cgit v1.2.3 From 795f7d94377f9093e8b3b064e7e020c4f753293d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 11:14:09 -0500 Subject: Adding a test that sets a bunch of properties. --- tests/test-libcustomindicator.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index c264bfa..1736efa 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -4,6 +4,28 @@ #include +void +test_libcustomindicator_init_with_props (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, + "id", "my-id", + "category", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, + "status", CUSTOM_INDICATOR_STATUS_ON, + "icon-name", "my-name", + "attention-icon-name", "my-attention-name", + NULL)); + g_assert(ci != NULL); + + g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); + g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); + g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_object_unref(G_OBJECT(ci)); + return; +} + void test_libcustomindicator_init (void) { @@ -16,7 +38,8 @@ test_libcustomindicator_init (void) void test_libcustomindicator_props_suite (void) { - g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); + g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); + g_test_add_func ("/indicator-custom/libcustomindicator/init_props", test_libcustomindicator_init_with_props); return; -- cgit v1.2.3 From dc43af9a9e3aa1965bf3d9994f8733cdaf588912 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 11:40:23 -0500 Subject: Checking all the set functions. --- tests/test-libcustomindicator.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index 1736efa..ecc187b 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -4,6 +4,28 @@ #include +void +test_libcustomindicator_init_set_props (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); + g_assert(ci != NULL); + + custom_indicator_set_id(ci, "my-id"); + custom_indicator_set_category(ci, CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_icon(ci, "my-name"); + custom_indicator_set_attention_icon(ci, "my-attention-name"); + + g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); + g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); + g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_object_unref(G_OBJECT(ci)); + return; +} + void test_libcustomindicator_init_with_props (void) { @@ -40,6 +62,7 @@ test_libcustomindicator_props_suite (void) { g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); g_test_add_func ("/indicator-custom/libcustomindicator/init_props", test_libcustomindicator_init_with_props); + g_test_add_func ("/indicator-custom/libcustomindicator/init_set_props", test_libcustomindicator_init_set_props); return; -- cgit v1.2.3 From 5e1d1d9aee14f8771f89c98004299575a35e89b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 12:06:19 -0500 Subject: Adding test to test the property change signals. --- tests/test-libcustomindicator.c | 83 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index ecc187b..1bda8b4 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -4,6 +4,87 @@ #include +void +test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, CustomIndicatorStatus status, gboolean * signalactivated) +{ + *signalactivated = TRUE; + return; +} + +void +test_libcustomindicator_prop_signals_helper (CustomIndicator * ci, gboolean * signalactivated) +{ + *signalactivated = TRUE; + return; +} + +void +test_libcustomindicator_prop_signals (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); + g_assert(ci != NULL); + + gboolean signaled = FALSE; + gulong handlerid; + + handlerid = 0; + handlerid = g_signal_connect(G_OBJECT(ci), "new-icon", G_CALLBACK(test_libcustomindicator_prop_signals_helper), &signaled); + g_assert(handlerid != 0); + + handlerid = 0; + handlerid = g_signal_connect(G_OBJECT(ci), "new-attention-icon", G_CALLBACK(test_libcustomindicator_prop_signals_helper), &signaled); + g_assert(handlerid != 0); + + handlerid = 0; + handlerid = g_signal_connect(G_OBJECT(ci), "new-status", G_CALLBACK(test_libcustomindicator_prop_signals_status_helper), &signaled); + g_assert(handlerid != 0); + + + signaled = FALSE; + custom_indicator_set_icon(ci, "bob"); + g_assert(signaled); + + signaled = FALSE; + custom_indicator_set_icon(ci, "bob"); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_icon(ci, "al"); + g_assert(signaled); + + + signaled = FALSE; + custom_indicator_set_attention_icon(ci, "bob"); + g_assert(signaled); + + signaled = FALSE; + custom_indicator_set_attention_icon(ci, "bob"); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_attention_icon(ci, "al"); + g_assert(signaled); + + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_OFF); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + g_assert(signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ATTENTION); + g_assert(signaled); + + return; +} + void test_libcustomindicator_init_set_props (void) { @@ -63,7 +144,7 @@ test_libcustomindicator_props_suite (void) g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); g_test_add_func ("/indicator-custom/libcustomindicator/init_props", test_libcustomindicator_init_with_props); g_test_add_func ("/indicator-custom/libcustomindicator/init_set_props", test_libcustomindicator_init_set_props); - + g_test_add_func ("/indicator-custom/libcustomindicator/prop_signals", test_libcustomindicator_prop_signals); return; } -- cgit v1.2.3 From 5aeff27144282c008771e3f049b2f5ba0398a532 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 13:24:21 -0500 Subject: Getting the prototype right. --- tests/test-libcustomindicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index 1bda8b4..b4b4084 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -5,7 +5,7 @@ #include void -test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, CustomIndicatorStatus status, gboolean * signalactivated) +test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, gchar * status, gboolean * signalactivated) { *signalactivated = TRUE; return; -- cgit v1.2.3 From 5e34573c2cff345a2aa3c972ec4a0150f4c4183e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 14:03:18 -0500 Subject: Turning on verbose output and showing the status of all tests. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 4044617..865573b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,7 +18,7 @@ XML_REPORT = libcustomindicator-check-results.xml HTML_REPORT = libcustomindicator-check-results.html libcustomindicator-tester: test-libcustomindicator - gtester -o=$(XML_REPORT) ./test-libcustomindicator + gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator check-local: libcustomindicator-tester -- cgit v1.2.3 From 0df50d723494e795aa7447c02ac0f15611b2bfd8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 15:42:13 -0500 Subject: Change the enums to match the KDE ones to make life simpler even though I dislike the names. --- tests/test-libcustomindicator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index b4b4084..b3ead63 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -67,15 +67,15 @@ test_libcustomindicator_prop_signals (void) signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_OFF); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_PASSIVE); g_assert(!signaled); signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(signaled); signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(!signaled); signaled = FALSE; @@ -93,14 +93,14 @@ test_libcustomindicator_init_set_props (void) custom_indicator_set_id(ci, "my-id"); custom_indicator_set_category(ci, CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); custom_indicator_set_icon(ci, "my-name"); custom_indicator_set_attention_icon(ci, "my-attention-name"); g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); - g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); g_object_unref(G_OBJECT(ci)); @@ -113,7 +113,7 @@ test_libcustomindicator_init_with_props (void) CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", "my-id", "category", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, - "status", CUSTOM_INDICATOR_STATUS_ON, + "status", CUSTOM_INDICATOR_STATUS_ACTIVE, "icon-name", "my-name", "attention-icon-name", "my-attention-name", NULL)); @@ -122,7 +122,7 @@ test_libcustomindicator_init_with_props (void) g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); - g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); g_object_unref(G_OBJECT(ci)); -- cgit v1.2.3 From bca9b7ee96632e7c89092184c174b45722e0511c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 09:20:36 -0500 Subject: Adding in two little client server binaries for testing the custom indicator. --- tests/Makefile.am | 46 ++++++++++++++++++++++++++++- tests/test-defines.h | 7 +++++ tests/test-libcustomindicator-dbus-client.c | 11 +++++++ tests/test-libcustomindicator-dbus-server.c | 11 +++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 tests/test-defines.h create mode 100644 tests/test-libcustomindicator-dbus-client.c create mode 100644 tests/test-libcustomindicator-dbus-server.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 865573b..8327a79 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,12 @@ check_PROGRAMS = \ - test-libcustomindicator + test-libcustomindicator \ + test-libcustomindicator-dbus-client \ + test-libcustomindicator-dbus-server + +######################################### +## test-libcustomindicator +######################################### test_libcustomindicator_SOURCES = \ test-libcustomindicator.c @@ -14,6 +20,44 @@ test_libcustomindicator_LDADD = \ $(INDICATOR_LIBS) \ $(top_builddir)/src/libcustomindicator.la +######################################### +## test-libcustomindicator-dbus-client +######################################### + +test_libcustomindicator_dbus_client_SOURCES = \ + test-defines.h \ + test-libcustomindicator-dbus-client.c + +test_libcustomindicator_dbus_client_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -I$(top_srcdir)/src + +test_libcustomindicator_dbus_client_LDADD = \ + $(INDICATOR_LIBS) \ + $(top_builddir)/src/libcustomindicator.la + +######################################### +## test-libcustomindicator-dbus-server +######################################### + +test_libcustomindicator_dbus_server_SOURCES = \ + test-defines.h \ + test-libcustomindicator-dbus-server.c + +test_libcustomindicator_dbus_server_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -I$(top_srcdir)/src + +test_libcustomindicator_dbus_server_LDADD = \ + $(INDICATOR_LIBS) \ + $(top_builddir)/src/libcustomindicator.la + +######################################### +## Actual tests +######################################### + XML_REPORT = libcustomindicator-check-results.xml HTML_REPORT = libcustomindicator-check-results.html diff --git a/tests/test-defines.h b/tests/test-defines.h new file mode 100644 index 0000000..b68d9fc --- /dev/null +++ b/tests/test-defines.h @@ -0,0 +1,7 @@ + +#define TEST_ID "my-id" +#define TEST_ICON_NAME "my-icon-name" +#define TEST_ATTENTION_ICON_NAME "my-attention-icon-name" +#define TEST_STATE CUSTOM_INDICATOR_STATE_ACTIVE +#define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS + diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c new file mode 100644 index 0000000..7c3de86 --- /dev/null +++ b/tests/test-libcustomindicator-dbus-client.c @@ -0,0 +1,11 @@ + +#include +#include +#include "test-defines.h" + +gint +main (gint argc, gchar * argv[]) +{ + + return 0; +} diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c new file mode 100644 index 0000000..7c3de86 --- /dev/null +++ b/tests/test-libcustomindicator-dbus-server.c @@ -0,0 +1,11 @@ + +#include +#include +#include "test-defines.h" + +gint +main (gint argc, gchar * argv[]) +{ + + return 0; +} -- cgit v1.2.3 From 23b72422d828dd77909f6cc11947f9fb5e8cee2c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 09:30:59 -0500 Subject: Switching to using a little autotest as well. --- tests/Makefile.am | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 8327a79..f6a0525 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,6 +4,9 @@ check_PROGRAMS = \ test-libcustomindicator-dbus-client \ test-libcustomindicator-dbus-server +TESTS = +DISTCLEANFILES = $(TESTS) + ######################################### ## test-libcustomindicator ######################################### @@ -61,10 +64,21 @@ test_libcustomindicator_dbus_server_LDADD = \ XML_REPORT = libcustomindicator-check-results.xml HTML_REPORT = libcustomindicator-check-results.html -libcustomindicator-tester: test-libcustomindicator - gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator +libcustomindicator-tests: test-libcustomindicator + @echo "#!/bin/sh" > libcustomindicator-tests + @echo gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator >> libcustomindicator-tests + @chmod +x libcustomindicator-tests + +TESTS += libcustomindicator-tests +DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) + + +DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -check-local: libcustomindicator-tester +test-libcustomindicator-dbus: test-libcustomindicator-dbus-client test-libcustomindicator-dbus-server Makefile.am + @echo "#!/bin/sh" > test-libcustomindicator-dbus + @echo $(DBUS_RUNNER) --task ./test-libcustomindicator-dbus-client --task-name Client --task ./test-libcustomindicator-dbus-server --task-name Server --ignore-return >> test-libcustomindicator-dbus + @chmod +x test-libcustomindicator-dbus -DISTCLEANFILES = $(XML_REPORT) $(HTML_REPORT) +TESTS += test-libcustomindicator-dbus -- cgit v1.2.3 From 83a3d84ea6e0bb8a9ce7927b08658307becbb186 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 09:46:17 -0500 Subject: Fleshing out the server to setup a simple custom indicator. --- tests/test-defines.h | 2 +- tests/test-libcustomindicator-dbus-server.c | 30 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-defines.h b/tests/test-defines.h index b68d9fc..73ab316 100644 --- a/tests/test-defines.h +++ b/tests/test-defines.h @@ -2,6 +2,6 @@ #define TEST_ID "my-id" #define TEST_ICON_NAME "my-icon-name" #define TEST_ATTENTION_ICON_NAME "my-attention-icon-name" -#define TEST_STATE CUSTOM_INDICATOR_STATE_ACTIVE +#define TEST_STATE CUSTOM_INDICATOR_STATUS_ACTIVE #define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c index 7c3de86..444706f 100644 --- a/tests/test-libcustomindicator-dbus-server.c +++ b/tests/test-libcustomindicator-dbus-server.c @@ -1,11 +1,41 @@ +#include +#include #include #include #include "test-defines.h" +static GMainLoop * mainloop = NULL; + +gboolean +kill_func (gpointer userdata) +{ + g_main_loop_quit(mainloop); + return FALSE; +} + gint main (gint argc, gchar * argv[]) { + g_type_init(); + + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, + "id", TEST_ID, + "category", TEST_CATEGORY, + "status", TEST_STATE, + "icon-name", TEST_ICON_NAME, + "attention-icon-name", TEST_ATTENTION_ICON_NAME, + NULL)); + + g_timeout_add_seconds(2, kill_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_object_unref(G_OBJECT(ci)); + g_debug("Quiting"); return 0; } -- cgit v1.2.3 From a8b100939f7473874d858683229c2021b8ce6be6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 11:24:06 -0500 Subject: Basic code calling all the properties. --- tests/test-libcustomindicator-dbus-client.c | 147 ++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) (limited to 'tests') diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 7c3de86..8e49059 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -1,11 +1,158 @@ #include +#include #include #include "test-defines.h" +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; +static int propcount = 0; + +static void +check_propcount (void) +{ + + return; +} + + +static void +prop_id_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + propcount++; + + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting ID failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_ID, g_value_get_string(&value))) { + g_debug("Property ID Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property ID Returned: PASSED"); + } + + return; +} + +static void +prop_category_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_status_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_attention_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + gint main (gint argc, gchar * argv[]) { + g_type_init(); + + g_usleep(500000); + + GError * error = NULL; + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (error != NULL) { + g_error("Unable to get session bus: %s", error->message); + return 1; + } + + DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, + ":1.0", + "/test", + DBUS_INTERFACE_PROPERTIES, + &error); + if (error != NULL) { + g_error("Unable to get property proxy: %s", error->message); + return 1; + } + + dbus_g_proxy_begin_call (props, + "Get", + prop_id_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Id", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_category_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Category", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_status_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Status", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_icon_name_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "IconName", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_attention_icon_name_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "AttentionIconName", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_menu_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Menu", + G_TYPE_INVALID); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 0; + } return 0; } -- cgit v1.2.3 From e0d35fcfc64134af45aa4da81e6a8e9cd2007d16 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 11:30:41 -0500 Subject: Adding a kill function, just in case. --- tests/test-libcustomindicator-dbus-client.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 8e49059..c6c31f0 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -77,6 +77,15 @@ prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) return; } +gboolean +kill_func (gpointer userdata) +{ + g_main_loop_quit(mainloop); + g_warning("Forced to Kill"); + passed = FALSE; + return FALSE; +} + gint main (gint argc, gchar * argv[]) { @@ -144,6 +153,8 @@ main (gint argc, gchar * argv[]) G_TYPE_STRING, "Menu", G_TYPE_INVALID); + g_timeout_add_seconds(2, kill_func, NULL); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 9db2ce55c3f314f6547a00e592f0caf8a45f8f01 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 11:31:22 -0500 Subject: If we fail, we need to really fail. --- tests/test-libcustomindicator-dbus-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index c6c31f0..0ac1071 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -163,7 +163,7 @@ main (gint argc, gchar * argv[]) return 0; } else { g_debug("Quiting as we're a failure"); - return 0; + return 1; } return 0; } -- cgit v1.2.3 From 199365d6ddaa30851c0a291fdfa288a8bc8ecb5f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:15:53 -0500 Subject: Settng the right path --- tests/test-libcustomindicator-dbus-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 0ac1071..a506760 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -102,7 +102,7 @@ main (gint argc, gchar * argv[]) DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, ":1.0", - "/test", + "/need/a/path", DBUS_INTERFACE_PROPERTIES, &error); if (error != NULL) { -- cgit v1.2.3 From e99a6fee70b515e68a5eda0d9e5d3e0db311d490 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:21:49 -0500 Subject: Fleshing out the property counting. --- tests/test-libcustomindicator-dbus-client.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index a506760..0f3ebb9 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -11,7 +11,9 @@ static int propcount = 0; static void check_propcount (void) { - + if (propcount >= 6) { + g_main_loop_quit(mainloop); + } return; } @@ -39,41 +41,52 @@ prop_id_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) g_debug("Property ID Returned: PASSED"); } + check_propcount(); return; } static void prop_category_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_status_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_attention_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } -- cgit v1.2.3 From af102359a5d71fa5ddfad14d3e6d3063c1801578 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:26:53 -0500 Subject: All strings work. --- tests/test-libcustomindicator-dbus-client.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 0f3ebb9..66922dc 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -68,6 +68,24 @@ prop_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting icon name failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_ICON_NAME, g_value_get_string(&value))) { + g_debug("Property icon name Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property icon name Returned: PASSED"); + } + check_propcount(); return; } @@ -77,6 +95,24 @@ prop_attention_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * d { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting attention icon name failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_ATTENTION_ICON_NAME, g_value_get_string(&value))) { + g_debug("Property attention icon name Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property attention icon name Returned: PASSED"); + } + check_propcount(); return; } -- cgit v1.2.3 From b04e0deb68b1e245eba4bcbbf80b8d706d0250b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:30:40 -0500 Subject: Checking the category and state --- tests/test-defines.h | 2 ++ tests/test-libcustomindicator-dbus-client.c | 36 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/test-defines.h b/tests/test-defines.h index 73ab316..2afe4f4 100644 --- a/tests/test-defines.h +++ b/tests/test-defines.h @@ -3,5 +3,7 @@ #define TEST_ICON_NAME "my-icon-name" #define TEST_ATTENTION_ICON_NAME "my-attention-icon-name" #define TEST_STATE CUSTOM_INDICATOR_STATUS_ACTIVE +#define TEST_STATE_S "active" #define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS +#define TEST_CATEGORY_S "application-status" diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 66922dc..bdc0fa6 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -50,6 +50,24 @@ prop_category_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting category failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_CATEGORY_S, g_value_get_string(&value))) { + g_debug("Property category Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property category Returned: PASSED"); + } + check_propcount(); return; } @@ -59,6 +77,24 @@ prop_status_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting status failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_STATE_S, g_value_get_string(&value))) { + g_debug("Property status Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property status Returned: PASSED"); + } + check_propcount(); return; } -- cgit v1.2.3 From 6a255c63e5030a5ab992184dec39f791eedaa3a7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 15:45:26 -0500 Subject: Changes due to the properties changes. --- tests/test-libcustomindicator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index b3ead63..c4342e8 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -112,8 +112,8 @@ test_libcustomindicator_init_with_props (void) { CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", "my-id", - "category", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, - "status", CUSTOM_INDICATOR_STATUS_ACTIVE, + "category-enum", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, + "status-enum", CUSTOM_INDICATOR_STATUS_ACTIVE, "icon-name", "my-name", "attention-icon-name", "my-attention-name", NULL)); -- cgit v1.2.3 From 603044567814b8a5bc895bb22a1bf3ea35e788a2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 15:47:31 -0500 Subject: Property name changes. Boo. --- tests/test-libcustomindicator-dbus-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c index 444706f..4c9dcb9 100644 --- a/tests/test-libcustomindicator-dbus-server.c +++ b/tests/test-libcustomindicator-dbus-server.c @@ -23,8 +23,8 @@ main (gint argc, gchar * argv[]) CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", TEST_ID, - "category", TEST_CATEGORY, - "status", TEST_STATE, + "category-enum", TEST_CATEGORY, + "status-enum", TEST_STATE, "icon-name", TEST_ICON_NAME, "attention-icon-name", TEST_ATTENTION_ICON_NAME, NULL)); -- cgit v1.2.3 From 1b71a85918d149eb4fdd8f3213ddc52dabc6b684 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 16:19:40 -0500 Subject: Adding in testing the location of the dbusmenuserver --- tests/test-defines.h | 1 + tests/test-libcustomindicator-dbus-client.c | 18 ++++++++++++++++++ tests/test-libcustomindicator-dbus-server.c | 3 +++ 3 files changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/test-defines.h b/tests/test-defines.h index 2afe4f4..9d1fc26 100644 --- a/tests/test-defines.h +++ b/tests/test-defines.h @@ -6,4 +6,5 @@ #define TEST_STATE_S "active" #define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS #define TEST_CATEGORY_S "application-status" +#define TEST_OBJECT "/an/object/path/to/use" diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index bdc0fa6..e0203c0 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -158,6 +158,24 @@ prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting menu object failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_OBJECT, g_value_get_string(&value))) { + g_debug("Property menu object Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property menu object Returned: PASSED"); + } + check_propcount(); return; } diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c index 4c9dcb9..2d61776 100644 --- a/tests/test-libcustomindicator-dbus-server.c +++ b/tests/test-libcustomindicator-dbus-server.c @@ -21,12 +21,15 @@ main (gint argc, gchar * argv[]) g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + DbusmenuServer * dms = dbusmenu_server_new(TEST_OBJECT); + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", TEST_ID, "category-enum", TEST_CATEGORY, "status-enum", TEST_STATE, "icon-name", TEST_ICON_NAME, "attention-icon-name", TEST_ATTENTION_ICON_NAME, + "menu-object", dms, NULL)); g_timeout_add_seconds(2, kill_func, NULL); -- cgit v1.2.3