This allows us to compile the engine tests against the internal VAPI, so we can unit test internal classes. * CMakeLists.txt: Add top-level targets test-engine-run and test-client-run that execute the respective test binaries. Make the tests target depend on them and make them depend on their binaries. * Makefile.in: Add test-client and test-engin targets for convenience. * src/CMakeLists.txt: Make the right invocation of valac to generate a correct geary-engine-internal.vapi. Make gsettings schema generation depend on geary-client so it exists for test-client if the main binary hasn't been built. * test/CMakeLists.txt: Split everything up into to builds, one for test-engine and the other for test-client. Use geary-engine-internal when building test-engine for access to internal classes and members. * test/engine/util-idle-manager-test.vala, test/engine/util-timeout-manager-test.vala: Use Glib MainContext rather than the GTK main loop for pumping events so the test cases compile without GTK. * test/test-engine.vala, test/test-client.vala: New main source file for test binaries based on old main.vala.
40 lines
1 KiB
Vala
40 lines
1 KiB
Vala
/*
|
|
* Copyright 2017 Michael Gratton <mike@vee.net>
|
|
*
|
|
* This software is licensed under the GNU Lesser General Public License
|
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
|
*/
|
|
|
|
class Geary.IdleManagerTest : Gee.TestCase {
|
|
|
|
public IdleManagerTest() {
|
|
base("Geary.IdleManagerTest");
|
|
add_test("start_reset", start_reset);
|
|
add_test("test_run", test_run);
|
|
}
|
|
|
|
public void start_reset() {
|
|
IdleManager test = new IdleManager(() => { /* noop */ });
|
|
assert(!test.is_running);
|
|
test.schedule();
|
|
assert(test.is_running);
|
|
test.reset();
|
|
assert(!test.is_running);
|
|
}
|
|
|
|
public void test_run() {
|
|
bool did_run = false;
|
|
|
|
IdleManager test = new IdleManager(() => { did_run = true; });
|
|
test.schedule();
|
|
|
|
// There should be at least one event pending
|
|
assert(this.main_loop.pending());
|
|
|
|
// Execute the idle function
|
|
this.main_loop.iteration(true);
|
|
|
|
assert(did_run);
|
|
}
|
|
|
|
}
|