[libsecret] Make sure notifications come in for new objects before waiting



commit 3cb0d8047da1bff2eb7286eef014ff8948c99333
Author: Stef Walter <stefw gnome org>
Date:   Thu Jul 5 23:31:47 2012 +0200

    Make sure notifications come in for new objects before waiting
    
     * In tests make sure notifications settle down before waiting
       on new notifications. This fixes random test crashes.
     * Using async here means all signals are delivered by the time
       we get the new object.

 library/tests/test-collection.c |    8 ++++++--
 library/tests/test-item.c       |   14 ++++++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/library/tests/test-collection.c b/library/tests/test-collection.c
index 70e3998..71212a3 100644
--- a/library/tests/test-collection.c
+++ b/library/tests/test-collection.c
@@ -436,14 +436,18 @@ test_set_label_prop (Test *test,
                      gconstpointer unused)
 {
 	const gchar *collection_path = "/org/freedesktop/secrets/collection/english";
+	GAsyncResult *result = NULL;
 	GError *error = NULL;
 	SecretCollection *collection;
 	guint sigs = 2;
 	gchar *label;
 
-	collection = secret_collection_new_sync (test->service, collection_path,
-	                                         SECRET_COLLECTION_NONE, NULL, &error);
+	secret_collection_new (test->service, collection_path, SECRET_COLLECTION_NONE, NULL, on_async_result, &result);
+	g_assert (result == NULL);
+	egg_test_wait ();
+	collection = secret_collection_new_finish (result, &error);
 	g_assert_no_error (error);
+	g_object_unref (result);
 
 	label = secret_collection_get_label (collection);
 	g_assert_cmpstr (label, ==, "Collection One");
diff --git a/library/tests/test-item.c b/library/tests/test-item.c
index 1a58907..c2eb480 100644
--- a/library/tests/test-item.c
+++ b/library/tests/test-item.c
@@ -367,13 +367,18 @@ test_set_label_prop (Test *test,
                      gconstpointer unused)
 {
 	const gchar *item_path = "/org/freedesktop/secrets/collection/english/1";
+	GAsyncResult *result = NULL;
 	GError *error = NULL;
 	SecretItem *item;
 	guint sigs = 2;
 	gchar *label;
 
-	item = secret_item_new_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error);
+	secret_item_new (test->service, item_path, SECRET_ITEM_NONE, NULL, on_async_result, &result);
+	g_assert (result == NULL);
+	egg_test_wait ();
+	item = secret_item_new_finish (result, &error);
 	g_assert_no_error (error);
+	g_object_unref (result);
 
 	label = secret_item_get_label (item);
 	g_assert_cmpstr (label, ==, "Item One");
@@ -477,13 +482,18 @@ test_set_attributes_prop (Test *test,
                           gconstpointer unused)
 {
 	const gchar *item_path = "/org/freedesktop/secrets/collection/english/1";
+	GAsyncResult *result = NULL;
 	GError *error = NULL;
 	SecretItem *item;
 	GHashTable *attributes;
 	guint sigs = 2;
 
-	item = secret_item_new_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error);
+	secret_item_new (test->service, item_path, SECRET_ITEM_NONE, NULL, on_async_result, &result);
+	g_assert (result == NULL);
+	egg_test_wait ();
+	item = secret_item_new_finish (result, &error);
 	g_assert_no_error (error);
+	g_object_unref (result);
 
 	attributes = secret_item_get_attributes (item);
 	g_assert_cmpstr (g_hash_table_lookup (attributes, "string"), ==, "one");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]