Commit a70ab280 authored by Carlos Garnacho's avatar Carlos Garnacho

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.
parent 8986eb3b
......@@ -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);
main_loop = g_main_loop_new (NULL, FALSE);
g_assert (main_loop != NULL);
/* 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 ();
g_main_loop_run (main_loop);
return result;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment