geary/test/engine/util-idle-manager-test.vala
Michael James Gratton 15748cef03 Tidy up unit test infrastructure and mock classes.
* test/api/*.vala: Renamed files that contained mock objects to *-mock.vala,
  not *-test.vala.

* test/testcase.vala: Renamed to test-case.vala for consistency, remove
  TestCase class from Gee package since that's really not true. Clean up
  code for consistency.

* test/meson.build, test/CMakeLists.txt: Split TestCase compilation out
  into a separate test lib.
2018-04-07 09:41:18 +10:00

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 : TestCase {
public IdleManagerTest() {
base("Geary.IdleManagerTest");
add_test("start_reset", start_reset);
add_test("test_run", test_run);
}
public void start_reset() throws Error {
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() throws Error {
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);
}
}