[geary/wip/728002-webkit2: 98/105] Make GTK & async unit tests work by running them in a GTK+ main loop.



commit 6fb1d109b8f0476d92cfee10784f1a4795c26e08
Author: Michael James Gratton <mike vee net>
Date:   Sat Dec 31 14:49:38 2016 +1100

    Make GTK & async unit tests work by running them in a GTK+ main loop.
    
    Include GResources in the build so they can be loaded.
    
    Bug 776421.
    
    * test/main.vala (main): Init GTK, start a main loop and run the tests in
      that.
    
    * test/CMakeLists.txt: Include GResources in unit test binary so they can
      be loaded by tests, and since we can't compile them into the client
      static lib.

 test/CMakeLists.txt |    6 +++++-
 test/main.vala      |   11 ++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9dad847..fa61e1e 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -30,6 +30,7 @@ pkg_check_modules(DEPS REQUIRED
   javascriptcoregtk-4.0
   libsoup-2.4
   webkit2gtk-4.0
+  libxml-2.0
 )
 
 set(TEST_PACKAGES
@@ -58,6 +59,9 @@ set(LIB_PATHS ${DEPS_LIBRARY_DIRS})
 link_directories(${LIB_PATHS})
 add_definitions(${CFLAGS})
 
+# GResources must be compiled into the binary??
+set_property(SOURCE ${RESOURCES_C} PROPERTY GENERATED TRUE)
+
 set(VALAC_OPTIONS
     --vapidir=${CMAKE_BINARY_DIR}/src
     --vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi
@@ -79,5 +83,5 @@ OPTIONS
     ${VALAC_OPTIONS}
 )
 
-add_executable(geary-test ${TEST_VALA_C})
+add_executable(geary-test ${TEST_VALA_C} ${RESOURCES_C})
 target_link_libraries(geary-test ${DEPS_LIBRARIES} geary-client geary-engine)
diff --git a/test/main.vala b/test/main.vala
index ff99b02..06be7f3 100644
--- a/test/main.vala
+++ b/test/main.vala
@@ -18,6 +18,7 @@ int main(string[] args) {
      * Initialise all the things.
      */
 
+    Gtk.init(ref args);
     Test.init(ref args);
 
     Geary.RFC822.init();
@@ -46,5 +47,13 @@ int main(string[] args) {
     root.add_suite(engine);
     root.add_suite(client);
 
-    return Test.run();
+    int ret = -1;
+    Idle.add(() => {
+            ret = Test.run();
+            Gtk.main_quit();
+            return false;
+        });
+
+    Gtk.main();
+    return ret;
 }


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