aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-02-22 12:56:40 -0600
committerTed Gould <ted@gould.cx>2010-02-22 12:56:40 -0600
commit225f2911ff99822cdb77c4e74f75c0e21f63b943 (patch)
tree7e7d736b4356d276cf1b4691d7328c7b777c32da
parente5612deb73c41eb427f3e8ab66a675ab9545f5e2 (diff)
parentbf13c7af125d97c2067da1b365ac4f11c2f2b943 (diff)
downloadlibayatana-appindicator-225f2911ff99822cdb77c4e74f75c0e21f63b943.tar.gz
libayatana-appindicator-225f2911ff99822cdb77c4e74f75c0e21f63b943.tar.bz2
libayatana-appindicator-225f2911ff99822cdb77c4e74f75c0e21f63b943.zip
Making the fallback test more robust on slow systems.
-rw-r--r--tests/test-libappindicator-fallback-item.c23
-rw-r--r--tests/test-libappindicator-fallback-watcher.c21
2 files changed, 40 insertions, 4 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",
diff --git a/tests/test-libappindicator-fallback-watcher.c b/tests/test-libappindicator-fallback-watcher.c
index 90c7db8..70e01d1 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,23 @@ 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;
+ 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);
+
+ g_debug("Initing");
+
guint nameret = 0;
if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) {