[nautilus] tests: Use GMainLoop in search engine test



commit 2f8e300d3d50244af8c64fe12c558de4794d912b
Author: Ernestas Kulik <ernestask gnome org>
Date:   Thu Jul 19 13:18:33 2018 +0300

    tests: Use GMainLoop in search engine test
    
    This removes the need for a display.

 test/automated/display/meson.build                        |  5 +----
 test/automated/displayless/meson.build                    |  6 +++++-
 .../test-nautilus-search-engine.c                         | 15 ++++++++++-----
 3 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/test/automated/display/meson.build b/test/automated/display/meson.build
index 171730e43..76bcabd60 100644
--- a/test/automated/display/meson.build
+++ b/test/automated/display/meson.build
@@ -4,12 +4,9 @@ test_env += [
 ]
 
 tests = [
-  ['test-nautilus-search-engine', [
-    'test-nautilus-search-engine.c'
-  ]],
   ['test-nautilus-directory-async', [
     'test-nautilus-directory-async.c'
-  ]]
+  ]],
 ]
 
 foreach t: tests
diff --git a/test/automated/displayless/meson.build b/test/automated/displayless/meson.build
index b05b591b1..8a4800ffd 100644
--- a/test/automated/displayless/meson.build
+++ b/test/automated/displayless/meson.build
@@ -13,7 +13,11 @@ tests = [
   ]],
   ['test-file-operations-move-files', [
     'test-file-operations-move-files.c'
-  ]]
+  ]],
+  ['test-nautilus-search-engine', [
+    'test-nautilus-search-engine.c'
+  ]],
+>>>>>>> tests: Use GMainLoop in search engine test
 ]
 
 foreach t: tests
diff --git a/test/automated/display/test-nautilus-search-engine.c 
b/test/automated/displayless/test-nautilus-search-engine.c
similarity index 79%
rename from test/automated/display/test-nautilus-search-engine.c
rename to test/automated/displayless/test-nautilus-search-engine.c
index 2ed8af77e..8fb66aad4 100644
--- a/test/automated/display/test-nautilus-search-engine.c
+++ b/test/automated/displayless/test-nautilus-search-engine.c
@@ -1,4 +1,5 @@
 #include <src/nautilus-file-utilities.h>
+#include <src/nautilus-global-preferences.h>
 #include <src/nautilus-search-provider.h>
 #include <src/nautilus-search-engine.h>
 #include <gtk/gtk.h>
@@ -17,31 +18,35 @@ hits_added_cb (NautilusSearchEngine *engine,
 
 static void
 finished_cb (NautilusSearchEngine         *engine,
-             NautilusSearchProviderStatus  status)
+             NautilusSearchProviderStatus  status,
+             gpointer                      user_data)
 {
     g_print ("finished!\n");
-    gtk_main_quit ();
+    g_main_loop_quit (user_data);
 }
 
 int
 main (int   argc,
       char *argv[])
 {
+    GMainLoop *loop;
     NautilusSearchEngine *engine;
     NautilusSearchEngineModel *model;
     NautilusDirectory *directory;
     NautilusQuery *query;
     GFile *location;
 
-    gtk_init (&argc, &argv);
+    loop = g_main_loop_new (NULL, TRUE);
 
     nautilus_ensure_extension_points ();
+    /* Needed for nautilus-query.c. */
+    nautilus_global_preferences_init ();
 
     engine = nautilus_search_engine_new ();
     g_signal_connect (engine, "hits-added",
                       G_CALLBACK (hits_added_cb), NULL);
     g_signal_connect (engine, "finished",
-                      G_CALLBACK (finished_cb), NULL);
+                      G_CALLBACK (finished_cb), loop);
 
     query = nautilus_query_new ();
     nautilus_query_set_text (query, "richard hult");
@@ -60,6 +65,6 @@ main (int   argc,
     nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (engine));
     g_object_unref (engine);
 
-    gtk_main ();
+    g_main_loop_run (loop);
     return 0;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]