aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-06-11 12:36:41 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-06-11 12:36:41 +0000
commit9eee6f013103e856f66f16e17e156b1f6103695a (patch)
tree3678963f3d3520e8703732d7d0bb8489f23b7f49 /tests
parent5e6083e752f7dd50571f87e5910dca6302ce8113 (diff)
parentdb2898b2da7231490fe77ebcef0fb373ce1f2776 (diff)
downloadayatana-indicator-datetime-9eee6f013103e856f66f16e17e156b1f6103695a.tar.gz
ayatana-indicator-datetime-9eee6f013103e856f66f16e17e156b1f6103695a.tar.bz2
ayatana-indicator-datetime-9eee6f013103e856f66f16e17e156b1f6103695a.zip
Prefer to use ubuntu-platform-hardware-api for wakeups when possible s.t. user-defined alarms/appointments can wake up the phone from sleep to give a snap decision. Fixes: 1299916
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/test-alarm-queue.cpp (renamed from tests/test-clock-watcher.cpp)32
2 files changed, 19 insertions, 15 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7d590c9..fe6d7eb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -41,8 +41,8 @@ function(add_test_by_name name)
target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
endfunction()
add_test_by_name(test-actions)
+add_test_by_name(test-alarm-queue)
add_test_by_name(test-clock)
-add_test_by_name(test-clock-watcher)
add_test_by_name(test-exporter)
add_test_by_name(test-formatter)
add_test_by_name(test-live-actions)
diff --git a/tests/test-clock-watcher.cpp b/tests/test-alarm-queue.cpp
index 2425fe8..d2de8ac 100644
--- a/tests/test-clock-watcher.cpp
+++ b/tests/test-alarm-queue.cpp
@@ -17,7 +17,8 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
-#include <datetime/clock-watcher.h>
+#include <datetime/alarm-queue-simple.h>
+#include <datetime/wakeup-timer-mainloop.h>
#include <gtest/gtest.h>
@@ -25,7 +26,7 @@
using namespace unity::indicator::datetime;
-class ClockWatcherFixture: public StateFixture
+class AlarmQueueFixture: public StateFixture
{
private:
@@ -34,7 +35,8 @@ private:
protected:
std::vector<std::string> m_triggered;
- std::unique_ptr<ClockWatcher> m_watcher;
+ std::shared_ptr<WakeupTimer> m_wakeup_timer;
+ std::unique_ptr<AlarmQueue> m_watcher;
std::shared_ptr<RangePlanner> m_range_planner;
std::shared_ptr<UpcomingPlanner> m_upcoming;
@@ -42,9 +44,10 @@ protected:
{
super::SetUp();
+ m_wakeup_timer.reset(new MainloopWakeupTimer(m_state->clock));
m_range_planner.reset(new MockRangePlanner);
m_upcoming.reset(new UpcomingPlanner(m_range_planner, m_state->clock->localtime()));
- m_watcher.reset(new ClockWatcherImpl(m_state->clock, m_upcoming));
+ m_watcher.reset(new SimpleAlarmQueue(m_state->clock, m_upcoming, m_wakeup_timer));
m_watcher->alarm_reached().connect([this](const Appointment& appt){
m_triggered.push_back(appt.uid);
});
@@ -108,7 +111,7 @@ protected:
****
***/
-TEST_F(ClockWatcherFixture, AppointmentsChanged)
+TEST_F(AlarmQueueFixture, AppointmentsChanged)
{
// Add some appointments to the planner.
// One of these matches our state's localtime, so that should get triggered.
@@ -117,12 +120,12 @@ TEST_F(ClockWatcherFixture, AppointmentsChanged)
m_range_planner->appointments().set(a);
// Confirm that it got fired
- EXPECT_EQ(1, m_triggered.size());
+ ASSERT_EQ(1, m_triggered.size());
EXPECT_EQ(a[0].uid, m_triggered[0]);
}
-TEST_F(ClockWatcherFixture, TimeChanged)
+TEST_F(AlarmQueueFixture, TimeChanged)
{
// Add some appointments to the planner.
// Neither of these match the state's localtime, so nothing should be triggered.
@@ -132,26 +135,27 @@ TEST_F(ClockWatcherFixture, TimeChanged)
// Set the state's clock to a time that matches one of the appointments().
// That appointment should get triggered.
+g_message ("%s setting clock to %s", G_STRLOC, a[1].begin.format("%F %T").c_str());
m_mock_state->mock_clock->set_localtime(a[1].begin);
- EXPECT_EQ(1, m_triggered.size());
+ ASSERT_EQ(1, m_triggered.size());
EXPECT_EQ(a[1].uid, m_triggered[0]);
}
-TEST_F(ClockWatcherFixture, MoreThanOne)
+TEST_F(AlarmQueueFixture, MoreThanOne)
{
const auto now = m_state->clock->localtime();
std::vector<Appointment> a = build_some_appointments();
a[0].begin = a[1].begin = now;
m_range_planner->appointments().set(a);
- EXPECT_EQ(2, m_triggered.size());
+ ASSERT_EQ(2, m_triggered.size());
EXPECT_EQ(a[0].uid, m_triggered[0]);
EXPECT_EQ(a[1].uid, m_triggered[1]);
}
-TEST_F(ClockWatcherFixture, NoDuplicates)
+TEST_F(AlarmQueueFixture, NoDuplicates)
{
// Setup: add an appointment that gets triggered.
const auto now = m_state->clock->localtime();
@@ -160,13 +164,13 @@ TEST_F(ClockWatcherFixture, NoDuplicates)
a.push_back(appointments[0]);
a[0].begin = now;
m_range_planner->appointments().set(a);
- EXPECT_EQ(1, m_triggered.size());
+ ASSERT_EQ(1, m_triggered.size());
EXPECT_EQ(a[0].uid, m_triggered[0]);
// Now change the appointment vector by adding one to it.
- // Confirm that the ClockWatcher doesn't re-trigger a[0]
+ // Confirm that the AlarmQueue doesn't re-trigger a[0]
a.push_back(appointments[1]);
m_range_planner->appointments().set(a);
- EXPECT_EQ(1, m_triggered.size());
+ ASSERT_EQ(1, m_triggered.size());
EXPECT_EQ(a[0].uid, m_triggered[0]);
}