[gnome-break-timer] Updated code style for tests.
- From: Dylan McCall <dylanmccall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-break-timer] Updated code style for tests.
- Date: Thu, 19 Sep 2013 15:52:32 +0000 (UTC)
commit 65a4aa5589d08e5e9f42b8e008a26ab313a90124
Author: Dylan McCall <dylanmccall ubuntu com>
Date: Thu Sep 19 08:52:06 2013 -0700
Updated code style for tests.
.../activity-monitor/activity-monitor_runner.vala | 8 +-
tests/activity-monitor/test_ActivityMonitor.vala | 218 ++++++++--------
tests/breaks/breaks_runner.vala | 8 +-
tests/breaks/test_TimerBreakController.vala | 282 ++++++++++----------
tests/common/common_runner.vala | 8 +-
tests/common/test_NaturalTime.vala | 98 ++++----
tests/tests.vala | 200 +++++++-------
7 files changed, 411 insertions(+), 411 deletions(-)
---
diff --git a/tests/activity-monitor/activity-monitor_runner.vala
b/tests/activity-monitor/activity-monitor_runner.vala
index 25bc6f1..bfc59c9 100644
--- a/tests/activity-monitor/activity-monitor_runner.vala
+++ b/tests/activity-monitor/activity-monitor_runner.vala
@@ -15,8 +15,8 @@
* along with GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
*/
-public static int main(string[] args) {
- var runner = new TestRunner(ref args);
- runner.add(new test_ActivityMonitor());
- return runner.run();
+public static int main (string[] args) {
+ var runner = new TestRunner (ref args);
+ runner.add (new test_ActivityMonitor ());
+ return runner.run ();
}
diff --git a/tests/activity-monitor/test_ActivityMonitor.vala
b/tests/activity-monitor/test_ActivityMonitor.vala
index e03ed13..9ff8ad3 100644
--- a/tests/activity-monitor/test_ActivityMonitor.vala
+++ b/tests/activity-monitor/test_ActivityMonitor.vala
@@ -16,178 +16,178 @@
*/
public class test_ActivityMonitor : TestSuiteWithActivityMonitor {
- public test_ActivityMonitor() {
- new test_simple_idle().add_to(this);
- new test_simple_active().add_to(this);
- new test_lock_idle().add_to(this);
- new test_active_then_idle().add_to(this);
- new test_sleep_and_unlock().add_to(this);
- new test_unlock_signal_activity().add_to(this);
+ public test_ActivityMonitor () {
+ new test_simple_idle ().add_to (this);
+ new test_simple_active ().add_to (this);
+ new test_lock_idle ().add_to (this);
+ new test_active_then_idle ().add_to (this);
+ new test_sleep_and_unlock ().add_to (this);
+ new test_unlock_signal_activity ().add_to (this);
}
}
class test_simple_idle : Object, SimpleTestCase<test_ActivityMonitor> {
- public void run(test_ActivityMonitor context) {
+ public void run (test_ActivityMonitor context) {
context.session_status.virt_is_locked = false;
- context.time_step(false, 0, 0);
- context.time_step(false, 1, 1);
+ context.time_step (false, 0, 0);
+ context.time_step (false, 1, 1);
- assert(context.activity_log.size == 2);
+ assert (context.activity_log.size == 2);
- assert(context.activity_log[0].type == ActivityMonitor.ActivityType.NONE);
- assert(context.activity_log[0].is_active() == false);
- assert(context.activity_log[0].idle_time == 10);
+ assert (context.activity_log[0].type == ActivityMonitor.ActivityType.NONE);
+ assert (context.activity_log[0].is_active () == false);
+ assert (context.activity_log[0].idle_time == 10);
- assert(context.activity_log[1].type == ActivityMonitor.ActivityType.NONE);
- assert(context.activity_log[1].is_active() == false);
- assert(context.activity_log[1].idle_time == context.activity_log[0].idle_time + 1);
+ assert (context.activity_log[1].type == ActivityMonitor.ActivityType.NONE);
+ assert (context.activity_log[1].is_active () == false);
+ assert (context.activity_log[1].idle_time == context.activity_log[0].idle_time + 1);
}
}
class test_simple_active : Object, SimpleTestCase<test_ActivityMonitor> {
- public void run(test_ActivityMonitor context) {
+ public void run (test_ActivityMonitor context) {
context.session_status.virt_is_locked = false;
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- assert(context.activity_log.size == 3);
+ assert (context.activity_log.size == 3);
- assert(context.activity_log[0].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[0].is_active() == true);
- assert(context.activity_log[0].idle_time == 0);
+ assert (context.activity_log[0].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[0].is_active () == true);
+ assert (context.activity_log[0].idle_time == 0);
- assert(context.activity_log[1].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[1].is_active() == true);
- assert(context.activity_log[1].idle_time == 0);
+ assert (context.activity_log[1].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[1].is_active () == true);
+ assert (context.activity_log[1].idle_time == 0);
- assert(context.activity_log[2].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[2].is_active() == true);
- assert(context.activity_log[2].idle_time == 0);
+ assert (context.activity_log[2].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[2].is_active () == true);
+ assert (context.activity_log[2].idle_time == 0);
}
}
class test_active_then_idle : Object, SimpleTestCase<test_ActivityMonitor> {
- public void run(test_ActivityMonitor context) {
+ public void run (test_ActivityMonitor context) {
context.session_status.virt_is_locked = false;
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- context.time_step(false, 1, 1);
+ context.time_step (false, 1, 1);
- context.time_step(false, 1, 1);
+ context.time_step (false, 1, 1);
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- assert(context.activity_log.size == 5);
+ assert (context.activity_log.size == 5);
- assert(context.activity_log[0].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[0].is_active() == true);
- assert(context.activity_log[0].idle_time == 0);
+ assert (context.activity_log[0].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[0].is_active () == true);
+ assert (context.activity_log[0].idle_time == 0);
- assert(context.activity_log[1].type == ActivityMonitor.ActivityType.NONE);
- assert(context.activity_log[1].is_active() == false);
- assert(context.activity_log[1].idle_time == 1);
- assert(context.activity_log[1].time_since_active == 1);
+ assert (context.activity_log[1].type == ActivityMonitor.ActivityType.NONE);
+ assert (context.activity_log[1].is_active () == false);
+ assert (context.activity_log[1].idle_time == 1);
+ assert (context.activity_log[1].time_since_active == 1);
- assert(context.activity_log[2].type == ActivityMonitor.ActivityType.NONE);
- assert(context.activity_log[2].is_active() == false);
- assert(context.activity_log[2].idle_time == 2);
- assert(context.activity_log[2].time_since_active == 2);
+ assert (context.activity_log[2].type == ActivityMonitor.ActivityType.NONE);
+ assert (context.activity_log[2].is_active () == false);
+ assert (context.activity_log[2].idle_time == 2);
+ assert (context.activity_log[2].time_since_active == 2);
- assert(context.activity_log[3].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[3].is_active() == true);
- assert(context.activity_log[3].idle_time == 0);
- assert(context.activity_log[3].time_since_active == 3);
+ assert (context.activity_log[3].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[3].is_active () == true);
+ assert (context.activity_log[3].idle_time == 0);
+ assert (context.activity_log[3].time_since_active == 3);
- assert(context.activity_log[4].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[4].is_active() == true);
- assert(context.activity_log[4].idle_time == 0);
- assert(context.activity_log[4].time_since_active == 1);
+ assert (context.activity_log[4].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[4].is_active () == true);
+ assert (context.activity_log[4].idle_time == 0);
+ assert (context.activity_log[4].time_since_active == 1);
}
}
class test_lock_idle : Object, SimpleTestCase<test_ActivityMonitor> {
- public void run(test_ActivityMonitor context) {
+ public void run (test_ActivityMonitor context) {
context.session_status.virt_is_locked = true;
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- context.time_step(false, 1, 1);
+ context.time_step (false, 1, 1);
- assert(context.activity_log.size == 3);
+ assert (context.activity_log.size == 3);
- assert(context.activity_log[0].type == ActivityMonitor.ActivityType.LOCKED);
- assert(context.activity_log[0].is_active() == false);
- assert(context.activity_log[0].idle_time == 0);
+ assert (context.activity_log[0].type == ActivityMonitor.ActivityType.LOCKED);
+ assert (context.activity_log[0].is_active () == false);
+ assert (context.activity_log[0].idle_time == 0);
- assert(context.activity_log[1].type == ActivityMonitor.ActivityType.LOCKED);
- assert(context.activity_log[1].is_active() == false);
- assert(context.activity_log[1].idle_time == 0);
+ assert (context.activity_log[1].type == ActivityMonitor.ActivityType.LOCKED);
+ assert (context.activity_log[1].is_active () == false);
+ assert (context.activity_log[1].idle_time == 0);
- assert(context.activity_log[2].type == ActivityMonitor.ActivityType.LOCKED);
- assert(context.activity_log[2].is_active() == false);
- assert(context.activity_log[2].idle_time == 1);
+ assert (context.activity_log[2].type == ActivityMonitor.ActivityType.LOCKED);
+ assert (context.activity_log[2].is_active () == false);
+ assert (context.activity_log[2].idle_time == 1);
}
}
class test_sleep_and_unlock : Object, SimpleTestCase<test_ActivityMonitor> {
- public void run(test_ActivityMonitor context) {
+ public void run (test_ActivityMonitor context) {
context.session_status.virt_is_locked = false;
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
context.session_status.virt_is_locked = true;
- context.time_step(true, 120, 2);
+ context.time_step (true, 120, 2);
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
context.session_status.virt_is_locked = false;
- context.time_step(true, 1, 1);
-
- assert(context.activity_log.size == 4);
-
- assert(context.activity_log[0].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[0].is_active() == true);
- assert(context.activity_log[0].idle_time == 0);
- assert(context.activity_log[0].time_correction == 0);
-
- assert(context.activity_log[1].type == ActivityMonitor.ActivityType.SLEEP);
- assert(context.activity_log[1].is_active() == false);
- assert(context.activity_log[1].time_since_active == 120);
- assert(context.activity_log[1].idle_time == 0);
- assert(context.activity_log[1].time_correction == 120-2);
-
- assert(context.activity_log[2].type == ActivityMonitor.ActivityType.LOCKED);
- assert(context.activity_log[2].is_active() == false);
- assert(context.activity_log[2].idle_time == 0);
- assert(context.activity_log[2].time_correction == 0);
-
- assert(context.activity_log[3].type == ActivityMonitor.ActivityType.INPUT);
- assert(context.activity_log[3].is_active() == true);
- assert(context.activity_log[3].idle_time == 0);
- assert(context.activity_log[3].time_correction == 0);
+ context.time_step (true, 1, 1);
+
+ assert (context.activity_log.size == 4);
+
+ assert (context.activity_log[0].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[0].is_active () == true);
+ assert (context.activity_log[0].idle_time == 0);
+ assert (context.activity_log[0].time_correction == 0);
+
+ assert (context.activity_log[1].type == ActivityMonitor.ActivityType.SLEEP);
+ assert (context.activity_log[1].is_active () == false);
+ assert (context.activity_log[1].time_since_active == 120);
+ assert (context.activity_log[1].idle_time == 0);
+ assert (context.activity_log[1].time_correction == 120-2);
+
+ assert (context.activity_log[2].type == ActivityMonitor.ActivityType.LOCKED);
+ assert (context.activity_log[2].is_active () == false);
+ assert (context.activity_log[2].idle_time == 0);
+ assert (context.activity_log[2].time_correction == 0);
+
+ assert (context.activity_log[3].type == ActivityMonitor.ActivityType.INPUT);
+ assert (context.activity_log[3].is_active () == true);
+ assert (context.activity_log[3].idle_time == 0);
+ assert (context.activity_log[3].time_correction == 0);
}
}
class test_unlock_signal_activity : Object, SimpleTestCase<test_ActivityMonitor> {
- public void run(test_ActivityMonitor context) {
+ public void run (test_ActivityMonitor context) {
context.session_status.virt_is_locked = true;
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
- context.session_status.do_unlock();
+ context.session_status.do_unlock ();
- assert(context.activity_log.size == 2);
+ assert (context.activity_log.size == 2);
- assert(context.activity_log[0].type == ActivityMonitor.ActivityType.LOCKED);
- assert(context.activity_log[0].is_active() == false);
- assert(context.activity_log[0].idle_time == 0);
+ assert (context.activity_log[0].type == ActivityMonitor.ActivityType.LOCKED);
+ assert (context.activity_log[0].is_active () == false);
+ assert (context.activity_log[0].idle_time == 0);
- assert(context.activity_log[1].type == ActivityMonitor.ActivityType.UNLOCK);
- assert(context.activity_log[1].is_active() == true);
- assert(context.activity_log[1].idle_time == 0);
+ assert (context.activity_log[1].type == ActivityMonitor.ActivityType.UNLOCK);
+ assert (context.activity_log[1].is_active () == true);
+ assert (context.activity_log[1].idle_time == 0);
}
}
diff --git a/tests/breaks/breaks_runner.vala b/tests/breaks/breaks_runner.vala
index 4bce0f3..dd928c1 100644
--- a/tests/breaks/breaks_runner.vala
+++ b/tests/breaks/breaks_runner.vala
@@ -15,8 +15,8 @@
* along with GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
*/
-public static int main(string[] args) {
- var runner = new TestRunner(ref args);
- runner.add(new test_TimerBreakController());
- return runner.run();
+public static int main (string[] args) {
+ var runner = new TestRunner (ref args);
+ runner.add (new test_TimerBreakController ());
+ return runner.run ();
}
diff --git a/tests/breaks/test_TimerBreakController.vala b/tests/breaks/test_TimerBreakController.vala
index 246c3a5..3cca55c 100644
--- a/tests/breaks/test_TimerBreakController.vala
+++ b/tests/breaks/test_TimerBreakController.vala
@@ -23,298 +23,298 @@ public class test_TimerBreakController : TestSuiteWithActivityMonitor {
public Gee.List<string> break_log;
public Gee.List<string> break_timestep_log;
- public test_TimerBreakController() {
- new test_start_disabled().add_to(this);
- new test_enable_and_idle().add_to(this);
- new test_enable_and_active().add_to(this);
- new test_force_activate().add_to(this);
- new test_postpone().add_to(this);
- new test_serialize().add_to(this);
+ public test_TimerBreakController () {
+ new test_start_disabled ().add_to (this);
+ new test_enable_and_idle ().add_to (this);
+ new test_enable_and_active ().add_to (this);
+ new test_force_activate ().add_to (this);
+ new test_postpone ().add_to (this);
+ new test_serialize ().add_to (this);
}
- public override void setup() {
- this.break_log = new Gee.ArrayList<string>();
- this.break_timestep_log = new Gee.ArrayList<string>();
+ public override void setup () {
+ this.break_log = new Gee.ArrayList<string> ();
+ this.break_timestep_log = new Gee.ArrayList<string> ();
- base.setup();
+ base.setup ();
}
- private void log_break_message(string message) {
- this.break_log.add(message);
- this.break_timestep_log.add(message);
+ private void log_break_message (string message) {
+ this.break_log.add (message);
+ this.break_timestep_log.add (message);
}
- public Json.Object save_state() {
- Json.Object root_object = new Json.Object();
- root_object.set_object_member("break_controller", this.break_controller.serialize());
- root_object.set_object_member("activity_monitor_backend",
this.activity_monitor_backend.serialize());
- root_object.set_object_member("activity_monitor", this.activity_monitor.serialize());
+ public Json.Object save_state () {
+ Json.Object root_object = new Json.Object ();
+ root_object.set_object_member ("break_controller", this.break_controller.serialize ());
+ root_object.set_object_member ("activity_monitor_backend",
this.activity_monitor_backend.serialize ());
+ root_object.set_object_member ("activity_monitor", this.activity_monitor.serialize ());
return root_object;
}
- public void restore_state(ref Json.Object root_object) {
- this.refresh_environment();
+ public void restore_state (ref Json.Object root_object) {
+ this.refresh_environment ();
- Json.Object break_controller_json = root_object.get_object_member("break_controller");
- this.break_controller.deserialize(ref break_controller_json);
+ Json.Object break_controller_json = root_object.get_object_member ("break_controller");
+ this.break_controller.deserialize (ref break_controller_json);
- Json.Object activity_monitor_backend_json =
root_object.get_object_member("activity_monitor_backend");
- this.activity_monitor_backend.deserialize(ref activity_monitor_backend_json);
+ Json.Object activity_monitor_backend_json = root_object.get_object_member
("activity_monitor_backend");
+ this.activity_monitor_backend.deserialize (ref activity_monitor_backend_json);
- Json.Object activity_monitor_json = root_object.get_object_member("activity_monitor");
- this.activity_monitor.deserialize(ref activity_monitor_json);
+ Json.Object activity_monitor_json = root_object.get_object_member ("activity_monitor");
+ this.activity_monitor.deserialize (ref activity_monitor_json);
- this.activity_monitor.poll_activity();
+ this.activity_monitor.poll_activity ();
}
- public override void refresh_environment() {
- base.refresh_environment();
+ public override void refresh_environment () {
+ base.refresh_environment ();
- this.break_log.clear();
- this.break_timestep_log.clear();
+ this.break_log.clear ();
+ this.break_timestep_log.clear ();
- this.break_controller = new testable_TimerBreakController(this.activity_monitor);
+ this.break_controller = new testable_TimerBreakController (this.activity_monitor);
this.break_controller.interval = DEFAULT_INTERVAL;
this.break_controller.duration = DEFAULT_DURATION;
- this.break_controller.set_enabled(true);
+ this.break_controller.set_enabled (true);
- this.break_controller.enabled.connect(() => { this.log_break_message("enabled"); } );
- this.break_controller.disabled.connect(() => { this.log_break_message("disabled"); } );
- this.break_controller.warned.connect(() => { this.log_break_message("warned"); } );
- this.break_controller.unwarned.connect(() => { this.log_break_message("unwarned"); } );
- this.break_controller.activated.connect(() => { this.log_break_message("activated"); } );
- this.break_controller.finished.connect(() => { this.log_break_message("finished"); } );
+ this.break_controller.enabled.connect ( () => { this.log_break_message ("enabled"); } );
+ this.break_controller.disabled.connect ( () => { this.log_break_message ("disabled"); } );
+ this.break_controller.warned.connect ( () => { this.log_break_message ("warned"); } );
+ this.break_controller.unwarned.connect ( () => { this.log_break_message ("unwarned"); } );
+ this.break_controller.activated.connect ( () => { this.log_break_message ("activated"); } );
+ this.break_controller.finished.connect ( () => { this.log_break_message ("finished"); } );
- this.break_controller.counting.connect(() => { this.log_break_message("counting"); } );
- this.break_controller.delayed.connect(() => { this.log_break_message("delayed"); } );
+ this.break_controller.counting.connect ( () => { this.log_break_message ("counting"); } );
+ this.break_controller.delayed.connect ( () => { this.log_break_message ("delayed"); } );
}
- public override void time_step(bool is_active, int real_seconds, int monotonic_seconds) {
- this.break_timestep_log.clear();
- base.time_step(is_active, real_seconds, monotonic_seconds);
- this.break_controller.time_step(real_seconds, monotonic_seconds);
+ public override void time_step (bool is_active, int real_seconds, int monotonic_seconds) {
+ this.break_timestep_log.clear ();
+ base.time_step (is_active, real_seconds, monotonic_seconds);
+ this.break_controller.time_step (real_seconds, monotonic_seconds);
}
}
public class testable_TimerBreakController : TimerBreakController {
- public testable_TimerBreakController(ActivityMonitor activity_monitor) {
- base(activity_monitor, 0);
+ public testable_TimerBreakController (ActivityMonitor activity_monitor) {
+ base (activity_monitor, 0);
}
- public void time_step(int real_seconds, int monotonic_seconds) {
- this.countdowns_timeout.run_once();
+ public void time_step (int real_seconds, int monotonic_seconds) {
+ this.countdowns_timeout.run_once ();
}
- public void assert_timers(int? starts_in, int? remaining) {
- if (starts_in != null) assert(this.starts_in() == starts_in);
- if (remaining != null) assert(this.get_time_remaining() == remaining);
+ public void assert_timers (int? starts_in, int? remaining) {
+ if (starts_in != null) assert (this.starts_in () == starts_in);
+ if (remaining != null) assert (this.get_time_remaining () == remaining);
}
}
class test_start_disabled : Object, SimpleTestCase<test_TimerBreakController> {
- public void run(test_TimerBreakController context) {
- context.break_controller.set_enabled(false);
+ public void run (test_TimerBreakController context) {
+ context.break_controller.set_enabled (false);
- assert(context.break_controller.is_enabled() == false);
- assert(context.break_controller.is_active() == false);
- assert(context.break_controller.get_seconds_since_start() == 0);
- context.break_controller.assert_timers(test_TimerBreakController.DEFAULT_INTERVAL,
test_TimerBreakController.DEFAULT_DURATION);
+ assert (context.break_controller.is_enabled () == false);
+ assert (context.break_controller.is_active () == false);
+ assert (context.break_controller.get_seconds_since_start () == 0);
+ context.break_controller.assert_timers (test_TimerBreakController.DEFAULT_INTERVAL,
test_TimerBreakController.DEFAULT_DURATION);
- context.break_controller.activate();
+ context.break_controller.activate ();
- assert(context.break_controller.is_enabled() == false);
- assert(context.break_log.last() == "disabled");
+ assert (context.break_controller.is_enabled () == false);
+ assert (context.break_log.last () == "disabled");
}
}
class test_enable_and_idle : Object, SimpleTestCase<test_TimerBreakController> {
- public void run(test_TimerBreakController context) {
+ public void run (test_TimerBreakController context) {
// break_controller is enabled by default (emulating the behaviour of BreakManager with
default settings)
- assert(context.break_controller.is_enabled());
+ assert (context.break_controller.is_enabled ());
int expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
expected_starts_in -= 1;
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
for (int step = 0; step <= test_TimerBreakController.DEFAULT_DURATION; step++) {
- context.time_step(false, 1, 1);
- assert(context.break_timestep_log[0] == "counting");
+ context.time_step (false, 1, 1);
+ assert (context.break_timestep_log[0] == "counting");
if (step == test_TimerBreakController.DEFAULT_DURATION) {
- assert(context.break_timestep_log[1] == "finished");
+ assert (context.break_timestep_log[1] == "finished");
}
}
expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
for (int step = 0; step < test_TimerBreakController.DEFAULT_INTERVAL; step++) {
- context.time_step(false, 1, 1);
- assert(context.break_timestep_log[0] == "counting");
+ context.time_step (false, 1, 1);
+ assert (context.break_timestep_log[0] == "counting");
}
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
}
}
class test_enable_and_active : Object, SimpleTestCase<test_TimerBreakController> {
- public void run(test_TimerBreakController context) {
+ public void run (test_TimerBreakController context) {
int expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
var active_time_1 = 20;
for (int step = 0; step < active_time_1; step++) {
- context.time_step(true, 1, 1);
- assert(context.break_timestep_log[0] == "delayed");
+ context.time_step (true, 1, 1);
+ assert (context.break_timestep_log[0] == "delayed");
}
expected_starts_in -= active_time_1;
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
var idle_time_1 = 10;
for (int step = 0; step <= idle_time_1; step++) {
- context.time_step(false, 1, 1);
- assert(context.break_timestep_log[0] == "counting");
+ context.time_step (false, 1, 1);
+ assert (context.break_timestep_log[0] == "counting");
}
expected_starts_in -= 1;
expected_remaining -= idle_time_1;
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
var active_time_2 = test_TimerBreakController.DEFAULT_INTERVAL - active_time_1;
var warn_step = active_time_2 - test_TimerBreakController.DEFAULT_DURATION - 1;
for (int step = 0; step < active_time_2; step++) {
- context.time_step(true, 1, 1);
- assert(context.break_timestep_log[0] == "delayed");
+ context.time_step (true, 1, 1);
+ assert (context.break_timestep_log[0] == "delayed");
if (step == warn_step) {
- assert(context.break_timestep_log[1] == "warned");
+ assert (context.break_timestep_log[1] == "warned");
} else if (step == active_time_2-1) {
- assert(context.break_timestep_log[1] == "activated");
+ assert (context.break_timestep_log[1] == "activated");
}
}
expected_starts_in = 0;
expected_remaining -= 1;
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
for (int step = 0; step < 5; step++) {
- context.time_step(false, 1, 1);
- assert(context.break_timestep_log[0] == "counting");
+ context.time_step (false, 1, 1);
+ assert (context.break_timestep_log[0] == "counting");
}
expected_remaining -= 5;
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
for (int step = 0; step < expected_remaining; step++) {
- context.time_step(false, 1, 1);
- assert(context.break_timestep_log[0] == "counting");
+ context.time_step (false, 1, 1);
+ assert (context.break_timestep_log[0] == "counting");
if (step == expected_remaining-1) {
- assert(context.break_timestep_log[1] == "finished");
+ assert (context.break_timestep_log[1] == "finished");
}
}
expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
}
}
class test_force_activate : Object, SimpleTestCase<test_TimerBreakController> {
- public void run(test_TimerBreakController context) {
+ public void run (test_TimerBreakController context) {
int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
- context.break_controller.activate();
- assert(context.break_log.last() == "activated");
+ context.break_controller.activate ();
+ assert (context.break_log.last () == "activated");
- assert(context.break_controller.get_seconds_since_start() == 0);
- context.break_controller.assert_timers(null, expected_remaining);
+ assert (context.break_controller.get_seconds_since_start () == 0);
+ context.break_controller.assert_timers (null, expected_remaining);
for (int step = 0; step < 10; step++) {
- context.time_step(false, 1, 1);
+ context.time_step (false, 1, 1);
}
expected_remaining -= 10;
- context.break_controller.assert_timers(null, expected_remaining);
+ context.break_controller.assert_timers (null, expected_remaining);
}
}
class test_postpone : Object, SimpleTestCase<test_TimerBreakController> {
- public void run(test_TimerBreakController context) {
+ public void run (test_TimerBreakController context) {
int expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
- context.break_controller.activate();
+ context.break_controller.activate ();
for (int step = 0; step < 10; step++) {
- context.time_step(false, 1, 1);
+ context.time_step (false, 1, 1);
}
expected_remaining -= 10;
- context.break_controller.assert_timers(null, expected_remaining);
- assert(context.break_controller.get_seconds_since_start() == 10);
+ context.break_controller.assert_timers (null, expected_remaining);
+ assert (context.break_controller.get_seconds_since_start () == 10);
- context.break_controller.postpone(60);
+ context.break_controller.postpone (60);
expected_starts_in = 60;
expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
- assert(context.break_controller.is_active() == false);
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ assert (context.break_controller.is_active () == false);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
for (int step = 0; step < expected_starts_in; step++) {
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
if (step == expected_starts_in-1) {
- assert(context.break_timestep_log[1] == "activated");
+ assert (context.break_timestep_log[1] == "activated");
}
}
expected_starts_in = 0;
expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
- assert(context.break_controller.is_active() == true);
- context.break_controller.assert_timers(expected_starts_in, expected_remaining);
+ assert (context.break_controller.is_active () == true);
+ context.break_controller.assert_timers (expected_starts_in, expected_remaining);
}
}
class test_serialize : Object, SimpleTestCase<test_TimerBreakController> {
- public void run(test_TimerBreakController context) {
- var initial_json = context.save_state();
+ public void run (test_TimerBreakController context) {
+ var initial_json = context.save_state ();
for (int step = 0; step < 50; step++) {
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
}
- assert(context.break_controller.is_active() == false);
- context.break_controller.assert_timers(test_TimerBreakController.DEFAULT_INTERVAL - 50,
test_TimerBreakController.DEFAULT_DURATION);
- var active_waiting_json = context.save_state();
+ assert (context.break_controller.is_active () == false);
+ context.break_controller.assert_timers (test_TimerBreakController.DEFAULT_INTERVAL - 50,
test_TimerBreakController.DEFAULT_DURATION);
+ var active_waiting_json = context.save_state ();
for (int step = 50; step < test_TimerBreakController.DEFAULT_INTERVAL; step++) {
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
}
- assert(context.break_controller.is_active() == true);
- context.break_controller.assert_timers(0, test_TimerBreakController.DEFAULT_DURATION);
- var activated_json = context.save_state();
+ assert (context.break_controller.is_active () == true);
+ context.break_controller.assert_timers (0, test_TimerBreakController.DEFAULT_DURATION);
+ var activated_json = context.save_state ();
for (int step = 0; step < 10; step++) {
- context.time_step(false, 1, 1);
+ context.time_step (false, 1, 1);
}
- assert(context.break_controller.is_active() == true);
- context.break_controller.assert_timers(0, test_TimerBreakController.DEFAULT_DURATION-10);
- var counting_json = context.save_state();
+ assert (context.break_controller.is_active () == true);
+ context.break_controller.assert_timers (0, test_TimerBreakController.DEFAULT_DURATION-10);
+ var counting_json = context.save_state ();
- context.time_step(true, 0, 0);
+ context.time_step (true, 0, 0);
for (int step = 0; step < 10; step++) {
- context.time_step(true, 1, 1);
+ context.time_step (true, 1, 1);
}
- assert(context.break_controller.is_active() == true);
- context.break_controller.assert_timers(0, test_TimerBreakController.DEFAULT_DURATION-10);
+ assert (context.break_controller.is_active () == true);
+ context.break_controller.assert_timers (0, test_TimerBreakController.DEFAULT_DURATION-10);
- context.restore_state(ref initial_json);
- assert(context.break_controller.is_active() == false);
- context.break_controller.assert_timers(test_TimerBreakController.DEFAULT_INTERVAL,
test_TimerBreakController.DEFAULT_DURATION);
+ context.restore_state (ref initial_json);
+ assert (context.break_controller.is_active () == false);
+ context.break_controller.assert_timers (test_TimerBreakController.DEFAULT_INTERVAL,
test_TimerBreakController.DEFAULT_DURATION);
- context.restore_state(ref counting_json);
- assert(context.break_controller.is_active() == true);
- context.break_controller.assert_timers(0, test_TimerBreakController.DEFAULT_DURATION-10);
+ context.restore_state (ref counting_json);
+ assert (context.break_controller.is_active () == true);
+ context.break_controller.assert_timers (0, test_TimerBreakController.DEFAULT_DURATION-10);
- context.restore_state(ref active_waiting_json);
- assert(context.break_controller.is_active() == false);
+ context.restore_state (ref active_waiting_json);
+ assert (context.break_controller.is_active () == false);
// The state was saved more than break duration ago, so it is immediately finished.
- context.break_controller.assert_timers(test_TimerBreakController.DEFAULT_INTERVAL,
test_TimerBreakController.DEFAULT_DURATION);
+ context.break_controller.assert_timers (test_TimerBreakController.DEFAULT_INTERVAL,
test_TimerBreakController.DEFAULT_DURATION);
- context.restore_state(ref activated_json);
- assert(context.break_controller.is_active() == true);
+ context.restore_state (ref activated_json);
+ assert (context.break_controller.is_active () == true);
// 20 seconds have passed since the break was activated. The application should assume all
this time was spent idle.
// Note that this will not happen with a gap smaller than 10+5 seconds, because
ActivityMonitor ignores detected
// "sleep" time below 5 seconds + detected idle time (which is, initially, 10 seconds).
- context.break_controller.assert_timers(0, test_TimerBreakController.DEFAULT_DURATION-20);
+ context.break_controller.assert_timers (0, test_TimerBreakController.DEFAULT_DURATION-20);
}
}
diff --git a/tests/common/common_runner.vala b/tests/common/common_runner.vala
index daccb62..d87cd27 100644
--- a/tests/common/common_runner.vala
+++ b/tests/common/common_runner.vala
@@ -15,8 +15,8 @@
* along with GNOME Break Timer. If not, see <http://www.gnu.org/licenses/>.
*/
-public static int main(string[] args) {
- var runner = new TestRunner(ref args);
- runner.add(new test_NaturalTime());
- return runner.run();
+public static int main (string[] args) {
+ var runner = new TestRunner (ref args);
+ runner.add (new test_NaturalTime ());
+ return runner.run ();
}
diff --git a/tests/common/test_NaturalTime.vala b/tests/common/test_NaturalTime.vala
index 9013b7e..3aba2b2 100644
--- a/tests/common/test_NaturalTime.vala
+++ b/tests/common/test_NaturalTime.vala
@@ -18,95 +18,95 @@
public class test_NaturalTime : SimpleTestSuite {
public NaturalTime natural_time;
- public test_NaturalTime() {
- new test_get_label_for_seconds().add_to(this);
- new test_get_simplest_label_for_seconds().add_to(this);
- new test_get_countdown_for_seconds().add_to(this);
- new test_get_countdown_for_seconds_with_start().add_to(this);
+ public test_NaturalTime () {
+ new test_get_label_for_seconds ().add_to (this);
+ new test_get_simplest_label_for_seconds ().add_to (this);
+ new test_get_countdown_for_seconds ().add_to (this);
+ new test_get_countdown_for_seconds_with_start ().add_to (this);
}
- public override void setup() {
+ public override void setup () {
this.natural_time = NaturalTime.instance;
}
}
class test_get_label_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
- public void run(test_NaturalTime context) {
+ public void run (test_NaturalTime context) {
int value_60;
- var label_60 = context.natural_time.get_label_for_seconds(60, out value_60);
- assert(label_60 == "%d minute".printf(1));
- assert(value_60 == 1);
+ var label_60 = context.natural_time.get_label_for_seconds (60, out value_60);
+ assert (label_60 == "%d minute".printf (1));
+ assert (value_60 == 1);
int value_61;
- var label_61 = context.natural_time.get_label_for_seconds(61, out value_61);
- assert(label_61 == "%d seconds".printf(61));
- assert(value_61 == 61);
+ var label_61 = context.natural_time.get_label_for_seconds (61, out value_61);
+ assert (label_61 == "%d seconds".printf (61));
+ assert (value_61 == 61);
}
}
class test_get_simplest_label_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
- public void run(test_NaturalTime context) {
+ public void run (test_NaturalTime context) {
int value_60;
- var label_60 = context.natural_time.get_simplest_label_for_seconds(60, out value_60);
- assert(label_60 == "%d minute".printf(1));
- assert(value_60 == 1);
+ var label_60 = context.natural_time.get_simplest_label_for_seconds (60, out value_60);
+ assert (label_60 == "%d minute".printf (1));
+ assert (value_60 == 1);
int value_61;
- var label_61 = context.natural_time.get_simplest_label_for_seconds(61, out value_61);
- assert(label_61 == "%d minute".printf(1));
- assert(value_61 == 1);
+ var label_61 = context.natural_time.get_simplest_label_for_seconds (61, out value_61);
+ assert (label_61 == "%d minute".printf (1));
+ assert (value_61 == 1);
}
}
class test_get_countdown_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
- public void run(test_NaturalTime context) {
+ public void run (test_NaturalTime context) {
int value_90;
- var label_90 = context.natural_time.get_countdown_for_seconds(90, out value_90);
- assert(label_90 == "%d minutes".printf(2));
- assert(value_90 == 2);
+ var label_90 = context.natural_time.get_countdown_for_seconds (90, out value_90);
+ assert (label_90 == "%d minutes".printf (2));
+ assert (value_90 == 2);
int value_60;
- var label_60 = context.natural_time.get_countdown_for_seconds(60, out value_60);
- assert(label_60 == "%d minute".printf(1));
- assert(value_60 == 1);
+ var label_60 = context.natural_time.get_countdown_for_seconds (60, out value_60);
+ assert (label_60 == "%d minute".printf (1));
+ assert (value_60 == 1);
int value_55;
- var label_55 = context.natural_time.get_countdown_for_seconds(55, out value_55);
- assert(label_55 == "%d minute".printf(1));
- assert(value_55 == 1);
+ var label_55 = context.natural_time.get_countdown_for_seconds (55, out value_55);
+ assert (label_55 == "%d minute".printf (1));
+ assert (value_55 == 1);
int value_42;
- var label_42 = context.natural_time.get_countdown_for_seconds(42, out value_42);
- assert(label_42 == "%d seconds".printf(50));
- assert(value_42 == 50);
+ var label_42 = context.natural_time.get_countdown_for_seconds (42, out value_42);
+ assert (label_42 == "%d seconds".printf (50));
+ assert (value_42 == 50);
int value_8;
- var label_8 = context.natural_time.get_countdown_for_seconds(8, out value_8);
- assert(label_8 == "%d seconds".printf(8));
- assert(value_8 == 8);
+ var label_8 = context.natural_time.get_countdown_for_seconds (8, out value_8);
+ assert (label_8 == "%d seconds".printf (8));
+ assert (value_8 == 8);
}
}
class test_get_countdown_for_seconds_with_start : Object, SimpleTestCase<test_NaturalTime> {
- public void run(test_NaturalTime context) {
+ public void run (test_NaturalTime context) {
int value_90;
- var label_90 = context.natural_time.get_countdown_for_seconds_with_start(90, 90, out
value_90);
- assert(label_90 == "%d minute".printf(1));
- assert(value_90 == 1);
+ var label_90 = context.natural_time.get_countdown_for_seconds_with_start (90, 90, out
value_90);
+ assert (label_90 == "%d minute".printf (1));
+ assert (value_90 == 1);
int value_60;
- var label_60 = context.natural_time.get_countdown_for_seconds_with_start(60, 55, out
value_60);
- assert(label_60 == "%d seconds".printf(55));
- assert(value_60 == 55);
+ var label_60 = context.natural_time.get_countdown_for_seconds_with_start (60, 55, out
value_60);
+ assert (label_60 == "%d seconds".printf (55));
+ assert (value_60 == 55);
int value_55;
- var label_55 = context.natural_time.get_countdown_for_seconds_with_start(55, 55, out
value_55);
- assert(label_55 == "%d seconds".printf(55));
- assert(value_55 == 55);
+ var label_55 = context.natural_time.get_countdown_for_seconds_with_start (55, 55, out
value_55);
+ assert (label_55 == "%d seconds".printf (55));
+ assert (value_55 == 55);
int value_51;
- var label_51 = context.natural_time.get_countdown_for_seconds_with_start(51, 55, out
value_51);
- assert(label_51 == "%d seconds".printf(55));
- assert(value_51 == 55);
+ var label_51 = context.natural_time.get_countdown_for_seconds_with_start (51, 55, out
value_51);
+ assert (label_51 == "%d seconds".printf (55));
+ assert (value_51 == 55);
}
}
diff --git a/tests/tests.vala b/tests/tests.vala
index 6bf6689..fdd4497 100644
--- a/tests/tests.vala
+++ b/tests/tests.vala
@@ -26,36 +26,36 @@ public abstract class SimpleTestSuite : Object {
private SimpleTestSuite test_suite;
private SimpleTestCase<SimpleTestSuite> test;
- public Adaptor(SimpleTestSuite test_suite, owned SimpleTestCase<SimpleTestSuite> test) {
+ public Adaptor (SimpleTestSuite test_suite, owned SimpleTestCase<SimpleTestSuite> test) {
this.test_suite = test_suite;
this.test = (owned)test;
}
- private string get_short_name() {
- string base_name = this.test_suite.get_name();
- string test_full_name = this.test.get_name();
- if (test_full_name.has_prefix(base_name)) {
- return test_full_name.splice(0, base_name.length);
+ private string get_short_name () {
+ string base_name = this.test_suite.get_name ();
+ string test_full_name = this.test.get_name ();
+ if (test_full_name.has_prefix (base_name)) {
+ return test_full_name.splice (0, base_name.length);
} else {
return test_full_name;
}
}
- private void setup(void *fixture) {
- this.test_suite.setup();
+ private void setup (void *fixture) {
+ this.test_suite.setup ();
}
- private void run(void *fixture) {
- this.test.run(this.test_suite);
+ private void run (void *fixture) {
+ this.test.run (this.test_suite);
}
- private void teardown(void *fixture) {
- this.test_suite.teardown();
+ private void teardown (void *fixture) {
+ this.test_suite.teardown ();
}
- public GLib.TestCase get_g_test_case() {
- return new GLib.TestCase(
- this.get_short_name(),
+ public GLib.TestCase get_g_test_case () {
+ return new GLib.TestCase (
+ this.get_short_name (),
(TestFixtureFunc)this.setup,
(TestFixtureFunc)this.run,
(TestFixtureFunc)this.teardown
@@ -63,45 +63,45 @@ public abstract class SimpleTestSuite : Object {
}
}
- public SimpleTestSuite() {
- var name = this.get_name();
- this.g_test_suite = new GLib.TestSuite(name);
+ public SimpleTestSuite () {
+ var name = this.get_name ();
+ this.g_test_suite = new GLib.TestSuite (name);
}
- public void add_to(GLib.TestSuite parent) {
- parent.add_suite(this.g_test_suite);
+ public void add_to (GLib.TestSuite parent) {
+ parent.add_suite (this.g_test_suite);
}
- public GLib.TestSuite get_g_test_suite() {
+ public GLib.TestSuite get_g_test_suite () {
return this.g_test_suite;
}
- public string get_name() {
- return this.get_type().name();
+ public string get_name () {
+ return this.get_type ().name ();
}
- public void add_test(owned SimpleTestCase test) {
- var adaptor = new Adaptor(this, (owned)test);
+ public void add_test (owned SimpleTestCase test) {
+ var adaptor = new Adaptor (this, (owned)test);
this.adaptors += adaptor;
- this.g_test_suite.add(adaptor.get_g_test_case());
+ this.g_test_suite.add (adaptor.get_g_test_case ());
}
- public virtual void setup() {
+ public virtual void setup () {
}
- public virtual void teardown() {
+ public virtual void teardown () {
}
}
public interface SimpleTestCase<T> : Object {
- public abstract void run(T context);
+ public abstract void run (T context);
- public void add_to(SimpleTestSuite test_suite) {
- test_suite.add_test(this);
+ public void add_to (SimpleTestSuite test_suite) {
+ test_suite.add_test (this);
}
- public string get_name() {
- return this.get_type().name();
+ public string get_name () {
+ return this.get_type ().name ();
}
}
@@ -112,83 +112,83 @@ class TestRunner : Object {
private File tmp_dir;
const string SCHEMA_FILE_NAME = "org.gnome.break-timer.gschema.xml";
- public TestRunner(ref unowned string[] args, GLib.TestSuite? root_suite = null) {
- GLib.Test.init(ref args);
+ public TestRunner (ref unowned string[] args, GLib.TestSuite? root_suite = null) {
+ GLib.Test.init (ref args);
if (root_suite == null) {
- this.root_suite = GLib.TestSuite.get_root();
+ this.root_suite = GLib.TestSuite.get_root ();
} else {
this.root_suite = root_suite;
}
}
- public void add(SimpleTestSuite suite) {
- suite.add_to(this.root_suite);
+ public void add (SimpleTestSuite suite) {
+ suite.add_to (this.root_suite);
}
- public virtual void global_setup() {
+ public virtual void global_setup () {
Environment.set_variable ("LANGUAGE", "C", true);
try {
- var tmp_path = DirUtils.make_tmp("gnome-break-timer-test-XXXXXX");
- tmp_dir = File.new_for_path(tmp_path);
+ var tmp_path = DirUtils.make_tmp ("gnome-break-timer-test-XXXXXX");
+ tmp_dir = File.new_for_path (tmp_path);
} catch (Error e) {
- GLib.warning("Error creating temporary directory for test files:
%s".printf(e.message));
+ GLib.warning ("Error creating temporary directory for test files: %s".printf
(e.message));
}
- string target_data_path = Path.build_filename(tmp_dir.get_path(), "share");
- string target_schema_path = Path.build_filename(tmp_dir.get_path(), "share", "glib-2.0",
"schemas");
+ string target_data_path = Path.build_filename (tmp_dir.get_path (), "share");
+ string target_schema_path = Path.build_filename (tmp_dir.get_path (), "share", "glib-2.0",
"schemas");
- Environment.set_variable("GSETTINGS_BACKEND", "memory", true);
+ Environment.set_variable ("GSETTINGS_BACKEND", "memory", true);
- var original_data_dirs = Environment.get_variable("XDG_DATA_DIRS");
- Environment.set_variable("XDG_DATA_DIRS", "%s:%s".printf(target_data_path,
original_data_dirs), true);
+ var original_data_dirs = Environment.get_variable ("XDG_DATA_DIRS");
+ Environment.set_variable ("XDG_DATA_DIRS", "%s:%s".printf (target_data_path,
original_data_dirs), true);
- File source_schema_file = File.new_for_path(
- Path.build_filename(get_top_builddir(), "data", SCHEMA_FILE_NAME)
+ File source_schema_file = File.new_for_path (
+ Path.build_filename (get_top_builddir (), "data", SCHEMA_FILE_NAME)
);
- File target_schema_dir = File.new_for_path(target_schema_path);
+ File target_schema_dir = File.new_for_path (target_schema_path);
try {
- target_schema_dir.make_directory_with_parents();
+ target_schema_dir.make_directory_with_parents ();
} catch (Error e) {
- GLib.warning("Error creating directory for schema files: %s", e.message);
+ GLib.warning ("Error creating directory for schema files: %s", e.message);
}
- File target_schema_file = File.new_for_path(
- Path.build_filename(target_schema_dir.get_path(), SCHEMA_FILE_NAME)
+ File target_schema_file = File.new_for_path (
+ Path.build_filename (target_schema_dir.get_path (), SCHEMA_FILE_NAME)
);
try {
- source_schema_file.copy(target_schema_file, FileCopyFlags.OVERWRITE);
+ source_schema_file.copy (target_schema_file, FileCopyFlags.OVERWRITE);
} catch (Error e) {
- GLib.warning("Error copying schema file: %s", e.message);
+ GLib.warning ("Error copying schema file: %s", e.message);
}
- int compile_schemas_result = Posix.system("glib-compile-schemas
%s".printf(target_schema_path));
+ int compile_schemas_result = Posix.system ("glib-compile-schemas %s".printf
(target_schema_path));
if (compile_schemas_result != 0) {
- GLib.warning("Could not compile schemas in %s", target_schema_path);
+ GLib.warning ("Could not compile schemas in %s", target_schema_path);
}
}
- public virtual void global_teardown() {
+ public virtual void global_teardown () {
if (tmp_dir != null) {
- var tmp_dir_path = tmp_dir.get_path();
- int delete_tmp_result = Posix.system("rm -rf %s".printf(tmp_dir_path));
+ var tmp_dir_path = tmp_dir.get_path ();
+ int delete_tmp_result = Posix.system ("rm -rf %s".printf (tmp_dir_path));
if (delete_tmp_result != 0) {
- GLib.warning("Could not delete temporary files in %s", tmp_dir_path);
+ GLib.warning ("Could not delete temporary files in %s", tmp_dir_path);
}
}
}
- public int run() {
- this.global_setup();
- GLib.Test.run();
- this.global_teardown();
+ public int run () {
+ this.global_setup ();
+ GLib.Test.run ();
+ this.global_teardown ();
return 0;
}
- private static string get_top_builddir() {
- var builddir = Environment.get_variable("top_builddir");
+ private static string get_top_builddir () {
+ var builddir = Environment.get_variable ("top_builddir");
if (builddir == null) builddir = "..";
return builddir;
}
@@ -206,45 +206,45 @@ public class TestSuiteWithActivityMonitor : SimpleTestSuite {
public const int64 START_REAL_TIME = 100000 * Util.MICROSECONDS_IN_SECONDS;
public const int64 START_MONOTONIC_TIME = 50 * Util.MICROSECONDS_IN_SECONDS;
- public override void setup() {
- base.setup();
+ public override void setup () {
+ base.setup ();
Util._do_override_time = true;
Util._override_real_time = START_REAL_TIME;
Util._override_monotonic_time = START_MONOTONIC_TIME;
- this.activity_log = new Gee.ArrayList<ActivityMonitor.UserActivity?>();
- this.refresh_environment();
+ this.activity_log = new Gee.ArrayList<ActivityMonitor.UserActivity?> ();
+ this.refresh_environment ();
}
- public override void teardown() {
+ public override void teardown () {
Util._do_override_time = false;
Util._override_real_time = 0;
Util._override_monotonic_time = 0;
}
- public virtual void refresh_environment() {
+ public virtual void refresh_environment () {
// We keep _override_real_time as it is, because time never goes backward within a test case
Util._override_monotonic_time = START_MONOTONIC_TIME;
- this.activity_log.clear();
- this.activity_monitor_backend = new testable_ActivityMonitorBackend();
- this.session_status = new testable_SessionStatus();
- this.activity_monitor = new ActivityMonitor(session_status, activity_monitor_backend);
- this.activity_monitor.detected_idle.connect(this.log_activity);
- this.activity_monitor.detected_activity.connect(this.log_activity);
- this.activity_monitor.stop();
+ this.activity_log.clear ();
+ this.activity_monitor_backend = new testable_ActivityMonitorBackend ();
+ this.session_status = new testable_SessionStatus ();
+ this.activity_monitor = new ActivityMonitor (session_status, activity_monitor_backend);
+ this.activity_monitor.detected_idle.connect (this.log_activity);
+ this.activity_monitor.detected_activity.connect (this.log_activity);
+ this.activity_monitor.stop ();
}
- public virtual void time_step(bool is_active, int real_seconds, int monotonic_seconds) {
+ public virtual void time_step (bool is_active, int real_seconds, int monotonic_seconds) {
Util._override_real_time += real_seconds * Util.MICROSECONDS_IN_SECONDS;
Util._override_monotonic_time += monotonic_seconds * Util.MICROSECONDS_IN_SECONDS;
- if (is_active) this.activity_monitor_backend.push_activity();
- this.activity_monitor.poll_activity();
+ if (is_active) this.activity_monitor_backend.push_activity ();
+ this.activity_monitor.poll_activity ();
}
- private void log_activity(ActivityMonitor.UserActivity activity) {
- this.activity_log.add(activity);
+ private void log_activity (ActivityMonitor.UserActivity activity) {
+ this.activity_log.add (activity);
}
}
@@ -255,16 +255,16 @@ public class testable_ActivityMonitorBackend : ActivityMonitorBackend {
public int64 last_event_time = 0;
public int64 start_time = 0;
- public testable_ActivityMonitorBackend() {
- this.start_time = Util.get_monotonic_time_seconds() - 10;
+ public testable_ActivityMonitorBackend () {
+ this.start_time = Util.get_monotonic_time_seconds () - 10;
}
- public void push_activity() {
- this.last_event_time = Util.get_monotonic_time_seconds();
+ public void push_activity () {
+ this.last_event_time = Util.get_monotonic_time_seconds ();
}
- protected override int time_since_last_event() {
- int64 now_monotonic = Util.get_monotonic_time_seconds();
+ protected override int time_since_last_event () {
+ int64 now_monotonic = Util.get_monotonic_time_seconds ();
int64 event_time = this.last_event_time;
if (event_time == 0) event_time = this.start_time;
return (int) (now_monotonic - event_time);
@@ -274,25 +274,25 @@ public class testable_ActivityMonitorBackend : ActivityMonitorBackend {
public class testable_SessionStatus : Object, ISessionStatus {
public bool virt_is_locked = false;
- public void do_lock() {
+ public void do_lock () {
this.virt_is_locked = true;
- this.locked();
+ this.locked ();
}
- public void do_unlock() {
+ public void do_unlock () {
this.virt_is_locked = false;
- this.unlocked();
+ this.unlocked ();
}
- public bool is_locked() {
+ public bool is_locked () {
return this.virt_is_locked;
}
- public void lock_screen() {
+ public void lock_screen () {
this.virt_is_locked = true;
}
- public void blank_screen() {}
+ public void blank_screen () {}
- public void unblank_screen() {}
+ public void unblank_screen () {}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]