diff options
author | Corey Berla <corey@berla.me> | 2022-12-26 12:57:57 -0800 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-12-28 00:19:14 +0000 |
commit | 7246b841be864c8b4727bb3708966581e4ebe8dc (patch) | |
tree | 31dd03a09bf50b5c956bfac419486673d58745a0 | |
parent | 78e847fe1880c27902321f78c634ffe9f5e7ac3d (diff) | |
download | nautilus-7246b841be864c8b4727bb3708966581e4ebe8dc.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.c | 30 | ||||
-rw-r--r-- | src/nautilus-tracker-utilities.h | 3 | ||||
-rw-r--r-- | test/automated/displayless/test-nautilus-search-engine-tracker.c | 3 |
3 files changed, 36 insertions, 0 deletions
diff --git a/src/nautilus-tracker-utilities.c b/src/nautilus-tracker-utilities.c index d73ea1423..f621c3a01 100644 --- a/src/nautilus-tracker-utilities.c +++ b/src/nautilus-tracker-utilities.c @@ -73,6 +73,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"; @@ -87,6 +93,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) { |