From ecfd01992d210f2411d1adac9ed7622837135210 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 18:18:13 -0500 Subject: Adding a test-client bin --- .bzrignore | 1 + tests/Makefile.am | 1 + tests/test-json-client.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/test-json-client.c diff --git a/.bzrignore b/.bzrignore index d2d26a9..e80aadf 100644 --- a/.bzrignore +++ b/.bzrignore @@ -186,3 +186,4 @@ tests/dbusmenu-jsonloader.pc tests/libdbusmenu-jsonloader.la tests/libdbusmenu_jsonloader_la-json-loader.lo tests/test-json-server +tests/test-json-client diff --git a/tests/Makefile.am b/tests/Makefile.am index 2dd2cf7..9dab3eb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ check_PROGRAMS = \ test-gtk-shortcut-server \ test-glib-simple-items \ test-gtk-reorder-server \ + test-json-client \ test-json-server XVFB_RUN=". $(srcdir)/run-xvfb.sh" 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 +#include +#include +#include + +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; +} -- cgit v1.2.3