[tracker] tests: Initialize and run main loop in specific tests
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tests: Initialize and run main loop in specific tests
- Date: Sat, 23 Feb 2019 13:20:58 +0000 (UTC)
commit a70ab28015f28927ed9fb0e9b11f981bcb025cfe
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Feb 23 13:35:36 2019 +0100
tests: Initialize and run main loop in specific tests
Both /libtracker-sparql/tracker-sparql/tracker_sparql_cursor_next_async
and /libtracker-sparql/tracker-sparql/nb237150 use the main loop.
Let each initialize and run it instead of doing it in main() (yikes!)
or depending on tracker-fts (only true for the former?). Initializing
the main loop on main() was also dubious for the latter, since we fork
into a subprocess.
tests/libtracker-sparql/tracker-sparql-test.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/tests/libtracker-sparql/tracker-sparql-test.c b/tests/libtracker-sparql/tracker-sparql-test.c
index 54a7d687a..43ecf489d 100644
--- a/tests/libtracker-sparql/tracker-sparql-test.c
+++ b/tests/libtracker-sparql/tracker-sparql-test.c
@@ -187,6 +187,8 @@ test_tracker_sparql_cursor_next_async (void)
TrackerSparqlConnection *connection;
GError *error = NULL;
+ main_loop = g_main_loop_new (NULL, TRUE);
+
/* So, the idea here:
* 1. Test async cursor_next() call.
* 2. Make sure we can cancel a cursor_next() call and start a new query (was failing)
@@ -198,6 +200,7 @@ test_tracker_sparql_cursor_next_async (void)
g_assert (connection != NULL);
test_tracker_sparql_cursor_next_async_query (connection, 0);
+ g_main_loop_run (main_loop);
}
#endif /* HAVE_TRACKER_FTS */
@@ -288,6 +291,8 @@ test_tracker_sparql_nb237150_cb (GObject *source_object,
static void
test_tracker_sparql_nb237150_subprocess (void)
{
+ main_loop = g_main_loop_new (NULL, TRUE);
+
g_print ("\n");
g_print ("Calling #1 - tracker_sparql_connection_get_async()\n");
tracker_sparql_connection_get_async (NULL, test_tracker_sparql_nb237150_cb, GINT_TO_POINTER(1));
@@ -296,6 +301,7 @@ test_tracker_sparql_nb237150_subprocess (void)
tracker_sparql_connection_get_async (NULL, test_tracker_sparql_nb237150_cb, GINT_TO_POINTER(2));
g_print ("Calling both finished\n");
+ g_main_loop_run (main_loop);
}
static void
@@ -367,11 +373,6 @@ main (gint argc, gchar **argv)
g_test_init (&argc, &argv, NULL);
-#if HAVE_TRACKER_FTS
- main_loop = g_main_loop_new (NULL, FALSE);
- g_assert (main_loop != NULL);
-#endif
-
/* NOTE: this first test must come BEFORE any others because
* connections are cached by libtracker-sparql.
*/
@@ -397,9 +398,5 @@ main (gint argc, gchar **argv)
result = g_test_run ();
-#if HAVE_TRACKER_FTS
- g_main_loop_run (main_loop);
-#endif
-
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]