[gnome-break-timer] Put test cases in their test suites' namespaces.



commit 96229179796fc5dde7788403c7321c11417b737d
Author: Dylan McCall <dylanmccall ubuntu com>
Date:   Fri Sep 20 21:24:37 2013 -0700

    Put test cases in their test suites' namespaces.
    
    Sorry about the massive diff. This is a quick fix to avoid name clashes when several test suites are 
built with a particular runner.

 tests/activity-monitor/test_ActivityMonitor.vala |  236 +++++++-------
 tests/breaks/test_TimerBreakController.vala      |  364 +++++++++++-----------
 tests/common/test_NaturalTime.vala               |  156 +++++-----
 3 files changed, 378 insertions(+), 378 deletions(-)
---
diff --git a/tests/activity-monitor/test_ActivityMonitor.vala 
b/tests/activity-monitor/test_ActivityMonitor.vala
index 9ff8ad3..e10ff22 100644
--- a/tests/activity-monitor/test_ActivityMonitor.vala
+++ b/tests/activity-monitor/test_ActivityMonitor.vala
@@ -24,170 +24,170 @@ public class test_ActivityMonitor : TestSuiteWithActivityMonitor {
                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) {
-               context.session_status.virt_is_locked = false;
-               context.time_step (false, 0, 0);
-               context.time_step (false, 1, 1);
+       class test_simple_idle : Object, SimpleTestCase<test_ActivityMonitor> {
+               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);
 
-               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) {
-               context.session_status.virt_is_locked = false;
-               context.time_step (true, 1, 1);
+       class test_simple_active : Object, SimpleTestCase<test_ActivityMonitor> {
+               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);
 
-               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) {
-               context.session_status.virt_is_locked = false;
-               context.time_step (true, 1, 1);
+       class test_active_then_idle : Object, SimpleTestCase<test_ActivityMonitor> {
+               public void run (test_ActivityMonitor context) {
+                       context.session_status.virt_is_locked = false;
+                       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) {
-               context.session_status.virt_is_locked = true;
-               context.time_step (true, 1, 1);
+       class test_lock_idle : Object, SimpleTestCase<test_ActivityMonitor> {
+               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 (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) {
-               context.session_status.virt_is_locked = false;
-               context.time_step (true, 1, 1);
+       class test_sleep_and_unlock : Object, SimpleTestCase<test_ActivityMonitor> {
+               public void run (test_ActivityMonitor context) {
+                       context.session_status.virt_is_locked = false;
+                       context.time_step (true, 1, 1);
 
-               context.session_status.virt_is_locked = true;
-               context.time_step (true, 120, 2);
+                       context.session_status.virt_is_locked = true;
+                       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);
+                       context.session_status.virt_is_locked = false;
+                       context.time_step (true, 1, 1);
 
-               assert (context.activity_log.size == 4);
+                       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[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[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[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);
+                       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) {
-               context.session_status.virt_is_locked = true;
-               context.time_step (true, 1, 1);
+       class test_unlock_signal_activity : Object, SimpleTestCase<test_ActivityMonitor> {
+               public void run (test_ActivityMonitor context) {
+                       context.session_status.virt_is_locked = true;
+                       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);
+               }
        }
-}
+}
\ No newline at end of file
diff --git a/tests/breaks/test_TimerBreakController.vala b/tests/breaks/test_TimerBreakController.vala
index 3cca55c..aae3d5d 100644
--- a/tests/breaks/test_TimerBreakController.vala
+++ b/tests/breaks/test_TimerBreakController.vala
@@ -94,227 +94,227 @@ public class test_TimerBreakController : TestSuiteWithActivityMonitor {
                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 class testable_TimerBreakController : TimerBreakController {
+               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);
+       class test_start_disabled : Object, SimpleTestCase<test_TimerBreakController> {
+               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) {
-               // break_controller is enabled by default (emulating the behaviour of BreakManager with 
default settings)
-               assert (context.break_controller.is_enabled ());
 
-               int expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
-               int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
+       class test_enable_and_idle : Object, SimpleTestCase<test_TimerBreakController> {
+               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 ());
 
-               context.time_step (true, 1, 1);
-               expected_starts_in -= 1;
-               context.break_controller.assert_timers (expected_starts_in, expected_remaining);
+                       int expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
+                       int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
 
-               for (int step = 0; step <= test_TimerBreakController.DEFAULT_DURATION; step++) {
-                       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");
+                       context.time_step (true, 1, 1);
+                       expected_starts_in -= 1;
+                       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");
+                               if (step == test_TimerBreakController.DEFAULT_DURATION) {
+                                       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);
+                       expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
+                       expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
+                       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");   
+                       for (int step = 0; step < test_TimerBreakController.DEFAULT_INTERVAL; step++) {
+                               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) {
-               int expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
-               int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
+       class test_enable_and_active : Object, SimpleTestCase<test_TimerBreakController> {
+               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");
-               }
-               expected_starts_in -= active_time_1;
-               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");
-               }
-               expected_starts_in -= 1;
-               expected_remaining -= idle_time_1;
-               context.break_controller.assert_timers (expected_starts_in, expected_remaining);
+                       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");
+                       }
+                       expected_starts_in -= active_time_1;
+                       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");
-                       if (step == warn_step) {
-                               assert (context.break_timestep_log[1] == "warned");
-                       } else if (step == active_time_2-1) {
-                               assert (context.break_timestep_log[1] == "activated");
+                       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");
                        }
-               }
-               expected_starts_in = 0;
-               expected_remaining -= 1;
-               context.break_controller.assert_timers (expected_starts_in, expected_remaining);
+                       expected_starts_in -= 1;
+                       expected_remaining -= idle_time_1;
+                       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");
+                               if (step == warn_step) {
+                                       assert (context.break_timestep_log[1] == "warned");
+                               } else if (step == active_time_2-1) {
+                                       assert (context.break_timestep_log[1] == "activated");
+                               }
+                       }
+                       expected_starts_in = 0;
+                       expected_remaining -= 1;
+                       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");
-               }
-               expected_remaining -= 5;
-               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");
-                       if (step == expected_remaining-1) {
-                               assert (context.break_timestep_log[1] == "finished");
+                       for (int step = 0; step < 5; step++) {
+                               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);
+
+                       for (int step = 0; step < expected_remaining; step++) {
+                               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");
+                               }
                        }
+                       expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
+                       expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
+                       context.break_controller.assert_timers (expected_starts_in, expected_remaining);
                }
-               expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
-               expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
-               context.break_controller.assert_timers (expected_starts_in, expected_remaining);
        }
-}
 
-class test_force_activate : Object, SimpleTestCase<test_TimerBreakController> {
-       public void run (test_TimerBreakController context) {
-               int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
+       class test_force_activate : Object, SimpleTestCase<test_TimerBreakController> {
+               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);
+                       for (int step = 0; step < 10; step++) {
+                               context.time_step (false, 1, 1);
+                       }
+                       expected_remaining -= 10;
+                       context.break_controller.assert_timers (null, expected_remaining);
                }
-               expected_remaining -= 10;
-               context.break_controller.assert_timers (null, expected_remaining);
        }
-}
 
-class test_postpone : Object, SimpleTestCase<test_TimerBreakController> {
-       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 ();
-               for (int step = 0; step < 10; step++) {
-                       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);
+       class test_postpone : Object, SimpleTestCase<test_TimerBreakController> {
+               public void run (test_TimerBreakController context) {
+                       int expected_starts_in = test_TimerBreakController.DEFAULT_INTERVAL;
+                       int expected_remaining = test_TimerBreakController.DEFAULT_DURATION;
 
-               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);
-
-               for (int step = 0; step < expected_starts_in; step++) {
-                       context.time_step (true, 1, 1);
-                       if (step == expected_starts_in-1) {
-                               assert (context.break_timestep_log[1] == "activated");
+                       context.break_controller.activate ();
+                       for (int step = 0; step < 10; step++) {
+                               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.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);
+
+                       for (int step = 0; step < expected_starts_in; step++) {
+                               context.time_step (true, 1, 1);
+                               if (step == expected_starts_in-1) {
+                                       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);
                }
-               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);
        }
-}
 
-class test_serialize : Object, SimpleTestCase<test_TimerBreakController> {
-       public void run (test_TimerBreakController context) {
-               var initial_json = context.save_state ();
+       class test_serialize : Object, SimpleTestCase<test_TimerBreakController> {
+               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);
-               }
-               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 = 0; step < 50; step++) {
+                               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 ();
 
-               for (int step = 50; step < test_TimerBreakController.DEFAULT_INTERVAL; step++) {
-                       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 ();
+                       for (int step = 50; step < test_TimerBreakController.DEFAULT_INTERVAL; step++) {
+                               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 ();
 
-               for (int step = 0; step < 10; step++) {
-                       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 ();
+                       for (int step = 0; step < 10; step++) {
+                               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 ();
 
-               context.time_step (true, 0, 0);
-               for (int step = 0; step < 10; step++) {
-                       context.time_step (true, 1, 1);
+                       context.time_step (true, 0, 0);
+                       for (int step = 0; step < 10; step++) {
+                               context.time_step (true, 1, 1);
+                       }
+                       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 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);
+                       // 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.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);
                }
-               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 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);
-               // 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.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);
        }
-}
+}
\ No newline at end of file
diff --git a/tests/common/test_NaturalTime.vala b/tests/common/test_NaturalTime.vala
index 3aba2b2..7bd50e0 100644
--- a/tests/common/test_NaturalTime.vala
+++ b/tests/common/test_NaturalTime.vala
@@ -28,85 +28,85 @@ public class test_NaturalTime : SimpleTestSuite {
        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) {
-               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);
-
-               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);
+
+       class test_get_label_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
+               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);
+
+                       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);
+               }
        }
-}
-
-class test_get_simplest_label_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
-       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);
-
-               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);
+
+       class test_get_simplest_label_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
+               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);
+
+                       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);
+               }
        }
-}
-
-class test_get_countdown_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
-       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);
-
-               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);
-
-               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);
-
-               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);
-
-               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);
+
+       class test_get_countdown_for_seconds : Object, SimpleTestCase<test_NaturalTime> {
+               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);
+
+                       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);
+
+                       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);
+
+                       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);
+
+                       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);
+               }
        }
-}
-
-class test_get_countdown_for_seconds_with_start : Object, SimpleTestCase<test_NaturalTime> {
-       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);
-
-               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);
-
-               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);
-
-               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);
+
+       class test_get_countdown_for_seconds_with_start : Object, SimpleTestCase<test_NaturalTime> {
+               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);
+
+                       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);
+
+                       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);
+
+                       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);
+               }
        }
-}
+}
\ No newline at end of file



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]