diff options
-rw-r--r-- | data/com.canonical.indicator.datetime.AlarmProperties.xml | 8 | ||||
-rw-r--r-- | data/com.canonical.indicator.datetime.gschema.xml.in | 8 | ||||
-rw-r--r-- | include/datetime/planner-aggregate.h | 52 | ||||
-rw-r--r-- | include/datetime/planner-snooze.h | 56 | ||||
-rw-r--r-- | include/datetime/planner.h | 5 | ||||
-rw-r--r-- | include/datetime/settings-live.h | 1 | ||||
-rw-r--r-- | include/datetime/settings-shared.h | 1 | ||||
-rw-r--r-- | include/datetime/settings.h | 1 | ||||
-rw-r--r-- | include/datetime/snap.h | 4 | ||||
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/exporter.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 32 | ||||
-rw-r--r-- | src/planner-aggregate.cpp | 106 | ||||
-rw-r--r-- | src/planner-snooze.cpp | 115 | ||||
-rw-r--r-- | src/planner.cpp | 54 | ||||
-rw-r--r-- | src/settings-live.cpp | 12 | ||||
-rw-r--r-- | src/snap.cpp | 24 | ||||
-rw-r--r-- | tests/manual | 10 | ||||
-rw-r--r-- | tests/manual-test-snap.cpp | 10 | ||||
-rw-r--r-- | tests/test-exporter.cpp | 11 | ||||
-rw-r--r-- | tests/test-settings.cpp | 1 |
21 files changed, 476 insertions, 39 deletions
diff --git a/data/com.canonical.indicator.datetime.AlarmProperties.xml b/data/com.canonical.indicator.datetime.AlarmProperties.xml index 9b38af9..7ba0e5e 100644 --- a/data/com.canonical.indicator.datetime.AlarmProperties.xml +++ b/data/com.canonical.indicator.datetime.AlarmProperties.xml @@ -36,5 +36,13 @@ </doc:doc> </property> + <property name="SnoozeDuration" type="i" access="readwrite"> + <doc:doc> + <doc:description> + <doc:para>How many minutes to wait when the Snooze button is pressed. [Range: 1-15]</doc:para> + </doc:description> + </doc:doc> + </property> + </interface> </node> diff --git a/data/com.canonical.indicator.datetime.gschema.xml.in b/data/com.canonical.indicator.datetime.gschema.xml.in index 4e4acd8..edcede2 100644 --- a/data/com.canonical.indicator.datetime.gschema.xml.in +++ b/data/com.canonical.indicator.datetime.gschema.xml.in @@ -154,5 +154,13 @@ How long the alarm's sound will be looped if its snap decision is not dismissed by the user. </_description> </key> + <key name="snooze-duration-minutes" type="u"> + <range min="1" max="20"/> + <default>5</default> + <_summary>The snooze duration.</_summary> + <_description> + How long to wait when the user hits the Snooze button. + </_description> + </key> </schema> </schemalist> diff --git a/include/datetime/planner-aggregate.h b/include/datetime/planner-aggregate.h new file mode 100644 index 0000000..892e71a --- /dev/null +++ b/include/datetime/planner-aggregate.h @@ -0,0 +1,52 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + */ + +#ifndef INDICATOR_DATETIME_PLANNER_AGGREGATE_H +#define INDICATOR_DATETIME_PLANNER_AGGREGATE_H + +#include <datetime/planner.h> + +#include <memory> + +namespace unity { +namespace indicator { +namespace datetime { + +/** + * \brief Aggregates one or more Planners + */ +class AggregatePlanner: public Planner +{ +public: + AggregatePlanner(); + virtual ~AggregatePlanner(); + void add(const std::shared_ptr<Planner>&); + + core::Property<std::vector<Appointment>>& appointments() override; + +protected: + class Impl; + std::unique_ptr<Impl> impl; +}; + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif // INDICATOR_DATETIME_PLANNER_AGGREGATE_H diff --git a/include/datetime/planner-snooze.h b/include/datetime/planner-snooze.h new file mode 100644 index 0000000..e2619fa --- /dev/null +++ b/include/datetime/planner-snooze.h @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + */ + +#ifndef INDICATOR_DATETIME_PLANNER_SNOOZE_H +#define INDICATOR_DATETIME_PLANNER_SNOOZE_H + +#include <datetime/clock.h> +#include <datetime/planner.h> +#include <datetime/settings.h> + +#include <memory> + +namespace unity { +namespace indicator { +namespace datetime { + +/** + * A planner to hold 'Snooze' copies of other appointments + */ +class SnoozePlanner: public Planner +{ +public: + SnoozePlanner(const std::shared_ptr<Settings>&, + const std::shared_ptr<Clock>&); + ~SnoozePlanner(); + void add(const Appointment&); + + core::Property<std::vector<Appointment>>& appointments() override; + +protected: + class Impl; + friend class Impl; + std::unique_ptr<Impl> impl; +}; + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif // INDICATOR_DATETIME_PLANNER_H diff --git a/include/datetime/planner.h b/include/datetime/planner.h index e6ef927..22b6381 100644 --- a/include/datetime/planner.h +++ b/include/datetime/planner.h @@ -37,11 +37,12 @@ namespace datetime { class Planner { public: - virtual ~Planner() =default; + virtual ~Planner(); virtual core::Property<std::vector<Appointment>>& appointments() =0; protected: - Planner() =default; + Planner(); + static void sort(std::vector<Appointment>&); }; } // namespace datetime diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h index 4850e69..bb4cd8d 100644 --- a/include/datetime/settings-live.h +++ b/include/datetime/settings-live.h @@ -59,6 +59,7 @@ private: void update_alarm_volume(); void update_alarm_duration(); void update_alarm_haptic(); + void update_snooze_duration(); GSettings* m_settings; diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h index a211821..c18cfaf 100644 --- a/include/datetime/settings-shared.h +++ b/include/datetime/settings-shared.h @@ -49,5 +49,6 @@ TimeFormatMode; #define SETTINGS_ALARM_VOLUME_S "alarm-default-volume" #define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes" #define SETTINGS_ALARM_HAPTIC_S "alarm-haptic-feedback" +#define SETTINGS_SNOOZE_DURATION_S "snooze-duration-minutes" #endif // INDICATOR_DATETIME_SETTINGS_SHARED diff --git a/include/datetime/settings.h b/include/datetime/settings.h index c6fe13b..0294f60 100644 --- a/include/datetime/settings.h +++ b/include/datetime/settings.h @@ -60,6 +60,7 @@ public: core::Property<std::string> alarm_haptic; core::Property<unsigned int> alarm_volume; core::Property<unsigned int> alarm_duration; + core::Property<unsigned int> snooze_duration; }; } // namespace datetime diff --git a/include/datetime/snap.h b/include/datetime/snap.h index ef5c868..572158d 100644 --- a/include/datetime/snap.h +++ b/include/datetime/snap.h @@ -44,8 +44,8 @@ public: typedef std::function<void(const Appointment&)> appointment_func; void operator()(const Appointment& appointment, - appointment_func show, - appointment_func dismiss); + appointment_func snooze, + appointment_func ok); private: class Impl; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e583334..512cc5c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,9 @@ set (SERVICE_CXX_SOURCES locations-settings.cpp menu.cpp notifications.cpp + planner.cpp + planner-aggregate.cpp + planner-snooze.cpp planner-month.cpp planner-range.cpp planner-upcoming.cpp diff --git a/src/exporter.cpp b/src/exporter.cpp index 1d45705..05b21eb 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -145,6 +145,7 @@ private: bind_uint_property(m_alarm_props, "default-volume", m_settings->alarm_volume); bind_string_property(m_alarm_props, "default-sound", m_settings->alarm_sound); bind_string_property(m_alarm_props, "haptic-feedback", m_settings->alarm_haptic); + bind_uint_property(m_alarm_props, "snooze-duration", m_settings->snooze_duration); } /*** diff --git a/src/main.cpp b/src/main.cpp index 48d3d20..54517c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,8 @@ #include <datetime/exporter.h> #include <datetime/locations-settings.h> #include <datetime/menu.h> +#include <datetime/planner-aggregate.h> +#include <datetime/planner-snooze.h> #include <datetime/planner-range.h> #include <datetime/settings-live.h> #include <datetime/snap.h> @@ -37,8 +39,6 @@ #include <glib/gi18n.h> // bindtextdomain() #include <gio/gio.h> -#include <url-dispatcher.h> - #include <locale.h> #include <cstdlib> // exit() @@ -90,6 +90,7 @@ namespace } std::shared_ptr<AlarmQueue> create_simple_alarm_queue(const std::shared_ptr<Clock>& clock, + const std::shared_ptr<Planner>& snooze_planner, const std::shared_ptr<Engine>& engine, const std::shared_ptr<Timezone>& tz) { @@ -102,8 +103,14 @@ namespace upcoming_planner->date().set(now); }); + // create an aggregate planner that folds together the above + // upcoming-events planner and locally-generated snooze events + std::shared_ptr<AggregatePlanner> planner = std::make_shared<AggregatePlanner>(); + planner->add(upcoming_planner); + planner->add(snooze_planner); + auto wakeup_timer = std::make_shared<PowerdWakeupTimer>(clock); - return std::make_shared<SimpleAlarmQueue>(clock, upcoming_planner, wakeup_timer); + return std::make_shared<SimpleAlarmQueue>(clock, planner, wakeup_timer); } } @@ -126,21 +133,14 @@ main(int /*argc*/, char** /*argv*/) MenuFactory factory(actions, state); // set up the snap decisions + auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock); auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service"); std::unique_ptr<Snap> snap (new Snap(notification_engine, state->settings)); - auto alarm_queue = create_simple_alarm_queue(state->clock, engine, timezone); - alarm_queue->alarm_reached().connect([&snap](const Appointment& appt){ - auto snap_show = [](const Appointment& a){ - const char* url; - if(!a.url.empty()) - url = a.url.c_str(); - else // alarm doesn't have a URl associated with it; use a fallback - url = "appid://com.ubuntu.clock/clock/current-user-version"; - url_dispatch_send(url, nullptr, nullptr); - }; - auto snap_dismiss = [](const Appointment&){}; - (*snap)(appt, snap_show, snap_dismiss); - }); + auto alarm_queue = create_simple_alarm_queue(state->clock, snooze_planner, engine, timezone); + auto on_snooze = [snooze_planner](const Appointment& a) {snooze_planner->add(a);}; + auto on_ok = [](const Appointment&){}; + auto on_alarm_reached = [&snap, &on_snooze, &on_ok](const Appointment& a) {(*snap)(a, on_snooze, on_ok);}; + alarm_queue->alarm_reached().connect(on_alarm_reached); // create the menus std::vector<std::shared_ptr<Menu>> menus; diff --git a/src/planner-aggregate.cpp b/src/planner-aggregate.cpp new file mode 100644 index 0000000..7458f0c --- /dev/null +++ b/src/planner-aggregate.cpp @@ -0,0 +1,106 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + */ + +#include <datetime/planner-aggregate.h> + +namespace unity { +namespace indicator { +namespace datetime { + +/*** +**** +***/ + +class AggregatePlanner::Impl +{ +public: + Impl(AggregatePlanner* owner): + m_owner(owner) + { + } + + ~Impl() =default; + + core::Property<std::vector<Appointment>>& appointments() + { + return m_appointments; + } + + void add(const std::shared_ptr<Planner>& planner) + { + m_planners.push_back(planner); + + auto on_changed = [this](const std::vector<Appointment>&){rebuild();}; + auto connection = planner->appointments().changed().connect(on_changed); + m_connections.push_back(connection); + } + +private: + + void rebuild() + { + // use a sorted aggregate vector of all our planners + std::vector<Appointment> all; + for (const auto& planner : m_planners) { + const auto& walk = planner->appointments().get(); + all.insert(std::end(all), std::begin(walk), std::end(walk)); + } + m_owner->sort(all); + m_appointments.set(all); + } + + const AggregatePlanner* m_owner = nullptr; + core::Property<std::vector<Appointment>> m_appointments; + std::vector<std::shared_ptr<Planner>> m_planners; + std::vector<core::ScopedConnection> m_connections; +}; + +/*** +**** +***/ + +AggregatePlanner::AggregatePlanner(): + impl(new Impl{this}) +{ +} + +AggregatePlanner::~AggregatePlanner() +{ +} + +core::Property<std::vector<Appointment>>& +AggregatePlanner::appointments() +{ + return impl->appointments(); +} + +void +AggregatePlanner::add(const std::shared_ptr<Planner>& planner) +{ + return impl->add(planner); +} + +/*** +**** +***/ + +} // namespace datetime +} // namespace indicator +} // namespace unity + diff --git a/src/planner-snooze.cpp b/src/planner-snooze.cpp new file mode 100644 index 0000000..51ad0d2 --- /dev/null +++ b/src/planner-snooze.cpp @@ -0,0 +1,115 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + */ + +#include <datetime/planner-snooze.h> + +#include <libedataserver/libedataserver.h> // e_uid_new() + +namespace unity { +namespace indicator { +namespace datetime { + +/*** +**** +***/ + +class SnoozePlanner::Impl +{ +public: + + Impl(SnoozePlanner* owner, + const std::shared_ptr<Settings>& settings, + const std::shared_ptr<Clock>& clock): + m_owner(owner), + m_settings(settings), + m_clock(clock) + { + } + + ~Impl() + { + } + + virtual core::Property<std::vector<Appointment>>& appointments() + { + return m_appointments; + } + + void add(const Appointment& appt_in) + { + Appointment appt = appt_in; + + // reschedule the alarm to go off N minutes from now + const auto alarm_duration_secs = appt.end - appt.begin; + appt.begin = m_clock->localtime().add_full(0,0,0,0,m_settings->snooze_duration.get(),0); + appt.end = appt.begin.add_full(0,0,0,0,0,alarm_duration_secs); + + // give it a new ID + gchar* uid = e_uid_new(); + appt.uid = uid; + g_free(uid); + + // add it to our appointment list + auto tmp = appointments().get(); + tmp.push_back(appt); + m_owner->sort(tmp); + m_appointments.set(tmp); + } + +private: + + const SnoozePlanner* const m_owner; + const std::shared_ptr<Settings> m_settings; + const std::shared_ptr<Clock> m_clock; + core::Property<std::vector<Appointment>> m_appointments; +}; + +/*** +**** +***/ + +SnoozePlanner::SnoozePlanner(const std::shared_ptr<Settings>& settings, + const std::shared_ptr<Clock>& clock): + impl(new Impl{this, settings, clock}) +{ +} + +SnoozePlanner::~SnoozePlanner() +{ +} + +void +SnoozePlanner::add(const Appointment& appointment) +{ + impl->add(appointment); +} + +core::Property<std::vector<Appointment>>& +SnoozePlanner::appointments() +{ + return impl->appointments(); +} + +/*** +**** +***/ + +} // namespace datetime +} // namespace indicator +} // namespace unity diff --git a/src/planner.cpp b/src/planner.cpp new file mode 100644 index 0000000..6ca9ca7 --- /dev/null +++ b/src/planner.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> + */ + +#include <datetime/planner.h> + +#include <algorithm> + +namespace unity { +namespace indicator { +namespace datetime { + +/*** +**** +***/ + +Planner::Planner() +{ +} + +Planner::~Planner() +{ +} + +void +Planner::sort(std::vector<Appointment>& appts) +{ + std::sort(std::begin(appts), + std::end(appts), + [](const Appointment& a, const Appointment& b){return a.begin < b.begin;}); +} + +/*** +**** +***/ + +} // namespace datetime +} // namespace indicator +} // namespace unity diff --git a/src/settings-live.cpp b/src/settings-live.cpp index a8338ed..8ea06a4 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -56,6 +56,7 @@ LiveSettings::LiveSettings(): update_alarm_volume(); update_alarm_duration(); update_alarm_haptic(); + update_snooze_duration(); // now listen for clients to change the properties s.t. we can sync update GSettings @@ -135,6 +136,10 @@ LiveSettings::LiveSettings(): alarm_haptic.changed().connect([this](const std::string& value){ g_settings_set_string(m_settings, SETTINGS_ALARM_HAPTIC_S, value.c_str()); }); + + snooze_duration.changed().connect([this](unsigned int value){ + g_settings_set_uint(m_settings, SETTINGS_SNOOZE_DURATION_S, value); + }); } /*** @@ -249,6 +254,11 @@ void LiveSettings::update_alarm_haptic() g_free(val); } +void LiveSettings::update_snooze_duration() +{ + snooze_duration.set(g_settings_get_uint(m_settings, SETTINGS_SNOOZE_DURATION_S)); +} + /*** **** ***/ @@ -298,6 +308,8 @@ void LiveSettings::update_key(const std::string& key) update_alarm_duration(); else if (key == SETTINGS_ALARM_HAPTIC_S) update_alarm_haptic(); + else if (key == SETTINGS_SNOOZE_DURATION_S) + update_snooze_duration(); } /*** diff --git a/src/snap.cpp b/src/snap.cpp index 0b2322a..505980c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -59,12 +59,12 @@ public: } void operator()(const Appointment& appointment, - appointment_func show, - appointment_func dismiss) + appointment_func snooze, + appointment_func ok) { if (!appointment.has_alarms) { - dismiss(appointment); + ok(appointment); return; } @@ -98,26 +98,24 @@ public: g_free (title); b.set_timeout (std::chrono::duration_cast<std::chrono::seconds>(minutes)); if (interactive) { - b.add_action ("show", _("Show")); - b.add_action ("dismiss", _("Dismiss")); + b.add_action ("ok", _("OK")); + b.add_action ("snooze", _("Snooze")); } // add 'sound', 'haptic', and 'awake' objects to the capture so // they stay alive until the closed callback is called; i.e., // for the lifespan of the notficiation - b.set_closed_callback([appointment, show, dismiss, sound, awake, haptic] + b.set_closed_callback([appointment, snooze, ok, sound, awake, haptic] (const std::string& action){ - if (action == "show") - show(appointment); + if (action == "snooze") + snooze(appointment); else - dismiss(appointment); + ok(appointment); }); const auto key = m_engine->show(b); if (key) m_notifications.insert (key); - else - show(appointment); } private: @@ -177,9 +175,9 @@ Snap::~Snap() void Snap::operator()(const Appointment& appointment, appointment_func show, - appointment_func dismiss) + appointment_func ok) { - (*impl)(appointment, show, dismiss); + (*impl)(appointment, show, ok); } /*** diff --git a/tests/manual b/tests/manual index c932004..64d59c3 100644 --- a/tests/manual +++ b/tests/manual @@ -33,6 +33,16 @@ Test-case indicator-datetime/new-alarm-wakeup <dd>If the device supports haptic feedback, confirm the alarm vibrates.</dd> </dl> +Test-case indicator-datetime/snooze +<dl> + <dt>Create and save an upcoming alarm in ubuntu-clock-app</dt> + <dt>When the alarm goes off, press the 'Snooze' button</dt> + <dd>The alarm should go away, then reappear N minutes later. + By default the N is 5 minutes but will be configurable from ubuntu-clock-app.</dd> + <dt>When the snoozed alarm reappears, press the 'OK' button</dt> + <dd>This time when the alarm is dismissed, it should not reappear.</dd> +</dl> + Test-case indicator-datetime/edited-alarm-wakeup <dl> <dt>Edit an alarm that's already passed. (see previous test)</dt> diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp index 7d4403d..369e6cd 100644 --- a/tests/manual-test-snap.cpp +++ b/tests/manual-test-snap.cpp @@ -78,12 +78,12 @@ int main(int argc, const char* argv[]) g_date_time_unref(begin); auto loop = g_main_loop_new(nullptr, false); - auto show = [loop](const Appointment& appt){ - g_message("You clicked 'show' for appt url '%s'", appt.url.c_str()); + auto on_snooze = [loop](const Appointment& appt){ + g_message("You clicked 'Snooze' for appt url '%s'", appt.url.c_str()); g_idle_add(quit_idle, loop); }; - auto dismiss = [loop](const Appointment&){ - g_message("You clicked 'dismiss'"); + auto on_ok = [loop](const Appointment&){ + g_message("You clicked 'OK'"); g_idle_add(quit_idle, loop); }; @@ -97,7 +97,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, show, dismiss); + snap(a, on_snooze, on_ok); g_main_loop_run(loop); g_main_loop_unref(loop); diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp index 96665cf..ec19ef4 100644 --- a/tests/test-exporter.cpp +++ b/tests/test-exporter.cpp @@ -184,11 +184,13 @@ TEST_F(ExporterFixture, AlarmProperties) ***/ auto expected_volume = 1; - int expected_duration = 60; + int expected_duration = 4; + int expected_snooze_duration = 5; const char * expected_sound = "/tmp/foo.wav"; const char * expected_haptic = "pulse"; settings->alarm_volume.set(expected_volume); settings->alarm_duration.set(expected_duration); + settings->snooze_duration.set(expected_snooze_duration); settings->alarm_sound.set(expected_sound); settings->alarm_haptic.set(expected_haptic); wait_msec(); @@ -197,20 +199,24 @@ TEST_F(ExporterFixture, AlarmProperties) static constexpr const char* const VOLUME_PROP {"default-volume"}; static constexpr const char* const DURATION_PROP {"duration"}; static constexpr const char* const HAPTIC_PROP {"haptic-feedback"}; + static constexpr const char* const SNOOZE_PROP {"snooze-duration"}; char* sound = nullptr; char* haptic = nullptr; int volume = -1; int duration = -1; + int snooze = -1; g_object_get(proxy, SOUND_PROP, &sound, HAPTIC_PROP, &haptic, VOLUME_PROP, &volume, DURATION_PROP, &duration, + SNOOZE_PROP, &snooze, nullptr); EXPECT_STREQ(expected_sound, sound); EXPECT_STREQ(expected_haptic, haptic); EXPECT_EQ(expected_volume, volume); EXPECT_EQ(expected_duration, duration); + EXPECT_EQ(expected_snooze_duration, snooze); g_clear_pointer (&sound, g_free); g_clear_pointer (&haptic, g_free); @@ -223,10 +229,12 @@ TEST_F(ExporterFixture, AlarmProperties) expected_duration = 30; expected_sound = "/tmp/bar.wav"; expected_haptic = "none"; + expected_snooze_duration = 5; g_object_set(proxy, SOUND_PROP, expected_sound, HAPTIC_PROP, expected_haptic, VOLUME_PROP, expected_volume, DURATION_PROP, expected_duration, + SNOOZE_PROP, expected_snooze_duration, nullptr); wait_msec(); @@ -234,6 +242,7 @@ TEST_F(ExporterFixture, AlarmProperties) EXPECT_STREQ(expected_haptic, settings->alarm_haptic.get().c_str()); EXPECT_EQ(expected_volume, settings->alarm_volume.get()); EXPECT_EQ(expected_duration, settings->alarm_duration.get()); + EXPECT_EQ(expected_snooze_duration, settings->snooze_duration.get()); // cleanup g_clear_object(&proxy); diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp index 4fb0a08..5dfb5ae 100644 --- a/tests/test-settings.cpp +++ b/tests/test-settings.cpp @@ -152,6 +152,7 @@ TEST_F(SettingsFixture, UIntProperties) { TestUIntProperty(m_settings->alarm_duration, SETTINGS_ALARM_DURATION_S); TestUIntProperty(m_settings->alarm_volume, SETTINGS_ALARM_VOLUME_S); + TestUIntProperty(m_settings->snooze_duration, SETTINGS_SNOOZE_DURATION_S); } TEST_F(SettingsFixture, StringProperties) |