From 5dc20f427333bb7dd291cabd766d7c4a5c248581 Mon Sep 17 00:00:00 2001 From: Michael James Gratton Date: Sat, 31 Dec 2016 14:49:38 +1100 Subject: [PATCH] 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 9dff841f..32145782 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 @@ -59,6 +60,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 @@ -80,7 +84,7 @@ OPTIONS ${VALAC_OPTIONS} ) -add_executable(geary-test ${TEST_VALA_C}) +add_executable(geary-test ${TEST_VALA_C} ${RESOURCES_C}) # Depend on geary so things like GResources, GSetting, etc are # compiled before the tests are built and run. add_dependencies(geary-test geary) diff --git a/test/main.vala b/test/main.vala index 0d26e21b..be55e6ab 100644 --- a/test/main.vala +++ b/test/main.vala @@ -24,6 +24,7 @@ int main(string[] args) { * Initialise all the things. */ + Gtk.init(ref args); Test.init(ref args); Geary.RFC822.init(); @@ -52,5 +53,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; }