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/test-libcustomindicator-dbus-client.c | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/test-libcustomindicator-dbus-client.c (limited to 'tests/test-libcustomindicator-dbus-client.c') 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; +} -- 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/test-libcustomindicator-dbus-client.c') 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/test-libcustomindicator-dbus-client.c') 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/test-libcustomindicator-dbus-client.c') 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/test-libcustomindicator-dbus-client.c') 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/test-libcustomindicator-dbus-client.c') 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/test-libcustomindicator-dbus-client.c') 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-libcustomindicator-dbus-client.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/test-libcustomindicator-dbus-client.c') 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 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-libcustomindicator-dbus-client.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test-libcustomindicator-dbus-client.c') 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; } -- cgit v1.2.3