Merge lp:~charlesk/indicator-datetime/15.04-lp-1505688-different-default-sounds-for-alarms-and-events into lp:indicator-datetime/15.04

Proposed by Charles Kerr
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 430
Merged at revision: 422
Proposed branch: lp:~charlesk/indicator-datetime/15.04-lp-1505688-different-default-sounds-for-alarms-and-events
Merge into: lp:indicator-datetime/15.04
Diff against target: 654 lines (+206/-40)
22 files modified
CMakeLists.txt (+6/-0)
data/CMakeLists.txt (+5/-3)
data/com.canonical.indicator.datetime.gschema.xml.in.in (+8/-1)
debian/control (+2/-0)
include/datetime/settings-live.h (+1/-0)
include/datetime/settings-shared.h (+1/-0)
include/datetime/settings.h (+1/-0)
include/datetime/snap.h (+2/-0)
include/notifications/sound.h (+22/-0)
src/main.cpp (+2/-1)
src/settings-live.cpp (+14/-0)
src/snap.cpp (+15/-9)
tests/CMakeLists.txt (+3/-1)
tests/manual-test-snap.cpp (+2/-1)
tests/test-eds-ics-missing-trigger.cpp (+1/-1)
tests/test-eds-ics-missing-trigger.ics.in (+2/-2)
tests/test-eds-ics-nonrepeating-events.cpp (+1/-1)
tests/test-eds-ics-nonrepeating-events.ics.in (+1/-1)
tests/test-eds-ics-repeating-events.cpp (+8/-8)
tests/test-eds-ics-repeating-events.ics.in (+1/-1)
tests/test-settings.cpp (+1/-0)
tests/test-snap.cpp (+107/-10)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/15.04-lp-1505688-different-default-sounds-for-alarms-and-events
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Approve
dobey (community) Approve
Review via email: mp+274307@code.launchpad.net

Commit message

Use a different default sound for alarms and calendar events.

Description of the change

15.04 copy of https://code.launchpad.net/~charlesk/indicator-datetime/15.10-lp-1505688-different-default-sounds-for-alarms-and-events/+merge/274304

* Use a different default sound for alarms and calendar events.

* Define the default sounds once in cmake so that source files, schemas, and test datafiles don't all have to change each time the default value changes.

* Add a simple Sound factory so that we can use dependency injection to test notification sounds' properties

* Add unit tests to confirm the role and default sound of alarms and calendar events.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-08-19 04:03:38 +0000
+++ CMakeLists.txt 2015-10-14 02:18:01 +0000
@@ -9,6 +9,12 @@
9add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}"9add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}"
10 -DGNOMELOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")10 -DGNOMELOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
1111
12set(ALARM_DEFAULT_SOUND "/usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg")
13set(CALENDAR_DEFAULT_SOUND "/usr/share/sounds/ubuntu/ringtones/Marimbach.ogg")
14add_definitions(-DALARM_DEFAULT_SOUND="${ALARM_DEFAULT_SOUND}"
15 -DCALENDAR_DEFAULT_SOUND="${CALENDAR_DEFAULT_SOUND}")
16
17
12option (enable_tests "Build the package's automatic tests." ON)18option (enable_tests "Build the package's automatic tests." ON)
13option (enable_lcov "Generate lcov code coverage reports." ON)19option (enable_lcov "Generate lcov code coverage reports." ON)
1420
1521
=== modified file 'data/CMakeLists.txt'
--- data/CMakeLists.txt 2014-06-27 13:53:13 +0000
+++ data/CMakeLists.txt 2015-10-14 02:18:01 +0000
@@ -4,9 +4,11 @@
44
5include (UseGSettings)5include (UseGSettings)
6set (SCHEMA_NAME "com.canonical.indicator.datetime.gschema.xml")6set (SCHEMA_NAME "com.canonical.indicator.datetime.gschema.xml")
7set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}")7set (SCHEMA_FILE_IN_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}.in.in")
8set (SCHEMA_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}.in")8set (SCHEMA_FILE_IN "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}.in")
99set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}")
10# generate the .xml.in file so cmake constants are included
11configure_file(${SCHEMA_FILE_IN_IN} ${SCHEMA_FILE_IN})
10# generate the .xml file using intltool12# generate the .xml file using intltool
11set (ENV{LC_ALL} "C")13set (ENV{LC_ALL} "C")
12execute_process (COMMAND intltool-merge -quiet --xml-style --utf8 --no-translations "${SCHEMA_FILE_IN}" "${SCHEMA_FILE}")14execute_process (COMMAND intltool-merge -quiet --xml-style --utf8 --no-translations "${SCHEMA_FILE_IN}" "${SCHEMA_FILE}")
1315
=== renamed file 'data/com.canonical.indicator.datetime.gschema.xml.in' => 'data/com.canonical.indicator.datetime.gschema.xml.in.in'
--- data/com.canonical.indicator.datetime.gschema.xml.in 2015-10-07 14:07:15 +0000
+++ data/com.canonical.indicator.datetime.gschema.xml.in.in 2015-10-14 02:18:01 +0000
@@ -131,8 +131,15 @@
131 Two modes are currently supported: 'pulse', 'none'.131 Two modes are currently supported: 'pulse', 'none'.
132 </_description>132 </_description>
133 </key>133 </key>
134 <key name="calendar-default-sound" type="s">
135 <default>'@CALENDAR_DEFAULT_SOUND@'</default>
136 <_summary>The calendar's default sound file.</_summary>
137 <_description>
138 If a calendar or reminder event doesn't specify its own sound file, this file will be used as the fallback sound.
139 </_description>
140 </key>
134 <key name="alarm-default-sound" type="s">141 <key name="alarm-default-sound" type="s">
135 <default>'/usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg'</default>142 <default>'@ALARM_DEFAULT_SOUND@'</default>
136 <_summary>The alarm's default sound file.</_summary>143 <_summary>The alarm's default sound file.</_summary>
137 <_description>144 <_description>
138 If an alarm doesn't specify its own sound file, this file will be used as the fallback sound.145 If an alarm doesn't specify its own sound file, this file will be used as the fallback sound.
139146
=== modified file 'debian/control'
--- debian/control 2015-04-06 14:25:59 +0000
+++ debian/control 2015-10-14 02:18:01 +0000
@@ -27,6 +27,8 @@
27# for running live EDS tests:27# for running live EDS tests:
28 evolution-data-server,28 evolution-data-server,
29 gvfs-daemons,29 gvfs-daemons,
30# for phone alarm/calendar notification sound tests:
31 ubuntu-touch-sounds,
30Standards-Version: 3.9.332Standards-Version: 3.9.3
31Homepage: https://launchpad.net/indicator-datetime33Homepage: https://launchpad.net/indicator-datetime
32# If you aren't a member of ~indicator-applet-developers but need to upload34# If you aren't a member of ~indicator-applet-developers but need to upload
3335
=== modified file 'include/datetime/settings-live.h'
--- include/datetime/settings-live.h 2014-09-02 15:37:03 +0000
+++ include/datetime/settings-live.h 2015-10-14 02:18:01 +0000
@@ -55,6 +55,7 @@
55 void update_show_year();55 void update_show_year();
56 void update_time_format_mode();56 void update_time_format_mode();
57 void update_timezone_name();57 void update_timezone_name();
58 void update_calendar_sound();
58 void update_alarm_sound();59 void update_alarm_sound();
59 void update_alarm_volume();60 void update_alarm_volume();
60 void update_alarm_duration();61 void update_alarm_duration();
6162
=== modified file 'include/datetime/settings-shared.h'
--- include/datetime/settings-shared.h 2014-09-02 15:37:03 +0000
+++ include/datetime/settings-shared.h 2015-10-14 02:18:01 +0000
@@ -45,6 +45,7 @@
45#define SETTINGS_SHOW_DETECTED_S "show-auto-detected-location"45#define SETTINGS_SHOW_DETECTED_S "show-auto-detected-location"
46#define SETTINGS_LOCATIONS_S "locations"46#define SETTINGS_LOCATIONS_S "locations"
47#define SETTINGS_TIMEZONE_NAME_S "timezone-name"47#define SETTINGS_TIMEZONE_NAME_S "timezone-name"
48#define SETTINGS_CALENDAR_SOUND_S "calendar-default-sound"
48#define SETTINGS_ALARM_SOUND_S "alarm-default-sound"49#define SETTINGS_ALARM_SOUND_S "alarm-default-sound"
49#define SETTINGS_ALARM_VOLUME_S "alarm-default-volume"50#define SETTINGS_ALARM_VOLUME_S "alarm-default-volume"
50#define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes"51#define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes"
5152
=== modified file 'include/datetime/settings.h'
--- include/datetime/settings.h 2014-09-02 15:37:03 +0000
+++ include/datetime/settings.h 2015-10-14 02:18:01 +0000
@@ -56,6 +56,7 @@
56 core::Property<bool> show_year;56 core::Property<bool> show_year;
57 core::Property<TimeFormatMode> time_format_mode;57 core::Property<TimeFormatMode> time_format_mode;
58 core::Property<std::string> timezone_name;58 core::Property<std::string> timezone_name;
59 core::Property<std::string> calendar_sound;
59 core::Property<std::string> alarm_sound;60 core::Property<std::string> alarm_sound;
60 core::Property<std::string> alarm_haptic;61 core::Property<std::string> alarm_haptic;
61 core::Property<unsigned int> alarm_volume;62 core::Property<unsigned int> alarm_volume;
6263
=== modified file 'include/datetime/snap.h'
--- include/datetime/snap.h 2015-03-31 23:54:04 +0000
+++ include/datetime/snap.h 2015-10-14 02:18:01 +0000
@@ -24,6 +24,7 @@
24#include <datetime/settings.h>24#include <datetime/settings.h>
2525
26#include <notifications/notifications.h>26#include <notifications/notifications.h>
27#include <notifications/sound.h>
2728
28#include <functional>29#include <functional>
29#include <memory>30#include <memory>
@@ -39,6 +40,7 @@
39{40{
40public:41public:
41 Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine,42 Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine,
43 const std::shared_ptr<unity::indicator::notifications::SoundBuilder>& sound_builder,
42 const std::shared_ptr<const Settings>& settings);44 const std::shared_ptr<const Settings>& settings);
43 virtual ~Snap();45 virtual ~Snap();
4446
4547
=== modified file 'include/notifications/sound.h'
--- include/notifications/sound.h 2015-01-22 01:57:59 +0000
+++ include/notifications/sound.h 2015-10-14 02:18:01 +0000
@@ -53,6 +53,28 @@
53****53****
54***/54***/
5555
56class SoundBuilder
57{
58public:
59 SoundBuilder() =default;
60 virtual ~SoundBuilder() =default;
61 virtual std::shared_ptr<Sound> create(const std::string& role, const std::string& uri, unsigned int volume, bool loop) =0;
62};
63
64class DefaultSoundBuilder: public SoundBuilder
65{
66public:
67 DefaultSoundBuilder() =default;
68 ~DefaultSoundBuilder() =default;
69 virtual std::shared_ptr<Sound> create(const std::string& role, const std::string& uri, unsigned int volume, bool loop) override {
70 return std::make_shared<Sound>(role, uri, volume, loop);
71 }
72};
73
74/***
75****
76***/
77
56} // namespace notifications78} // namespace notifications
57} // namespace indicator79} // namespace indicator
58} // namespace unity80} // namespace unity
5981
=== modified file 'src/main.cpp'
--- src/main.cpp 2015-04-03 18:11:39 +0000
+++ src/main.cpp 2015-10-14 02:18:01 +0000
@@ -136,7 +136,8 @@
136 // set up the snap decisions136 // set up the snap decisions
137 auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock);137 auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock);
138 auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service");138 auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service");
139 std::unique_ptr<Snap> snap (new Snap(notification_engine, state->settings));139 auto sound_builder = std::make_shared<uin::DefaultSoundBuilder>();
140 std::unique_ptr<Snap> snap (new Snap(notification_engine, sound_builder, state->settings));
140 auto alarm_queue = create_simple_alarm_queue(state->clock, snooze_planner, engine, timezone_);141 auto alarm_queue = create_simple_alarm_queue(state->clock, snooze_planner, engine, timezone_);
141 auto on_snooze = [snooze_planner](const Appointment& appointment, const Alarm& alarm) {142 auto on_snooze = [snooze_planner](const Appointment& appointment, const Alarm& alarm) {
142 snooze_planner->add(appointment, alarm);143 snooze_planner->add(appointment, alarm);
143144
=== modified file 'src/settings-live.cpp'
--- src/settings-live.cpp 2014-09-02 15:37:03 +0000
+++ src/settings-live.cpp 2015-10-14 02:18:01 +0000
@@ -52,6 +52,7 @@
52 update_show_year();52 update_show_year();
53 update_time_format_mode();53 update_time_format_mode();
54 update_timezone_name();54 update_timezone_name();
55 update_calendar_sound();
55 update_alarm_sound();56 update_alarm_sound();
56 update_alarm_volume();57 update_alarm_volume();
57 update_alarm_duration();58 update_alarm_duration();
@@ -121,6 +122,10 @@
121 g_settings_set_string(m_settings, SETTINGS_TIMEZONE_NAME_S, value.c_str());122 g_settings_set_string(m_settings, SETTINGS_TIMEZONE_NAME_S, value.c_str());
122 });123 });
123124
125 calendar_sound.changed().connect([this](const std::string& value){
126 g_settings_set_string(m_settings, SETTINGS_CALENDAR_SOUND_S, value.c_str());
127 });
128
124 alarm_sound.changed().connect([this](const std::string& value){129 alarm_sound.changed().connect([this](const std::string& value){
125 g_settings_set_string(m_settings, SETTINGS_ALARM_SOUND_S, value.c_str());130 g_settings_set_string(m_settings, SETTINGS_ALARM_SOUND_S, value.c_str());
126 });131 });
@@ -230,6 +235,13 @@
230 g_free(val);235 g_free(val);
231}236}
232237
238void LiveSettings::update_calendar_sound()
239{
240 auto val = g_settings_get_string(m_settings, SETTINGS_CALENDAR_SOUND_S);
241 calendar_sound.set(val);
242 g_free(val);
243}
244
233void LiveSettings::update_alarm_sound()245void LiveSettings::update_alarm_sound()
234{246{
235 auto val = g_settings_get_string(m_settings, SETTINGS_ALARM_SOUND_S);247 auto val = g_settings_get_string(m_settings, SETTINGS_ALARM_SOUND_S);
@@ -300,6 +312,8 @@
300 update_show_detected_locations();312 update_show_detected_locations();
301 else if (key == SETTINGS_TIMEZONE_NAME_S)313 else if (key == SETTINGS_TIMEZONE_NAME_S)
302 update_timezone_name();314 update_timezone_name();
315 else if (key == SETTINGS_CALENDAR_SOUND_S)
316 update_calendar_sound();
303 else if (key == SETTINGS_ALARM_SOUND_S)317 else if (key == SETTINGS_ALARM_SOUND_S)
304 update_alarm_sound();318 update_alarm_sound();
305 else if (key == SETTINGS_ALARM_VOLUME_S)319 else if (key == SETTINGS_ALARM_VOLUME_S)
306320
=== modified file 'src/snap.cpp'
--- src/snap.cpp 2015-10-07 14:07:15 +0000
+++ src/snap.cpp 2015-10-14 02:18:01 +0000
@@ -52,8 +52,10 @@
52public:52public:
5353
54 Impl(const std::shared_ptr<unity::indicator::notifications::Engine>& engine,54 Impl(const std::shared_ptr<unity::indicator::notifications::Engine>& engine,
55 const std::shared_ptr<unity::indicator::notifications::SoundBuilder>& sound_builder,
55 const std::shared_ptr<const Settings>& settings):56 const std::shared_ptr<const Settings>& settings):
56 m_engine(engine),57 m_engine(engine),
58 m_sound_builder(sound_builder),
57 m_settings(settings),59 m_settings(settings),
58 m_cancellable(g_cancellable_new())60 m_cancellable(g_cancellable_new())
59 {61 {
@@ -97,10 +99,10 @@
97 if (appointment.is_ubuntu_alarm() || !silent_mode()) {99 if (appointment.is_ubuntu_alarm() || !silent_mode()) {
98 // create the sound.100 // create the sound.
99 const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";101 const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";
100 const auto uri = get_alarm_uri(alarm, m_settings);102 const auto uri = get_alarm_uri(appointment, alarm, m_settings);
101 const auto volume = m_settings->alarm_volume.get();103 const auto volume = m_settings->alarm_volume.get();
102 const bool loop = interactive;104 const bool loop = interactive;
103 sound = std::make_shared<uin::Sound>(role, uri, volume, loop);105 sound = m_sound_builder->create(role, uri, volume, loop);
104 }106 }
105107
106 // create the haptic feedback...108 // create the haptic feedback...
@@ -189,14 +191,16 @@
189 && (accounts_service_sound_get_other_vibrate(m_accounts_service_sound_proxy));191 && (accounts_service_sound_get_other_vibrate(m_accounts_service_sound_proxy));
190 }192 }
191193
192 std::string get_alarm_uri(const Alarm& alarm,194 std::string get_alarm_uri(const Appointment& appointment,
195 const Alarm& alarm,
193 const std::shared_ptr<const Settings>& settings) const196 const std::shared_ptr<const Settings>& settings) const
194 {197 {
195 const char* FALLBACK {"/usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg"};198 const auto is_alarm = appointment.is_ubuntu_alarm();
196199 const std::string candidates[] = {
197 const std::string candidates[] = { alarm.audio_url,200 alarm.audio_url,
198 settings->alarm_sound.get(),201 is_alarm ? settings->alarm_sound.get() : settings->calendar_sound.get(),
199 FALLBACK };202 is_alarm ? ALARM_DEFAULT_SOUND : CALENDAR_DEFAULT_SOUND
203 };
200204
201 std::string uri;205 std::string uri;
202206
@@ -223,6 +227,7 @@
223 }227 }
224228
225 const std::shared_ptr<unity::indicator::notifications::Engine> m_engine;229 const std::shared_ptr<unity::indicator::notifications::Engine> m_engine;
230 const std::shared_ptr<unity::indicator::notifications::SoundBuilder> m_sound_builder;
226 const std::shared_ptr<const Settings> m_settings;231 const std::shared_ptr<const Settings> m_settings;
227 std::set<int> m_notifications;232 std::set<int> m_notifications;
228 GCancellable * m_cancellable {nullptr};233 GCancellable * m_cancellable {nullptr};
@@ -234,8 +239,9 @@
234***/239***/
235240
236Snap::Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine,241Snap::Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine,
242 const std::shared_ptr<unity::indicator::notifications::SoundBuilder>& sound_builder,
237 const std::shared_ptr<const Settings>& settings):243 const std::shared_ptr<const Settings>& settings):
238 impl(new Impl(engine, settings))244 impl(new Impl(engine, sound_builder, settings))
239{245{
240}246}
241247
242248
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-07-10 17:29:12 +0000
+++ tests/CMakeLists.txt 2015-10-14 02:18:01 +0000
@@ -73,6 +73,8 @@
7373
74function(add_eds_ics_test_by_name name)74function(add_eds_ics_test_by_name name)
75 set (TEST_NAME ${name})75 set (TEST_NAME ${name})
76 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.ics.in"
77 "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.ics")
76 add_executable(${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)78 add_executable(${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
77 target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})79 target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
78 add_test (${TEST_NAME}80 add_test (${TEST_NAME}
@@ -81,7 +83,7 @@
81 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} # arg2: test executable path83 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} # arg2: test executable path
82 ${TEST_NAME} # arg3: test name84 ${TEST_NAME} # arg3: test name
83 ${CMAKE_CURRENT_SOURCE_DIR}/test-eds-ics-config-files # arg4: base directory for config file template85 ${CMAKE_CURRENT_SOURCE_DIR}/test-eds-ics-config-files # arg4: base directory for config file template
84 ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.ics) # arg5: the ical file for this test86 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.ics) # arg5: the ical file for this test
85endfunction()87endfunction()
86add_eds_ics_test_by_name(test-eds-ics-all-day-events)88add_eds_ics_test_by_name(test-eds-ics-all-day-events)
87add_eds_ics_test_by_name(test-eds-ics-repeating-events)89add_eds_ics_test_by_name(test-eds-ics-repeating-events)
8890
=== modified file 'tests/manual-test-snap.cpp'
--- tests/manual-test-snap.cpp 2015-04-05 22:27:52 +0000
+++ tests/manual-test-snap.cpp 2015-10-14 02:18:01 +0000
@@ -92,7 +92,8 @@
92 settings->alarm_volume.set(volume);92 settings->alarm_volume.set(volume);
9393
94 auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service");94 auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service");
95 Snap snap (notification_engine, settings);95 auto sound_builder = std::make_shared<uin::DefaultSoundBuilder>();
96 Snap snap (notification_engine, sound_builder, settings);
96 snap(a, a.alarms.front(), on_snooze, on_ok);97 snap(a, a.alarms.front(), on_snooze, on_ok);
97 g_main_loop_run(loop);98 g_main_loop_run(loop);
9899
99100
=== renamed file 'tests/test-eds-ics-all-day-events.ics' => 'tests/test-eds-ics-all-day-events.ics.in'
=== modified file 'tests/test-eds-ics-missing-trigger.cpp'
--- tests/test-eds-ics-missing-trigger.cpp 2015-10-07 14:07:15 +0000
+++ tests/test-eds-ics-missing-trigger.cpp 2015-10-14 02:18:01 +0000
@@ -77,7 +77,7 @@
77 a.begin = DateTime { gtz, 2015, 6, 18, 10, 0, 0};77 a.begin = DateTime { gtz, 2015, 6, 18, 10, 0, 0};
78 a.end = a.begin;78 a.end = a.begin;
79 a.alarms.resize(1);79 a.alarms.resize(1);
80 a.alarms[0].audio_url = "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg";80 a.alarms[0].audio_url = "file://" ALARM_DEFAULT_SOUND;
81 a.alarms[0].time = a.begin;81 a.alarms[0].time = a.begin;
82 a.alarms[0].text = a.summary;82 a.alarms[0].text = a.summary;
83 expected.push_back(a);83 expected.push_back(a);
8484
=== renamed file 'tests/test-eds-ics-missing-trigger.ics' => 'tests/test-eds-ics-missing-trigger.ics.in'
--- tests/test-eds-ics-missing-trigger.ics 2015-10-07 14:07:15 +0000
+++ tests/test-eds-ics-missing-trigger.ics.in 2015-10-14 02:18:01 +0000
@@ -14,7 +14,7 @@
14BEGIN:VALARM14BEGIN:VALARM
15X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-2@ubuntu-phablet15X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-2@ubuntu-phablet
16ACTION:AUDIO16ACTION:AUDIO
17ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg17ATTACH:file://@ALARM_DEFAULT_SOUND@
18END:VALARM18END:VALARM
19BEGIN:VALARM19BEGIN:VALARM
20X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-3@ubuntu-phablet20X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-3@ubuntu-phablet
@@ -34,7 +34,7 @@
34BEGIN:VALARM34BEGIN:VALARM
35X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-6@ubuntu-phablet35X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-6@ubuntu-phablet
36ACTION:AUDIO36ACTION:AUDIO
37ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg37ATTACH:file://@ALARM_DEFAULT_SOUND@
38END:VALARM38END:VALARM
39BEGIN:VALARM39BEGIN:VALARM
40X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-7@ubuntu-phablet40X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-7@ubuntu-phablet
4141
=== modified file 'tests/test-eds-ics-nonrepeating-events.cpp'
--- tests/test-eds-ics-nonrepeating-events.cpp 2015-10-07 14:07:15 +0000
+++ tests/test-eds-ics-nonrepeating-events.cpp 2015-10-14 02:18:01 +0000
@@ -73,7 +73,7 @@
73 expected_appt.color = "#becedd";73 expected_appt.color = "#becedd";
74 expected_appt.summary = "Alarm";74 expected_appt.summary = "Alarm";
75 std::array<Alarm,1> expected_alarms = {75 std::array<Alarm,1> expected_alarms = {
76 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,5,20,20,00,0)})76 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,20,20,00,0)})
77 };77 };
7878
79 // compare it to what we actually loaded...79 // compare it to what we actually loaded...
8080
=== renamed file 'tests/test-eds-ics-nonrepeating-events.ics' => 'tests/test-eds-ics-nonrepeating-events.ics.in'
--- tests/test-eds-ics-nonrepeating-events.ics 2015-10-07 14:07:15 +0000
+++ tests/test-eds-ics-nonrepeating-events.ics.in 2015-10-14 02:18:01 +0000
@@ -14,7 +14,7 @@
14BEGIN:VALARM14BEGIN:VALARM
15X-EVOLUTION-ALARM-UID:20150520T223932Z-22506-32011-1771-2@ubuntu-phablet15X-EVOLUTION-ALARM-UID:20150520T223932Z-22506-32011-1771-2@ubuntu-phablet
16ACTION:AUDIO16ACTION:AUDIO
17ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg17ATTACH:file://@ALARM_DEFAULT_SOUND@
18TRIGGER;VALUE=DURATION;RELATED=START:PT0S18TRIGGER;VALUE=DURATION;RELATED=START:PT0S
19END:VALARM19END:VALARM
20BEGIN:VALARM20BEGIN:VALARM
2121
=== modified file 'tests/test-eds-ics-repeating-events.cpp'
--- tests/test-eds-ics-repeating-events.cpp 2015-10-07 14:07:15 +0000
+++ tests/test-eds-ics-repeating-events.cpp 2015-10-14 02:18:01 +0000
@@ -73,14 +73,14 @@
73 expected_appt.color = "#becedd";73 expected_appt.color = "#becedd";
74 expected_appt.summary = "Alarm";74 expected_appt.summary = "Alarm";
75 std::array<Alarm,8> expected_alarms = {75 std::array<Alarm,8> expected_alarms = {
76 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,5, 8,16,40,0)}),76 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5, 8,16,40,0)}),
77 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,5,15,16,40,0)}),77 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,15,16,40,0)}),
78 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,5,22,16,40,0)}),78 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,22,16,40,0)}),
79 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,5,29,16,40,0)}),79 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,29,16,40,0)}),
80 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,6, 5,16,40,0)}),80 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6, 5,16,40,0)}),
81 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,6,12,16,40,0)}),81 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,12,16,40,0)}),
82 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,6,19,16,40,0)}),82 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,19,16,40,0)}),
83 Alarm({"Alarm", "file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg", DateTime(gtz,2015,6,26,16,40,0)})83 Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,6,26,16,40,0)})
84 };84 };
8585
86 // compare it to what we actually loaded...86 // compare it to what we actually loaded...
8787
=== renamed file 'tests/test-eds-ics-repeating-events.ics' => 'tests/test-eds-ics-repeating-events.ics.in'
--- tests/test-eds-ics-repeating-events.ics 2015-10-07 14:07:15 +0000
+++ tests/test-eds-ics-repeating-events.ics.in 2015-10-14 02:18:01 +0000
@@ -15,7 +15,7 @@
15BEGIN:VALARM15BEGIN:VALARM
16X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-2@ubuntu-phablet16X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-2@ubuntu-phablet
17ACTION:AUDIO17ACTION:AUDIO
18ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg18ATTACH:file://@ALARM_DEFAULT_SOUND@
19TRIGGER;VALUE=DURATION;RELATED=START:PT0S19TRIGGER;VALUE=DURATION;RELATED=START:PT0S
20END:VALARM20END:VALARM
21BEGIN:VALARM21BEGIN:VALARM
2222
=== renamed file 'tests/test-eds-ics-repeating-valarms.ics' => 'tests/test-eds-ics-repeating-valarms.ics.in'
=== renamed file 'tests/test-eds-ics-tzids-2.ics' => 'tests/test-eds-ics-tzids-2.ics.in'
=== renamed file 'tests/test-eds-ics-tzids.ics' => 'tests/test-eds-ics-tzids.ics.in'
=== modified file 'tests/test-settings.cpp'
--- tests/test-settings.cpp 2014-09-17 16:51:51 +0000
+++ tests/test-settings.cpp 2015-10-14 02:18:01 +0000
@@ -160,6 +160,7 @@
160 TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S);160 TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S);
161 TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S);161 TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S);
162 TestStringProperty(m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S);162 TestStringProperty(m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S);
163 TestStringProperty(m_settings->calendar_sound, SETTINGS_CALENDAR_SOUND_S);
163 TestStringProperty(m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S);164 TestStringProperty(m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S);
164}165}
165166
166167
=== modified file 'tests/test-snap.cpp'
--- tests/test-snap.cpp 2015-04-08 23:48:24 +0000
+++ tests/test-snap.cpp 2015-10-14 02:18:01 +0000
@@ -34,6 +34,8 @@
3434
35using namespace unity::indicator::datetime;35using namespace unity::indicator::datetime;
3636
37namespace uin = unity::indicator::notifications;
38
37#include "glib-fixture.h"39#include "glib-fixture.h"
3840
39/***41/***
@@ -92,6 +94,7 @@
92 static constexpr char const * PROP_SILENT_MODE {"SilentMode"};94 static constexpr char const * PROP_SILENT_MODE {"SilentMode"};
9395
94 Appointment appt;96 Appointment appt;
97 Appointment ualarm;
95 GDBusConnection * system_bus = nullptr;98 GDBusConnection * system_bus = nullptr;
96 GDBusConnection * session_bus = nullptr;99 GDBusConnection * session_bus = nullptr;
97 DbusTestService * service = nullptr;100 DbusTestService * service = nullptr;
@@ -113,15 +116,25 @@
113116
114 super::SetUp();117 super::SetUp();
115118
116 // init the Appointment119 // init an Appointment
117 appt.color = "green";120 appt.color = "green";
118 appt.summary = "Alarm";121 appt.summary = "Christmas";
119 appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";122 appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402";
120 appt.type = Appointment::EVENT;123 appt.type = Appointment::EVENT;
121 const auto christmas = DateTime::Local(2015,12,25,0,0,0);124 const auto christmas = DateTime::Local(2015,12,25,0,0,0);
122 appt.begin = christmas.start_of_day();125 appt.begin = christmas.start_of_day();
123 appt.end = christmas.end_of_day();126 appt.end = christmas.end_of_day();
124 appt.alarms.push_back(Alarm{"Alarm Text", "", appt.begin});127 appt.alarms.push_back(Alarm{"Ho Ho Ho!", "", appt.begin});
128
129 // init an Ubuntu Alarm
130 ualarm.color = "red";
131 ualarm.summary = "Wakeup";
132 ualarm.uid = "E4B57D50247291478ED31DED17FF0A9838DED403";
133 ualarm.type = Appointment::UBUNTU_ALARM;
134 const auto tomorrow = DateTime::NowLocal().add_days(1);
135 ualarm.begin = tomorrow;
136 ualarm.end = tomorrow;
137 ualarm.alarms.push_back(Alarm{"It's Tomorrow!", "", appt.begin});
125138
126 service = dbus_test_service_new(nullptr);139 service = dbus_test_service_new(nullptr);
127140
@@ -360,6 +373,15 @@
360 &error);373 &error);
361 g_assert_no_error (error);374 g_assert_no_error (error);
362 }375 }
376
377 std::shared_ptr<Snap> create_snap(const std::shared_ptr<uin::Engine>& ne,
378 const std::shared_ptr<uin::SoundBuilder>& sb,
379 const std::shared_ptr<Settings>& settings)
380 {
381 auto snap = std::make_shared<Snap>(ne, sb, settings);
382 wait_msec(100); // wait a moment for the Snap to finish its async dbus bootstrapping
383 return snap;
384 }
363};385};
364386
365/***387/***
@@ -381,13 +403,14 @@
381 auto settings = std::make_shared<Settings>();403 auto settings = std::make_shared<Settings>();
382 settings->alarm_duration.set(duration_minutes);404 settings->alarm_duration.set(duration_minutes);
383 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);405 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);
384 Snap snap (ne, settings);406 auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>();
407 auto snap = create_snap(ne, sb, settings);
385408
386 make_interactive();409 make_interactive();
387410
388 // call the Snap Decision411 // call the Snap Decision
389 auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};412 auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
390 snap(appt, appt.alarms.front(), func, func);413 (*snap)(appt, appt.alarms.front(), func, func);
391414
392 // confirm that Notify got called once415 // confirm that Notify got called once
393 guint len = 0;416 guint len = 0;
@@ -431,7 +454,8 @@
431{454{
432 auto settings = std::make_shared<Settings>();455 auto settings = std::make_shared<Settings>();
433 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);456 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);
434 auto snap = new Snap (ne, settings);457 auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>();
458 auto snap = create_snap(ne, sb, settings);
435459
436 make_interactive();460 make_interactive();
437461
@@ -458,7 +482,7 @@
458482
459 // force-close the snap483 // force-close the snap
460 wait_msec(100);484 wait_msec(100);
461 delete snap;485 snap.reset();
462 wait_msec(100);486 wait_msec(100);
463487
464 // confirm that sleep got uninhibted488 // confirm that sleep got uninhibted
@@ -486,7 +510,8 @@
486{510{
487 auto settings = std::make_shared<Settings>();511 auto settings = std::make_shared<Settings>();
488 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);512 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);
489 auto snap = new Snap (ne, settings);513 auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>();
514 auto snap = create_snap(ne, sb, settings);
490515
491 make_interactive();516 make_interactive();
492517
@@ -507,7 +532,7 @@
507532
508 // force-close the snap533 // force-close the snap
509 wait_msec(100);534 wait_msec(100);
510 delete snap;535 snap.reset();
511 wait_msec(100);536 wait_msec(100);
512537
513 // confirm that sleep got uninhibted538 // confirm that sleep got uninhibted
@@ -527,6 +552,7 @@
527{552{
528 auto settings = std::make_shared<Settings>();553 auto settings = std::make_shared<Settings>();
529 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);554 auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME);
555 auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>();
530 auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};556 auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
531 GError * error = nullptr;557 GError * error = nullptr;
532558
@@ -541,7 +567,7 @@
541 { true, "pulse", true }567 { true, "pulse", true }
542 };568 };
543569
544 auto snap = std::make_shared<Snap>(ne, settings);570 auto snap = create_snap(ne, sb, settings);
545571
546 for(const auto& test_case : test_cases)572 for(const auto& test_case : test_cases)
547 {573 {
@@ -570,3 +596,74 @@
570 EXPECT_EQ(test_case.expected_vibrate_called, vibrate_called);596 EXPECT_EQ(test_case.expected_vibrate_called, vibrate_called);
571 }597 }
572}598}
599
600/***
601****
602***/
603
604/**
605 * A DefaultSoundBuilder wrapper which remembers the parameters of the last sound created.
606 */
607class TestSoundBuilder: public uin::SoundBuilder
608{
609public:
610 TestSoundBuilder() =default;
611 ~TestSoundBuilder() =default;
612
613 virtual std::shared_ptr<uin::Sound> create(const std::string& role, const std::string& uri, unsigned int volume, bool loop) override {
614 m_role = role;
615 m_uri = uri;
616 m_volume = volume;
617 m_loop = loop;
618 return m_impl.create(role, uri, volume, loop);
619 }
620
621 const std::string& role() { return m_role; }
622 const std::string& uri() { return m_uri; }
623 unsigned int volume() { return m_volume; }
624 bool loop() { return m_loop; }
625
626private:
627 std::string m_role;
628 std::string m_uri;
629 unsigned int m_volume;
630 bool m_loop;
631 uin::DefaultSoundBuilder m_impl;
632};
633
634std::string path_to_uri(const std::string& path)
635{
636 auto file = g_file_new_for_path(path.c_str());
637 auto uri_cstr = g_file_get_uri(file);
638 std::string uri = uri_cstr;
639 g_free(uri_cstr);
640 g_clear_pointer(&file, g_object_unref);
641 return uri;
642}
643
644TEST_F(SnapFixture,DefaultSounds)
645{
646 auto settings = std::make_shared<Settings>();
647 auto ne = std::make_shared<uin::Engine>(APP_NAME);
648 auto sb = std::make_shared<TestSoundBuilder>();
649 auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
650
651 const struct {
652 Appointment appointment;
653 std::string expected_role;
654 std::string expected_uri;
655 } test_cases[] = {
656 { ualarm, "alarm", path_to_uri(ALARM_DEFAULT_SOUND) },
657 { appt, "alert", path_to_uri(CALENDAR_DEFAULT_SOUND) }
658 };
659
660 auto snap = create_snap(ne, sb, settings);
661
662 for(const auto& test_case : test_cases)
663 {
664 (*snap)(test_case.appointment, test_case.appointment.alarms.front(), func, func);
665 wait_msec(100);
666 EXPECT_EQ(test_case.expected_uri, sb->uri());
667 EXPECT_EQ(test_case.expected_role, sb->role());
668 }
669}

Subscribers

People subscribed via source and target branches