diff options
-rw-r--r-- | .bzrignore | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/test-json-client.c | 45 |
3 files changed, 47 insertions, 0 deletions
@@ -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 <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; +} |