summaryrefslogtreecommitdiff
path: root/tests/functional-tests
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2019-12-28 02:10:09 +0100
committerCarlos Garnacho <carlosg@gnome.org>2020-02-17 18:57:46 +0100
commit167e6e796ac16dee932e5ec4ff33b1d9f9aa4f3d (patch)
tree4b98e8b9f38cf8019030c783f9bf41681df7e6d5 /tests/functional-tests
parentb5de2717c7b5b6a7e06d77373b36219da30a647b (diff)
downloadtracker-167e6e796ac16dee932e5ec4ff33b1d9f9aa4f3d.tar.gz
tests: Make test-bus-query-cancellation use in-process endpoint
Create a local connection and endpoint in another thread, and use it from the main thread through a bus connection.
Diffstat (limited to 'tests/functional-tests')
-rw-r--r--tests/functional-tests/ipc/test-bus-query-cancellation.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/tests/functional-tests/ipc/test-bus-query-cancellation.c b/tests/functional-tests/ipc/test-bus-query-cancellation.c
index 916b37481..44388b88d 100644
--- a/tests/functional-tests/ipc/test-bus-query-cancellation.c
+++ b/tests/functional-tests/ipc/test-bus-query-cancellation.c
@@ -26,6 +26,76 @@
#define MAX_TRIES 100
static int counter = 0;
+static gboolean started = FALSE;
+
+TrackerSparqlConnection *
+create_local_connection (GError **error)
+{
+ TrackerSparqlConnection *conn;
+ GFile *store, *ontology;
+ gchar *path;
+
+ path = g_build_filename (g_get_tmp_dir (), "libtracker-sparql-test-XXXXXX", NULL);
+ g_mkdtemp_full (path, 0700);
+ store = g_file_new_for_path (path);
+ g_free (path);
+
+ ontology = g_file_new_for_path (TEST_ONTOLOGIES_DIR);
+
+ conn = tracker_sparql_connection_new (0, store, ontology, NULL, error);
+ g_object_unref (store);
+ g_object_unref (ontology);
+
+ return conn;
+}
+
+static gpointer
+thread_func (gpointer user_data)
+{
+ GDBusConnection *dbus_conn = user_data;
+ TrackerSparqlConnection *direct;
+ TrackerEndpointDBus *endpoint;
+ GMainContext *context;
+ GMainLoop *main_loop;
+
+ context = g_main_context_new ();
+ g_main_context_push_thread_default (context);
+
+ main_loop = g_main_loop_new (context, FALSE);
+
+ direct = create_local_connection (NULL);
+ if (!direct)
+ return NULL;
+
+ endpoint = tracker_endpoint_dbus_new (direct, dbus_conn, NULL, NULL, NULL);
+ if (!endpoint)
+ return NULL;
+
+ started = TRUE;
+ g_main_loop_run (main_loop);
+
+ return NULL;
+}
+
+static TrackerSparqlConnection *
+create_dbus_connection (GError **error)
+{
+ TrackerSparqlConnection *dbus;
+ GDBusConnection *dbus_conn;
+
+ dbus_conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+ if (!dbus_conn)
+ return NULL;
+
+ g_thread_new (NULL, thread_func, dbus_conn);
+
+ while (!started)
+ g_usleep (100);
+
+ dbus = tracker_sparql_connection_bus_new (g_dbus_connection_get_unique_name (dbus_conn),
+ dbus_conn, error);
+ return dbus;
+}
static void
query_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
@@ -75,8 +145,7 @@ test_tracker_sparql_gb737023 (void)
g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=");
g_test_bug ("737023");
- g_setenv ("TRACKER_SPARQL_BACKEND", "bus", TRUE);
- conn = tracker_sparql_connection_get (NULL, &error);
+ conn = create_dbus_connection (&error);
g_assert_no_error (error);
loop = g_main_loop_new (NULL, FALSE);