summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2022-12-26 12:57:57 -0800
committerAntónio Fernandes <antoniof@gnome.org>2023-01-06 19:38:57 +0000
commitf4003513c873e03d5eb5ff156fd28de7a647a8e4 (patch)
treeb4a7e1afc1e52b6611aa305c4f961f2f33d009ef
parent2768d40326882de2b0121b12f205a2d1f99920c7 (diff)
downloadnautilus-f4003513c873e03d5eb5ff156fd28de7a647a8e4.tar.gz
test-nautilus-search-engine-tracker: Setup connection proactively
Now that the tracker miner fs connection is async we have to set it proactively or the test fails.
-rw-r--r--src/nautilus-tracker-utilities.c30
-rw-r--r--src/nautilus-tracker-utilities.h3
-rw-r--r--test/automated/displayless/test-nautilus-search-engine-tracker.c3
3 files changed, 36 insertions, 0 deletions
diff --git a/src/nautilus-tracker-utilities.c b/src/nautilus-tracker-utilities.c
index 6ded0fb1e..b2e894a41 100644
--- a/src/nautilus-tracker-utilities.c
+++ b/src/nautilus-tracker-utilities.c
@@ -78,6 +78,12 @@ nautilus_tracker_setup_miner_fs_connection (void)
{
static gsize tried_tracker_init = FALSE;
+ if (tracker_miner_fs_connection != NULL)
+ {
+ /* The connection was already established */
+ return;
+ }
+
if (g_once_init_enter (&tried_tracker_init))
{
const gchar *busname = "org.freedesktop.Tracker3.Miner.Files";
@@ -92,6 +98,30 @@ nautilus_tracker_setup_miner_fs_connection (void)
}
/**
+ * nautilus_tracker_setup_host_miner_fs_connection_sync:
+ *
+ * This function is only meant to be used within tests.
+ * This version of this setup function intentionally blocks to help with tests.
+ *
+ */
+void
+nautilus_tracker_setup_host_miner_fs_connection_sync (void)
+{
+ g_autoptr (GError) error = NULL;
+ const gchar *busname = "org.freedesktop.Tracker3.Miner.Files";
+
+ g_message ("Starting %s", busname);
+ tracker_miner_fs_connection = tracker_sparql_connection_bus_new (busname, NULL, NULL, &error);
+ if (error != NULL)
+ {
+ g_critical ("Could not start local Tracker indexer at %s: %s", busname, error->message);
+ return;
+ }
+
+ tracker_miner_fs_busname = busname;
+}
+
+/**
* nautilus_tracker_get_miner_fs_connection:
* @error: return location for a #GError
*
diff --git a/src/nautilus-tracker-utilities.h b/src/nautilus-tracker-utilities.h
index 614b7cf6b..d79c2b68b 100644
--- a/src/nautilus-tracker-utilities.h
+++ b/src/nautilus-tracker-utilities.h
@@ -26,3 +26,6 @@
TrackerSparqlConnection * nautilus_tracker_get_miner_fs_connection (GError **error);
void nautilus_tracker_setup_miner_fs_connection (void);
+
+/* nautilus_tracker_setup_host_miner_fs_connection_sync() is for testing purposes only */
+void nautilus_tracker_setup_host_miner_fs_connection_sync (void);
diff --git a/test/automated/displayless/test-nautilus-search-engine-tracker.c b/test/automated/displayless/test-nautilus-search-engine-tracker.c
index 0c96ef76d..d72c0b49b 100644
--- a/test/automated/displayless/test-nautilus-search-engine-tracker.c
+++ b/test/automated/displayless/test-nautilus-search-engine-tracker.c
@@ -1,3 +1,4 @@
+#include "nautilus-tracker-utilities.h"
#include "test-utilities.h"
/* Time in seconds we allow for Tracker Miners to index the file */
@@ -138,6 +139,8 @@ main (int argc,
g_autoptr (GError) error = NULL;
const gchar *indexed_tmpdir;
+ nautilus_tracker_setup_host_miner_fs_connection_sync ();
+
indexed_tmpdir = g_getenv ("TRACKER_INDEXED_TMPDIR");
if (!indexed_tmpdir)
{