From fff19d70649589b81a896e4deb032a7bd4bdca1e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 31 Mar 2015 18:54:04 -0500 Subject: add an Alarm class to represent ical valarm components; change the Appointment class to hold an arbitrary number of Alarms. --- tests/test-snap.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/test-snap.cpp') 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(); auto ne = std::make_shared(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, -- cgit v1.2.3 From 62d68e6453c0ad69ff4d71099441a8151e9a9bea Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 5 Apr 2015 17:27:52 -0500 Subject: fix misuse of ECalComponentAlarmInstance's fields. --- include/datetime/appointment.h | 1 - src/appointment.cpp | 3 +-- src/engine-eds.cpp | 4 +--- tests/manual-test-snap.cpp | 2 +- tests/test-alarm-queue.cpp | 4 ++-- tests/test-snap.cpp | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) (limited to 'tests/test-snap.cpp') diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h index 337d9b8..e9c1bc2 100644 --- a/include/datetime/appointment.h +++ b/include/datetime/appointment.h @@ -39,7 +39,6 @@ struct Alarm std::string text; std::string audio_url; DateTime time; - std::chrono::seconds duration; bool operator== (const Alarm& that) const; }; diff --git a/src/appointment.cpp b/src/appointment.cpp index 236c5f4..1edd93c 100644 --- a/src/appointment.cpp +++ b/src/appointment.cpp @@ -31,8 +31,7 @@ bool Alarm::operator==(const Alarm& that) const { return (text==that.text) && (audio_url==that.audio_url) - && (this->time==that.time) - && (duration==that.duration); + && (this->time==that.time); } bool Appointment::operator==(const Appointment& that) const diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp index ecbee59..856f190 100644 --- a/src/engine-eds.cpp +++ b/src/engine-eds.cpp @@ -559,7 +559,7 @@ private: if (a != nullptr) { - const DateTime alarm_begin{ai->occur_start}; + const DateTime alarm_begin{ai->trigger}; auto& alarm = alarms[alarm_begin]; if (alarm.text.empty()) @@ -568,8 +568,6 @@ private: alarm.audio_url = get_alarm_sound_url(a); if (!alarm.time.is_set()) alarm.time = alarm_begin; - if (alarm.duration == std::chrono::seconds::zero()) - alarm.duration = std::chrono::seconds(ai->occur_end - ai->occur_start); e_cal_component_alarm_free(a); } diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp index cbe79cd..d04cf14 100644 --- a/tests/manual-test-snap.cpp +++ b/tests/manual-test-snap.cpp @@ -71,7 +71,7 @@ int main(int argc, const char* argv[]) 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()}); + a.alarms.push_back(Alarm{"Alarm Text", "", a.begin}); auto loop = g_main_loop_new(nullptr, false); auto on_snooze = [loop](const Appointment& appt, const Alarm&){ diff --git a/tests/test-alarm-queue.cpp b/tests/test-alarm-queue.cpp index fdab425..aa35668 100644 --- a/tests/test-alarm-queue.cpp +++ b/tests/test-alarm-queue.cpp @@ -79,7 +79,7 @@ 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()}); + a1.alarms.push_back(Alarm{"Alarm Text", "", a1.begin}); const auto ubermorgen_begin = now.add_days(2).start_of_day(); const auto ubermorgen_end = ubermorgen_begin.end_of_day(); @@ -92,7 +92,7 @@ protected: 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()}); + a2.alarms.push_back(Alarm{"Alarm Text", "", a2.begin}); return std::vector({a1, a2}); } diff --git a/tests/test-snap.cpp b/tests/test-snap.cpp index 2e29132..46fbd10 100644 --- a/tests/test-snap.cpp +++ b/tests/test-snap.cpp @@ -111,7 +111,7 @@ protected: 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()}); + appt.alarms.push_back(Alarm{"Alarm Text", "", appt.begin}); service = dbus_test_service_new(nullptr); -- cgit v1.2.3