aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-01-22 14:28:20 -0600
committerCharles Kerr <charles.kerr@canonical.com>2014-01-22 14:28:20 -0600
commitaad7e86a109aeec75b3772cda20478363f966745 (patch)
tree5049662b13435cc5b422e1194bd617a1089e6fb6 /tests
parente2fd6e620ce7f18c2cbf7c7b353d7cb5f86dce11 (diff)
downloadayatana-indicator-datetime-aad7e86a109aeec75b3772cda20478363f966745.tar.gz
ayatana-indicator-datetime-aad7e86a109aeec75b3772cda20478363f966745.tar.bz2
ayatana-indicator-datetime-aad7e86a109aeec75b3772cda20478363f966745.zip
Alarms is going to need to know when the clock's minute changes. We already have a timer for that in Formatter, so move it from there to Clock and add a corresponding public signal Clock.minuteChanged that both Formatter and Alarms can use. Sync unit tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-clock.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/tests/test-clock.cpp b/tests/test-clock.cpp
index 142ccad..4271374 100644
--- a/tests/test-clock.cpp
+++ b/tests/test-clock.cpp
@@ -46,28 +46,24 @@ class ClockFixture: public TestDBusFixture
}
};
-/**
- * Confirm that normal time passing doesn't trigger a skew event.
- * that idling changing the clock's time triggers a skew event
- */
-TEST_F(ClockFixture, IdleDoesNotTriggerSkew)
+TEST_F(ClockFixture, MinuteChangedSignalShouldTriggerOncePerMinute)
{
+ // start up a live clock
std::shared_ptr<Timezones> zones(new Timezones);
zones->timezone.set("America/New_York");
LiveClock clock(zones);
wait_msec(500); // wait for the bus to set up
- bool skewed = false;
- clock.skewDetected.connect([&skewed](){
- skewed = true;
- g_warn_if_reached();
- return G_SOURCE_REMOVE;
- });
-
- const unsigned int intervalSec = 3;
- clock.skewTestIntervalSec.set(intervalSec);
- wait_msec(intervalSec * 2.5 * 1000);
- EXPECT_FALSE(skewed);
+ // count how many times clock.minuteChanged() is emitted over the next minute
+ const DateTime now = clock.localtime();
+ const auto gnow = now.get();
+ auto gthen = g_date_time_add_minutes(gnow, 1);
+ int count = 0;
+ clock.minuteChanged.connect([&count](){count++;});
+ const auto msec = g_date_time_difference(gthen,gnow) / 1000;
+ wait_msec(msec);
+ EXPECT_EQ(1, count);
+ g_date_time_unref(gthen);
}
/***
@@ -99,7 +95,7 @@ TEST_F(ClockFixture, TimezoneChangeTriggersSkew)
g_time_zone_unref(tz_nyc);
/// change the timezones!
- clock.skewDetected.connect([this](){
+ clock.minuteChanged.connect([this](){
g_main_loop_quit(loop);
});
g_idle_add([](gpointer gs){
@@ -128,7 +124,7 @@ TEST_F(ClockFixture, SleepTriggersSkew)
wait_msec(500); // wait for the bus to set up
bool skewed = false;
- clock.skewDetected.connect([&skewed, this](){
+ clock.minuteChanged.connect([&skewed, this](){
skewed = true;
g_main_loop_quit(loop);
return G_SOURCE_REMOVE;