diff options
author | Ted Gould <ted@gould.cx> | 2010-02-22 12:54:25 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-22 12:54:25 -0600 |
commit | a067b5b0e1da84a381eb5ca5a426b87680dcc9f7 (patch) | |
tree | 7ed70db2d4812ae0e49cd14be9fe952f1b7fd60b /tests/test-libappindicator-fallback-item.c | |
parent | e5612deb73c41eb427f3e8ab66a675ab9545f5e2 (diff) | |
download | libayatana-appindicator-a067b5b0e1da84a381eb5ca5a426b87680dcc9f7.tar.gz libayatana-appindicator-a067b5b0e1da84a381eb5ca5a426b87680dcc9f7.tar.bz2 libayatana-appindicator-a067b5b0e1da84a381eb5ca5a426b87680dcc9f7.zip |
Trying to make the test a little more robust by waiting for the other process to register on the bus, and then waiting.
Diffstat (limited to 'tests/test-libappindicator-fallback-item.c')
-rw-r--r-- | tests/test-libappindicator-fallback-item.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test-libappindicator-fallback-item.c b/tests/test-libappindicator-fallback-item.c index 2c6e044..9fd1b45 100644 --- a/tests/test-libappindicator-fallback-item.c +++ b/tests/test-libappindicator-fallback-item.c @@ -1,5 +1,7 @@ #include <glib.h> #include <glib-object.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-bindings.h> #include <libappindicator/app-indicator.h> #define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE (test_libappindicator_fallback_item_get_type ()) @@ -106,6 +108,27 @@ main (int argc, char ** argv) { gtk_init(&argc, &argv); + 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); + + guint nameret = 0; + + if (!org_freedesktop_DBus_request_name(bus_proxy, "org.test", 0, &nameret, NULL)) { + g_error("Unable to call to request name"); + return 1; + } + + if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_error("Unable to get name"); + return 1; + } + TestLibappindicatorFallbackItem * item = g_object_new(TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, "id", "test-id", "category", "Other", |