aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/manual-test-snap.cpp10
-rw-r--r--tests/test-alarm-queue.cpp17
-rw-r--r--tests/test-live-actions.cpp6
-rw-r--r--tests/test-snap.cpp20
4 files changed, 25 insertions, 28 deletions
diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp
index 22ef137..cbe79cd 100644
--- a/tests/manual-test-snap.cpp
+++ b/tests/manual-test-snap.cpp
@@ -67,18 +67,18 @@ int main(int argc, const char* argv[])
Appointment a;
a.color = "green";
a.summary = "Alarm";
- a.url = "alarm:///hello-world";
a.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
a.type = Appointment::UBUNTU_ALARM;
a.begin = DateTime::Local(2014, 12, 25, 0, 0, 0);
a.end = a.begin.end_of_day();
+ a.alarms.push_back(Alarm{"Alarm Text", "", a.begin, std::chrono::seconds::zero()});
auto loop = g_main_loop_new(nullptr, false);
- auto on_snooze = [loop](const Appointment& appt){
- g_message("You clicked 'Snooze' for appt url '%s'", appt.url.c_str());
+ auto on_snooze = [loop](const Appointment& appt, const Alarm&){
+ g_message("You clicked 'Snooze' for appt url '%s'", appt.summary.c_str());
g_idle_add(quit_idle, loop);
};
- auto on_ok = [loop](const Appointment&){
+ auto on_ok = [loop](const Appointment&, const Alarm&){
g_message("You clicked 'OK'");
g_idle_add(quit_idle, loop);
};
@@ -93,7 +93,7 @@ int main(int argc, const char* argv[])
auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service");
Snap snap (notification_engine, settings);
- snap(a, on_snooze, on_ok);
+ snap(a, a.alarms.front(), on_snooze, on_ok);
g_main_loop_run(loop);
g_main_loop_unref(loop);
diff --git a/tests/test-alarm-queue.cpp b/tests/test-alarm-queue.cpp
index 3fdf787..fdab425 100644
--- a/tests/test-alarm-queue.cpp
+++ b/tests/test-alarm-queue.cpp
@@ -48,7 +48,7 @@ protected:
m_range_planner.reset(new MockRangePlanner);
m_upcoming.reset(new UpcomingPlanner(m_range_planner, m_state->clock->localtime()));
m_watcher.reset(new SimpleAlarmQueue(m_state->clock, m_upcoming, m_wakeup_timer));
- m_watcher->alarm_reached().connect([this](const Appointment& appt){
+ m_watcher->alarm_reached().connect([this](const Appointment& appt, const Alarm& /*alarm*/){
m_triggered.push_back(appt.uid);
});
@@ -71,7 +71,7 @@ protected:
const auto tomorrow_begin = now.add_days(1).start_of_day();
const auto tomorrow_end = tomorrow_begin.end_of_day();
- Appointment a1; // an alarm clock appointment
+ Appointment a1; // an ubuntu alarm
a1.color = "red";
a1.summary = "Alarm";
a1.summary = "http://www.example.com/";
@@ -79,18 +79,20 @@ protected:
a1.type = Appointment::UBUNTU_ALARM;
a1.begin = tomorrow_begin;
a1.end = tomorrow_end;
+ a1.alarms.push_back(Alarm{"Alarm Text", "", a1.begin, std::chrono::seconds::zero()});
const auto ubermorgen_begin = now.add_days(2).start_of_day();
const auto ubermorgen_end = ubermorgen_begin.end_of_day();
- Appointment a2; // a non-alarm appointment
+ Appointment a2; // something else
a2.color = "green";
a2.summary = "Other Text";
a2.summary = "http://www.monkey.com/";
a2.uid = "monkey";
- a1.type = Appointment::EVENT;
+ a2.type = Appointment::EVENT;
a2.begin = ubermorgen_begin;
a2.end = ubermorgen_end;
+ a2.alarms.push_back(Alarm{"Alarm Text", "", a2.begin, std::chrono::seconds::zero()});
return std::vector<Appointment>({a1, a2});
}
@@ -105,7 +107,7 @@ TEST_F(AlarmQueueFixture, AppointmentsChanged)
// Add some appointments to the planner.
// One of these matches our state's localtime, so that should get triggered.
std::vector<Appointment> a = build_some_appointments();
- a[0].begin = m_state->clock->localtime();
+ a[0].begin = a[0].alarms.front().time = m_state->clock->localtime();
m_range_planner->appointments().set(a);
// Confirm that it got fired
@@ -135,7 +137,8 @@ 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;
+ a[0].alarms.front().time = now;
+ a[1].alarms.front().time = now;
m_range_planner->appointments().set(a);
ASSERT_EQ(2, m_triggered.size());
@@ -151,7 +154,7 @@ TEST_F(AlarmQueueFixture, NoDuplicates)
const std::vector<Appointment> appointments = build_some_appointments();
std::vector<Appointment> a;
a.push_back(appointments[0]);
- a[0].begin = now;
+ a[0].alarms.front().time = now;
m_range_planner->appointments().set(a);
ASSERT_EQ(1, m_triggered.size());
EXPECT_EQ(a[0].uid, m_triggered[0]);
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index 1a34511..4f84f25 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -319,10 +319,6 @@ TEST_F(LiveActionsFixture, PhoneOpenAppointment)
a.type = Appointment::UBUNTU_ALARM;
m_actions->phone_open_appointment(a);
EXPECT_EQ(clock_app_url, m_live_actions->last_url);
-
- a.url = "appid://blah";
- m_actions->phone_open_appointment(a);
- EXPECT_EQ(a.url, m_live_actions->last_url);
}
TEST_F(LiveActionsFixture, PhoneOpenCalendarApp)
@@ -392,7 +388,6 @@ TEST_F(LiveActionsFixture, CalendarState)
Appointment a1;
a1.color = "green";
a1.summary = "write unit tests";
- a1.url = "http://www.ubuntu.com/";
a1.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
a1.begin = tomorrow_begin;
a1.end = tomorrow_end;
@@ -403,7 +398,6 @@ TEST_F(LiveActionsFixture, CalendarState)
Appointment a2;
a2.color = "orange";
a2.summary = "code review";
- a2.url = "http://www.ubuntu.com/";
a2.uid = "2756ff7de3745bbffd65d2e4779c37c7ca60d843";
a2.begin = ubermorgen_begin;
a2.end = ubermorgen_end;
diff --git a/tests/test-snap.cpp b/tests/test-snap.cpp
index 3dd4501..2e29132 100644
--- a/tests/test-snap.cpp
+++ b/tests/test-snap.cpp
@@ -106,12 +106,12 @@ protected:
// init the Appointment
appt.color = "green";
appt.summary = "Alarm";
- appt.url = "alarm:///hello-world";
appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
appt.type = Appointment::EVENT;
const auto christmas = DateTime::Local(2015,12,25,0,0,0);
appt.begin = christmas.start_of_day();
appt.end = christmas.end_of_day();
+ appt.alarms.push_back(Alarm{"Alarm Text", "", appt.begin, std::chrono::seconds::zero()});
service = dbus_test_service_new(nullptr);
@@ -343,8 +343,8 @@ TEST_F(SnapFixture, InteractiveDuration)
make_interactive();
// call the Snap Decision
- auto func = [this](const Appointment&){g_idle_add(quit_idle, loop);};
- snap(appt, func, func);
+ auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
+ snap(appt, appt.alarms.front(), func, func);
// confirm that Notify got called once
guint len = 0;
@@ -393,8 +393,8 @@ TEST_F(SnapFixture, InhibitSleep)
make_interactive();
// invoke the notification
- auto func = [this](const Appointment&){g_idle_add(quit_idle, loop);};
- (*snap)(appt, func, func);
+ auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
+ (*snap)(appt, appt.alarms.front(), func, func);
wait_msec(1000);
@@ -448,8 +448,8 @@ TEST_F(SnapFixture, ForceScreen)
make_interactive();
// invoke the notification
- auto func = [this](const Appointment&){g_idle_add(quit_idle, loop);};
- (*snap)(appt, func, func);
+ auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
+ (*snap)(appt, appt.alarms.front(), func, func);
wait_msec(1000);
@@ -484,14 +484,14 @@ TEST_F(SnapFixture, HapticModes)
{
auto settings = std::make_shared<Settings>();
auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);
- auto func = [this](const Appointment&){g_idle_add(quit_idle, loop);};
+ auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
GError * error = nullptr;
// invoke a snap decision while haptic feedback is set to "pulse",
// confirm that VibratePattern got called
settings->alarm_haptic.set("pulse");
auto snap = new Snap (ne, settings);
- (*snap)(appt, func, func);
+ (*snap)(appt, appt.alarms.front(), func, func);
wait_msec(100);
EXPECT_TRUE (dbus_test_dbus_mock_object_check_method_call (haptic_mock,
haptic_obj,
@@ -506,7 +506,7 @@ TEST_F(SnapFixture, HapticModes)
dbus_test_dbus_mock_object_clear_method_calls (haptic_mock, haptic_obj, &error);
settings->alarm_haptic.set("none");
snap = new Snap (ne, settings);
- (*snap)(appt, func, func);
+ (*snap)(appt, appt.alarms.front(), func, func);
wait_msec(100);
EXPECT_FALSE (dbus_test_dbus_mock_object_check_method_call (haptic_mock,
haptic_obj,