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.
This commit is contained in:
Michael James Gratton 2016-12-31 14:49:38 +11:00
parent 61c8e5a105
commit 5dc20f4273
2 changed files with 15 additions and 2 deletions

View file

@ -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)

View file

@ -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;
}