From 35d5c711028141dbca7907f550849b1bd1c8dfe7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Nov 2009 13:15:47 -0600 Subject: De-customizing the directory stuff. --- tests/Makefile.am | 70 +++---- tests/test-libappindicator-dbus-client.c | 272 ++++++++++++++++++++++++++++ tests/test-libappindicator-dbus-server.c | 44 +++++ tests/test-libappindicator.c | 163 +++++++++++++++++ tests/test-libcustomindicator-dbus-client.c | 272 ---------------------------- tests/test-libcustomindicator-dbus-server.c | 44 ----- tests/test-libcustomindicator.c | 163 ----------------- 7 files changed, 514 insertions(+), 514 deletions(-) create mode 100644 tests/test-libappindicator-dbus-client.c create mode 100644 tests/test-libappindicator-dbus-server.c create mode 100644 tests/test-libappindicator.c delete mode 100644 tests/test-libcustomindicator-dbus-client.c delete mode 100644 tests/test-libcustomindicator-dbus-server.c delete mode 100644 tests/test-libcustomindicator.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 0b771db..845b41c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,92 +1,92 @@ check_PROGRAMS = \ - test-libcustomindicator \ - test-libcustomindicator-dbus-client \ - test-libcustomindicator-dbus-server \ + test-libappindicator \ + test-libappindicator-dbus-client \ + test-libappindicator-dbus-server \ test-simple-app TESTS = DISTCLEANFILES = $(TESTS) ######################################### -## test-libcustomindicator +## test-libappindicator ######################################### -test_libcustomindicator_SOURCES = \ - test-libcustomindicator.c +test_libappindicator_SOURCES = \ + test-libappindicator.c -test_libcustomindicator_CFLAGS = \ +test_libappindicator_CFLAGS = \ $(INDICATOR_CFLAGS) \ -Wall -Werror \ -I$(top_srcdir)/src -test_libcustomindicator_LDADD = \ +test_libappindicator_LDADD = \ $(INDICATOR_LIBS) \ - $(top_builddir)/src/libcustomindicator.la + $(top_builddir)/src/libappindicator.la ######################################### -## test-libcustomindicator-dbus-client +## test-libappindicator-dbus-client ######################################### -test_libcustomindicator_dbus_client_SOURCES = \ +test_libappindicator_dbus_client_SOURCES = \ test-defines.h \ - test-libcustomindicator-dbus-client.c + test-libappindicator-dbus-client.c -test_libcustomindicator_dbus_client_CFLAGS = \ +test_libappindicator_dbus_client_CFLAGS = \ $(INDICATOR_CFLAGS) \ -Wall -Werror \ -I$(top_srcdir)/src -test_libcustomindicator_dbus_client_LDADD = \ +test_libappindicator_dbus_client_LDADD = \ $(INDICATOR_LIBS) \ - $(top_builddir)/src/libcustomindicator.la + $(top_builddir)/src/libappindicator.la ######################################### -## test-libcustomindicator-dbus-server +## test-libappindicator-dbus-server ######################################### -test_libcustomindicator_dbus_server_SOURCES = \ +test_libappindicator_dbus_server_SOURCES = \ test-defines.h \ - test-libcustomindicator-dbus-server.c + test-libappindicator-dbus-server.c -test_libcustomindicator_dbus_server_CFLAGS = \ +test_libappindicator_dbus_server_CFLAGS = \ $(INDICATOR_CFLAGS) \ -Wall -Werror \ -I$(top_srcdir)/src -test_libcustomindicator_dbus_server_LDADD = \ +test_libappindicator_dbus_server_LDADD = \ $(INDICATOR_LIBS) \ - $(top_builddir)/src/libcustomindicator.la + $(top_builddir)/src/libappindicator.la ######################################### ## Actual tests ######################################### -XML_REPORT = libcustomindicator-check-results.xml -HTML_REPORT = libcustomindicator-check-results.html +XML_REPORT = libappindicator-check-results.xml +HTML_REPORT = libappindicator-check-results.html -libcustomindicator-tests: libcustomindicator-tests-gtester Makefile.am +libappindicator-tests: libappindicator-tests-gtester Makefile.am @echo "#!/bin/sh" > $@ - @echo $(DBUS_RUNNER) --task ./libcustomindicator-tests-gtester >> $@ + @echo $(DBUS_RUNNER) --task ./libappindicator-tests-gtester >> $@ @chmod +x $@ -libcustomindicator-tests-gtester: test-libcustomindicator Makefile.am +libappindicator-tests-gtester: test-libappindicator Makefile.am @echo "#!/bin/sh" > $@ - @echo gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator >> $@ + @echo gtester -k --verbose -o=$(XML_REPORT) ./test-libappindicator >> $@ @chmod +x $@ -TESTS += libcustomindicator-tests -DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) libcustomindicator-tests-gtester +TESTS += libappindicator-tests +DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) libappindicator-tests-gtester DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -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 +test-libappindicator-dbus: test-libappindicator-dbus-client test-libappindicator-dbus-server Makefile.am + @echo "#!/bin/sh" > test-libappindicator-dbus + @echo $(DBUS_RUNNER) --task ./test-libappindicator-dbus-client --task-name Client --task ./test-libappindicator-dbus-server --task-name Server --ignore-return >> test-libappindicator-dbus + @chmod +x test-libappindicator-dbus -TESTS += test-libcustomindicator-dbus +TESTS += test-libappindicator-dbus ######################################### ## test-simple-app @@ -102,5 +102,5 @@ test_simple_app_CFLAGS = \ test_simple_app_LDADD = \ $(INDICATOR_LIBS) \ - $(top_builddir)/src/libcustomindicator.la + $(top_builddir)/src/libappindicator.la diff --git a/tests/test-libappindicator-dbus-client.c b/tests/test-libappindicator-dbus-client.c new file mode 100644 index 0000000..e0203c0 --- /dev/null +++ b/tests/test-libappindicator-dbus-client.c @@ -0,0 +1,272 @@ + +#include +#include +#include +#include "test-defines.h" + +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; +static int propcount = 0; + +static void +check_propcount (void) +{ + if (propcount >= 6) { + g_main_loop_quit(mainloop); + } + 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"); + } + + check_propcount(); + return; +} + +static void +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; +} + +static void +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; +} + +static void +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; +} + +static void +prop_attention_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 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; +} + +static void +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; +} + +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[]) +{ + 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", + "/need/a/path", + 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); + + g_timeout_add_seconds(2, kill_func, NULL); + + 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 1; + } + return 0; +} diff --git a/tests/test-libappindicator-dbus-server.c b/tests/test-libappindicator-dbus-server.c new file mode 100644 index 0000000..2d61776 --- /dev/null +++ b/tests/test-libappindicator-dbus-server.c @@ -0,0 +1,44 @@ + +#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)))); + + 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); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_object_unref(G_OBJECT(ci)); + g_debug("Quiting"); + + return 0; +} diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c new file mode 100644 index 0000000..c4342e8 --- /dev/null +++ b/tests/test-libappindicator.c @@ -0,0 +1,163 @@ + +#include +#include + +#include + +void +test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, gchar * 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_PASSIVE); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); + g_assert(signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); + 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) +{ + 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_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_ACTIVE); + 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) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, + "id", "my-id", + "category-enum", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, + "status-enum", CUSTOM_INDICATOR_STATUS_ACTIVE, + "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_ACTIVE); + g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_object_unref(G_OBJECT(ci)); + return; +} + +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)); + return; +} + +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_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; +} + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + test_libcustomindicator_props_suite(); + + + return g_test_run (); +} diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c deleted file mode 100644 index e0203c0..0000000 --- a/tests/test-libcustomindicator-dbus-client.c +++ /dev/null @@ -1,272 +0,0 @@ - -#include -#include -#include -#include "test-defines.h" - -static GMainLoop * mainloop = NULL; -static gboolean passed = TRUE; -static int propcount = 0; - -static void -check_propcount (void) -{ - if (propcount >= 6) { - g_main_loop_quit(mainloop); - } - 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"); - } - - check_propcount(); - return; -} - -static void -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; -} - -static void -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; -} - -static void -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; -} - -static void -prop_attention_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 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; -} - -static void -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; -} - -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[]) -{ - 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", - "/need/a/path", - 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); - - g_timeout_add_seconds(2, kill_func, NULL); - - 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 1; - } - return 0; -} diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c deleted file mode 100644 index 2d61776..0000000 --- a/tests/test-libcustomindicator-dbus-server.c +++ /dev/null @@ -1,44 +0,0 @@ - -#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)))); - - 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); - - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); - - g_object_unref(G_OBJECT(ci)); - g_debug("Quiting"); - - return 0; -} diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c deleted file mode 100644 index c4342e8..0000000 --- a/tests/test-libcustomindicator.c +++ /dev/null @@ -1,163 +0,0 @@ - -#include -#include - -#include - -void -test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, gchar * 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_PASSIVE); - g_assert(!signaled); - - signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); - g_assert(signaled); - - signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); - 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) -{ - 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_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_ACTIVE); - 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) -{ - CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, - "id", "my-id", - "category-enum", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, - "status-enum", CUSTOM_INDICATOR_STATUS_ACTIVE, - "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_ACTIVE); - g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); - - g_object_unref(G_OBJECT(ci)); - return; -} - -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)); - return; -} - -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_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; -} - -gint -main (gint argc, gchar * argv[]) -{ - g_type_init(); - g_test_init(&argc, &argv, NULL); - - /* Test suites */ - test_libcustomindicator_props_suite(); - - - return g_test_run (); -} -- cgit v1.2.3