From a067b5b0e1da84a381eb5ca5a426b87680dcc9f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 22 Feb 2010 12:54:25 -0600 Subject: Trying to make the test a little more robust by waiting for the other process to register on the bus, and then waiting. --- tests/test-libappindicator-fallback-watcher.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/test-libappindicator-fallback-watcher.c') diff --git a/tests/test-libappindicator-fallback-watcher.c b/tests/test-libappindicator-fallback-watcher.c index 90c7db8..c632dff 100644 --- a/tests/test-libappindicator-fallback-watcher.c +++ b/tests/test-libappindicator-fallback-watcher.c @@ -56,10 +56,6 @@ main (int argv, char ** argc) g_debug("Waiting to init."); - /* Wait 1/4 a second, which should trigger the fallback */ - g_usleep(250000); - - g_debug("Initing"); GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); @@ -69,6 +65,16 @@ main (int argv, char ** argc) } DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + + gboolean has_owner = FALSE; + while (!has_owner) { + org_freedesktop_DBus_name_has_owner(bus_proxy, "org.test", &has_owner, NULL); + } + + g_usleep(250000); + + g_debug("Initing"); + guint nameret = 0; if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) { -- cgit v1.2.3 From bf13c7af125d97c2067da1b365ac4f11c2f2b943 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 22 Feb 2010 12:56:03 -0600 Subject: Fall out of the while, sometime, if we really think it's not recoverable. --- tests/test-libappindicator-fallback-watcher.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/test-libappindicator-fallback-watcher.c') diff --git a/tests/test-libappindicator-fallback-watcher.c b/tests/test-libappindicator-fallback-watcher.c index c632dff..70e01d1 100644 --- a/tests/test-libappindicator-fallback-watcher.c +++ b/tests/test-libappindicator-fallback-watcher.c @@ -67,8 +67,15 @@ main (int argv, char ** argc) DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); gboolean has_owner = FALSE; - while (!has_owner) { + 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(250000); -- cgit v1.2.3