[tracker/ttl: 7/8] libtracker-data: Fix and reenable backup test



commit 834b1b276933c290a373743a12175aa3607682ae
Author: Jürg Billeter <j bitron ch>
Date:   Thu Mar 18 09:32:58 2010 +0100

    libtracker-data: Fix and reenable backup test
    
    Backup runs asynchronously, wait for it.

 tests/libtracker-data/.gitignore            |    1 +
 tests/libtracker-data/Makefile.am           |    3 ++-
 tests/libtracker-data/tracker-backup-test.c |   13 +++++++++++++
 3 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/tests/libtracker-data/.gitignore b/tests/libtracker-data/.gitignore
index d7bb9a9..50b2c37 100644
--- a/tests/libtracker-data/.gitignore
+++ b/tests/libtracker-data/.gitignore
@@ -1,4 +1,5 @@
 tracker
+tracker-backup
 tracker-ontology
 tracker-sparql
 tracker-sparql-blank
diff --git a/tests/libtracker-data/Makefile.am b/tests/libtracker-data/Makefile.am
index 891f203..275b943 100644
--- a/tests/libtracker-data/Makefile.am
+++ b/tests/libtracker-data/Makefile.am
@@ -24,7 +24,8 @@ noinst_PROGRAMS = $(TEST_PROGS)
 TEST_PROGS += 								\
 	tracker-sparql							\
 	tracker-sparql-blank						\
-	tracker-ontology						
+	tracker-ontology						\
+	tracker-backup
 
 INCLUDES = 								\
 	-DTRACKER_COMPILATION						\
diff --git a/tests/libtracker-data/tracker-backup-test.c b/tests/libtracker-data/tracker-backup-test.c
index aabf368..f54437b 100644
--- a/tests/libtracker-data/tracker-backup-test.c
+++ b/tests/libtracker-data/tracker-backup-test.c
@@ -34,12 +34,18 @@
 #include <libtracker-data/tracker-data-backup.h>
 
 static gint backup_calls = 0;
+static GMainLoop *loop = NULL;
 
 static void
 backup_finished_cb (GError *error, gpointer user_data)
 {
         g_assert (TRUE);
         backup_calls += 1;
+
+	if (loop != NULL) {
+		/* backup callback, quite main loop */
+		g_main_loop_quit (loop);
+	}
 }
 
 static gboolean
@@ -122,6 +128,13 @@ test_backup_and_restore (void)
                                   backup_finished_cb,
                                   NULL,
                                   NULL);
+
+	/* Backup is asynchronous, wait until it is finished */
+	loop = g_main_loop_new (NULL, FALSE);
+	g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+	loop = NULL;
+
 	tracker_data_manager_shutdown ();
 
         meta_db = g_build_path (G_DIR_SEPARATOR_S, db_location, "meta.db", NULL);



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