aboutsummaryrefslogtreecommitdiff
path: root/tests/test-json-client.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-06-28 18:18:13 -0500
committerTed Gould <ted@gould.cx>2010-06-28 18:18:13 -0500
commitecfd01992d210f2411d1adac9ed7622837135210 (patch)
treec7f74a41d8f816778970e63b49d982e63989324f /tests/test-json-client.c
parent3d291c9bd937b20511efbebb938b3a6b059e8b14 (diff)
downloadlibdbusmenu-ecfd01992d210f2411d1adac9ed7622837135210.tar.gz
libdbusmenu-ecfd01992d210f2411d1adac9ed7622837135210.tar.bz2
libdbusmenu-ecfd01992d210f2411d1adac9ed7622837135210.zip
Adding a test-client bin
Diffstat (limited to 'tests/test-json-client.c')
-rw-r--r--tests/test-json-client.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test-json-client.c b/tests/test-json-client.c
new file mode 100644
index 0000000..2d90608
--- /dev/null
+++ b/tests/test-json-client.c
@@ -0,0 +1,45 @@
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+GMainLoop * mainloop = NULL;
+
+int
+main (int argv, char ** argc)
+{
+ g_type_init();
+ g_debug("Wait for friends");
+
+ 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 * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+
+ gboolean has_owner = FALSE;
+ gint owner_count = 0;
+ while (!has_owner && owner_count < 10000) {
+ org_freedesktop_DBus_name_has_owner(bus_proxy, "org.test", &has_owner, NULL);
+ owner_count++;
+ }
+
+ if (owner_count == 10000) {
+ g_error("Unable to get name owner after 10000 tries");
+ return 1;
+ }
+
+ g_usleep(500000);
+
+ g_debug("Initing");
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ g_debug("Exiting");
+
+ return 0;
+}