Merge lp:~charlesk/indicator-datetime/15.04-lp-1505688-different-default-sounds-for-alarms-and-events into lp:indicator-datetime/15.04
- 15.04-lp-1505688-different-default-sounds-for-alarms-and-events
- Merge into trunk.15.04
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 |
Related bugs: |
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
* 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.
PS Jenkins bot (ps-jenkins) wrote : | # |
dobey (dobey) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:422
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:422
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
dobey (dobey) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:422
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:422
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:422
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:422
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:422
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2014-08-19 04:03:38 +0000 | |||
3 | +++ CMakeLists.txt 2015-10-14 02:18:01 +0000 | |||
4 | @@ -9,6 +9,12 @@ | |||
5 | 9 | add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" | 9 | add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" |
6 | 10 | -DGNOMELOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}") | 10 | -DGNOMELOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}") |
7 | 11 | 11 | ||
8 | 12 | set(ALARM_DEFAULT_SOUND "/usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg") | ||
9 | 13 | set(CALENDAR_DEFAULT_SOUND "/usr/share/sounds/ubuntu/ringtones/Marimbach.ogg") | ||
10 | 14 | add_definitions(-DALARM_DEFAULT_SOUND="${ALARM_DEFAULT_SOUND}" | ||
11 | 15 | -DCALENDAR_DEFAULT_SOUND="${CALENDAR_DEFAULT_SOUND}") | ||
12 | 16 | |||
13 | 17 | |||
14 | 12 | option (enable_tests "Build the package's automatic tests." ON) | 18 | option (enable_tests "Build the package's automatic tests." ON) |
15 | 13 | option (enable_lcov "Generate lcov code coverage reports." ON) | 19 | option (enable_lcov "Generate lcov code coverage reports." ON) |
16 | 14 | 20 | ||
17 | 15 | 21 | ||
18 | === modified file 'data/CMakeLists.txt' | |||
19 | --- data/CMakeLists.txt 2014-06-27 13:53:13 +0000 | |||
20 | +++ data/CMakeLists.txt 2015-10-14 02:18:01 +0000 | |||
21 | @@ -4,9 +4,11 @@ | |||
22 | 4 | 4 | ||
23 | 5 | include (UseGSettings) | 5 | include (UseGSettings) |
24 | 6 | set (SCHEMA_NAME "com.canonical.indicator.datetime.gschema.xml") | 6 | set (SCHEMA_NAME "com.canonical.indicator.datetime.gschema.xml") |
28 | 7 | set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}") | 7 | set (SCHEMA_FILE_IN_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}.in.in") |
29 | 8 | set (SCHEMA_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}.in") | 8 | set (SCHEMA_FILE_IN "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}.in") |
30 | 9 | 9 | set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}") | |
31 | 10 | # generate the .xml.in file so cmake constants are included | ||
32 | 11 | configure_file(${SCHEMA_FILE_IN_IN} ${SCHEMA_FILE_IN}) | ||
33 | 10 | # generate the .xml file using intltool | 12 | # generate the .xml file using intltool |
34 | 11 | set (ENV{LC_ALL} "C") | 13 | set (ENV{LC_ALL} "C") |
35 | 12 | execute_process (COMMAND intltool-merge -quiet --xml-style --utf8 --no-translations "${SCHEMA_FILE_IN}" "${SCHEMA_FILE}") | 14 | execute_process (COMMAND intltool-merge -quiet --xml-style --utf8 --no-translations "${SCHEMA_FILE_IN}" "${SCHEMA_FILE}") |
36 | 13 | 15 | ||
37 | === renamed file 'data/com.canonical.indicator.datetime.gschema.xml.in' => 'data/com.canonical.indicator.datetime.gschema.xml.in.in' | |||
38 | --- data/com.canonical.indicator.datetime.gschema.xml.in 2015-10-07 14:07:15 +0000 | |||
39 | +++ data/com.canonical.indicator.datetime.gschema.xml.in.in 2015-10-14 02:18:01 +0000 | |||
40 | @@ -131,8 +131,15 @@ | |||
41 | 131 | Two modes are currently supported: 'pulse', 'none'. | 131 | Two modes are currently supported: 'pulse', 'none'. |
42 | 132 | </_description> | 132 | </_description> |
43 | 133 | </key> | 133 | </key> |
44 | 134 | <key name="calendar-default-sound" type="s"> | ||
45 | 135 | <default>'@CALENDAR_DEFAULT_SOUND@'</default> | ||
46 | 136 | <_summary>The calendar's default sound file.</_summary> | ||
47 | 137 | <_description> | ||
48 | 138 | If a calendar or reminder event doesn't specify its own sound file, this file will be used as the fallback sound. | ||
49 | 139 | </_description> | ||
50 | 140 | </key> | ||
51 | 134 | <key name="alarm-default-sound" type="s"> | 141 | <key name="alarm-default-sound" type="s"> |
53 | 135 | <default>'/usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg'</default> | 142 | <default>'@ALARM_DEFAULT_SOUND@'</default> |
54 | 136 | <_summary>The alarm's default sound file.</_summary> | 143 | <_summary>The alarm's default sound file.</_summary> |
55 | 137 | <_description> | 144 | <_description> |
56 | 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. |
57 | 139 | 146 | ||
58 | === modified file 'debian/control' | |||
59 | --- debian/control 2015-04-06 14:25:59 +0000 | |||
60 | +++ debian/control 2015-10-14 02:18:01 +0000 | |||
61 | @@ -27,6 +27,8 @@ | |||
62 | 27 | # for running live EDS tests: | 27 | # for running live EDS tests: |
63 | 28 | evolution-data-server, | 28 | evolution-data-server, |
64 | 29 | gvfs-daemons, | 29 | gvfs-daemons, |
65 | 30 | # for phone alarm/calendar notification sound tests: | ||
66 | 31 | ubuntu-touch-sounds, | ||
67 | 30 | Standards-Version: 3.9.3 | 32 | Standards-Version: 3.9.3 |
68 | 31 | Homepage: https://launchpad.net/indicator-datetime | 33 | Homepage: https://launchpad.net/indicator-datetime |
69 | 32 | # If you aren't a member of ~indicator-applet-developers but need to upload | 34 | # If you aren't a member of ~indicator-applet-developers but need to upload |
70 | 33 | 35 | ||
71 | === modified file 'include/datetime/settings-live.h' | |||
72 | --- include/datetime/settings-live.h 2014-09-02 15:37:03 +0000 | |||
73 | +++ include/datetime/settings-live.h 2015-10-14 02:18:01 +0000 | |||
74 | @@ -55,6 +55,7 @@ | |||
75 | 55 | void update_show_year(); | 55 | void update_show_year(); |
76 | 56 | void update_time_format_mode(); | 56 | void update_time_format_mode(); |
77 | 57 | void update_timezone_name(); | 57 | void update_timezone_name(); |
78 | 58 | void update_calendar_sound(); | ||
79 | 58 | void update_alarm_sound(); | 59 | void update_alarm_sound(); |
80 | 59 | void update_alarm_volume(); | 60 | void update_alarm_volume(); |
81 | 60 | void update_alarm_duration(); | 61 | void update_alarm_duration(); |
82 | 61 | 62 | ||
83 | === modified file 'include/datetime/settings-shared.h' | |||
84 | --- include/datetime/settings-shared.h 2014-09-02 15:37:03 +0000 | |||
85 | +++ include/datetime/settings-shared.h 2015-10-14 02:18:01 +0000 | |||
86 | @@ -45,6 +45,7 @@ | |||
87 | 45 | #define SETTINGS_SHOW_DETECTED_S "show-auto-detected-location" | 45 | #define SETTINGS_SHOW_DETECTED_S "show-auto-detected-location" |
88 | 46 | #define SETTINGS_LOCATIONS_S "locations" | 46 | #define SETTINGS_LOCATIONS_S "locations" |
89 | 47 | #define SETTINGS_TIMEZONE_NAME_S "timezone-name" | 47 | #define SETTINGS_TIMEZONE_NAME_S "timezone-name" |
90 | 48 | #define SETTINGS_CALENDAR_SOUND_S "calendar-default-sound" | ||
91 | 48 | #define SETTINGS_ALARM_SOUND_S "alarm-default-sound" | 49 | #define SETTINGS_ALARM_SOUND_S "alarm-default-sound" |
92 | 49 | #define SETTINGS_ALARM_VOLUME_S "alarm-default-volume" | 50 | #define SETTINGS_ALARM_VOLUME_S "alarm-default-volume" |
93 | 50 | #define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes" | 51 | #define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes" |
94 | 51 | 52 | ||
95 | === modified file 'include/datetime/settings.h' | |||
96 | --- include/datetime/settings.h 2014-09-02 15:37:03 +0000 | |||
97 | +++ include/datetime/settings.h 2015-10-14 02:18:01 +0000 | |||
98 | @@ -56,6 +56,7 @@ | |||
99 | 56 | core::Property<bool> show_year; | 56 | core::Property<bool> show_year; |
100 | 57 | core::Property<TimeFormatMode> time_format_mode; | 57 | core::Property<TimeFormatMode> time_format_mode; |
101 | 58 | core::Property<std::string> timezone_name; | 58 | core::Property<std::string> timezone_name; |
102 | 59 | core::Property<std::string> calendar_sound; | ||
103 | 59 | core::Property<std::string> alarm_sound; | 60 | core::Property<std::string> alarm_sound; |
104 | 60 | core::Property<std::string> alarm_haptic; | 61 | core::Property<std::string> alarm_haptic; |
105 | 61 | core::Property<unsigned int> alarm_volume; | 62 | core::Property<unsigned int> alarm_volume; |
106 | 62 | 63 | ||
107 | === modified file 'include/datetime/snap.h' | |||
108 | --- include/datetime/snap.h 2015-03-31 23:54:04 +0000 | |||
109 | +++ include/datetime/snap.h 2015-10-14 02:18:01 +0000 | |||
110 | @@ -24,6 +24,7 @@ | |||
111 | 24 | #include <datetime/settings.h> | 24 | #include <datetime/settings.h> |
112 | 25 | 25 | ||
113 | 26 | #include <notifications/notifications.h> | 26 | #include <notifications/notifications.h> |
114 | 27 | #include <notifications/sound.h> | ||
115 | 27 | 28 | ||
116 | 28 | #include <functional> | 29 | #include <functional> |
117 | 29 | #include <memory> | 30 | #include <memory> |
118 | @@ -39,6 +40,7 @@ | |||
119 | 39 | { | 40 | { |
120 | 40 | public: | 41 | public: |
121 | 41 | Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine, | 42 | Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine, |
122 | 43 | const std::shared_ptr<unity::indicator::notifications::SoundBuilder>& sound_builder, | ||
123 | 42 | const std::shared_ptr<const Settings>& settings); | 44 | const std::shared_ptr<const Settings>& settings); |
124 | 43 | virtual ~Snap(); | 45 | virtual ~Snap(); |
125 | 44 | 46 | ||
126 | 45 | 47 | ||
127 | === modified file 'include/notifications/sound.h' | |||
128 | --- include/notifications/sound.h 2015-01-22 01:57:59 +0000 | |||
129 | +++ include/notifications/sound.h 2015-10-14 02:18:01 +0000 | |||
130 | @@ -53,6 +53,28 @@ | |||
131 | 53 | **** | 53 | **** |
132 | 54 | ***/ | 54 | ***/ |
133 | 55 | 55 | ||
134 | 56 | class SoundBuilder | ||
135 | 57 | { | ||
136 | 58 | public: | ||
137 | 59 | SoundBuilder() =default; | ||
138 | 60 | virtual ~SoundBuilder() =default; | ||
139 | 61 | virtual std::shared_ptr<Sound> create(const std::string& role, const std::string& uri, unsigned int volume, bool loop) =0; | ||
140 | 62 | }; | ||
141 | 63 | |||
142 | 64 | class DefaultSoundBuilder: public SoundBuilder | ||
143 | 65 | { | ||
144 | 66 | public: | ||
145 | 67 | DefaultSoundBuilder() =default; | ||
146 | 68 | ~DefaultSoundBuilder() =default; | ||
147 | 69 | virtual std::shared_ptr<Sound> create(const std::string& role, const std::string& uri, unsigned int volume, bool loop) override { | ||
148 | 70 | return std::make_shared<Sound>(role, uri, volume, loop); | ||
149 | 71 | } | ||
150 | 72 | }; | ||
151 | 73 | |||
152 | 74 | /*** | ||
153 | 75 | **** | ||
154 | 76 | ***/ | ||
155 | 77 | |||
156 | 56 | } // namespace notifications | 78 | } // namespace notifications |
157 | 57 | } // namespace indicator | 79 | } // namespace indicator |
158 | 58 | } // namespace unity | 80 | } // namespace unity |
159 | 59 | 81 | ||
160 | === modified file 'src/main.cpp' | |||
161 | --- src/main.cpp 2015-04-03 18:11:39 +0000 | |||
162 | +++ src/main.cpp 2015-10-14 02:18:01 +0000 | |||
163 | @@ -136,7 +136,8 @@ | |||
164 | 136 | // set up the snap decisions | 136 | // set up the snap decisions |
165 | 137 | auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock); | 137 | auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock); |
166 | 138 | auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service"); | 138 | auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service"); |
168 | 139 | std::unique_ptr<Snap> snap (new Snap(notification_engine, state->settings)); | 139 | auto sound_builder = std::make_shared<uin::DefaultSoundBuilder>(); |
169 | 140 | std::unique_ptr<Snap> snap (new Snap(notification_engine, sound_builder, state->settings)); | ||
170 | 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_); |
171 | 141 | auto on_snooze = [snooze_planner](const Appointment& appointment, const Alarm& alarm) { | 142 | auto on_snooze = [snooze_planner](const Appointment& appointment, const Alarm& alarm) { |
172 | 142 | snooze_planner->add(appointment, alarm); | 143 | snooze_planner->add(appointment, alarm); |
173 | 143 | 144 | ||
174 | === modified file 'src/settings-live.cpp' | |||
175 | --- src/settings-live.cpp 2014-09-02 15:37:03 +0000 | |||
176 | +++ src/settings-live.cpp 2015-10-14 02:18:01 +0000 | |||
177 | @@ -52,6 +52,7 @@ | |||
178 | 52 | update_show_year(); | 52 | update_show_year(); |
179 | 53 | update_time_format_mode(); | 53 | update_time_format_mode(); |
180 | 54 | update_timezone_name(); | 54 | update_timezone_name(); |
181 | 55 | update_calendar_sound(); | ||
182 | 55 | update_alarm_sound(); | 56 | update_alarm_sound(); |
183 | 56 | update_alarm_volume(); | 57 | update_alarm_volume(); |
184 | 57 | update_alarm_duration(); | 58 | update_alarm_duration(); |
185 | @@ -121,6 +122,10 @@ | |||
186 | 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()); |
187 | 122 | }); | 123 | }); |
188 | 123 | 124 | ||
189 | 125 | calendar_sound.changed().connect([this](const std::string& value){ | ||
190 | 126 | g_settings_set_string(m_settings, SETTINGS_CALENDAR_SOUND_S, value.c_str()); | ||
191 | 127 | }); | ||
192 | 128 | |||
193 | 124 | alarm_sound.changed().connect([this](const std::string& value){ | 129 | alarm_sound.changed().connect([this](const std::string& value){ |
194 | 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()); |
195 | 126 | }); | 131 | }); |
196 | @@ -230,6 +235,13 @@ | |||
197 | 230 | g_free(val); | 235 | g_free(val); |
198 | 231 | } | 236 | } |
199 | 232 | 237 | ||
200 | 238 | void LiveSettings::update_calendar_sound() | ||
201 | 239 | { | ||
202 | 240 | auto val = g_settings_get_string(m_settings, SETTINGS_CALENDAR_SOUND_S); | ||
203 | 241 | calendar_sound.set(val); | ||
204 | 242 | g_free(val); | ||
205 | 243 | } | ||
206 | 244 | |||
207 | 233 | void LiveSettings::update_alarm_sound() | 245 | void LiveSettings::update_alarm_sound() |
208 | 234 | { | 246 | { |
209 | 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); |
210 | @@ -300,6 +312,8 @@ | |||
211 | 300 | update_show_detected_locations(); | 312 | update_show_detected_locations(); |
212 | 301 | else if (key == SETTINGS_TIMEZONE_NAME_S) | 313 | else if (key == SETTINGS_TIMEZONE_NAME_S) |
213 | 302 | update_timezone_name(); | 314 | update_timezone_name(); |
214 | 315 | else if (key == SETTINGS_CALENDAR_SOUND_S) | ||
215 | 316 | update_calendar_sound(); | ||
216 | 303 | else if (key == SETTINGS_ALARM_SOUND_S) | 317 | else if (key == SETTINGS_ALARM_SOUND_S) |
217 | 304 | update_alarm_sound(); | 318 | update_alarm_sound(); |
218 | 305 | else if (key == SETTINGS_ALARM_VOLUME_S) | 319 | else if (key == SETTINGS_ALARM_VOLUME_S) |
219 | 306 | 320 | ||
220 | === modified file 'src/snap.cpp' | |||
221 | --- src/snap.cpp 2015-10-07 14:07:15 +0000 | |||
222 | +++ src/snap.cpp 2015-10-14 02:18:01 +0000 | |||
223 | @@ -52,8 +52,10 @@ | |||
224 | 52 | public: | 52 | public: |
225 | 53 | 53 | ||
226 | 54 | Impl(const std::shared_ptr<unity::indicator::notifications::Engine>& engine, | 54 | Impl(const std::shared_ptr<unity::indicator::notifications::Engine>& engine, |
227 | 55 | const std::shared_ptr<unity::indicator::notifications::SoundBuilder>& sound_builder, | ||
228 | 55 | const std::shared_ptr<const Settings>& settings): | 56 | const std::shared_ptr<const Settings>& settings): |
229 | 56 | m_engine(engine), | 57 | m_engine(engine), |
230 | 58 | m_sound_builder(sound_builder), | ||
231 | 57 | m_settings(settings), | 59 | m_settings(settings), |
232 | 58 | m_cancellable(g_cancellable_new()) | 60 | m_cancellable(g_cancellable_new()) |
233 | 59 | { | 61 | { |
234 | @@ -97,10 +99,10 @@ | |||
235 | 97 | if (appointment.is_ubuntu_alarm() || !silent_mode()) { | 99 | if (appointment.is_ubuntu_alarm() || !silent_mode()) { |
236 | 98 | // create the sound. | 100 | // create the sound. |
237 | 99 | const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert"; | 101 | const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert"; |
239 | 100 | const auto uri = get_alarm_uri(alarm, m_settings); | 102 | const auto uri = get_alarm_uri(appointment, alarm, m_settings); |
240 | 101 | const auto volume = m_settings->alarm_volume.get(); | 103 | const auto volume = m_settings->alarm_volume.get(); |
241 | 102 | const bool loop = interactive; | 104 | const bool loop = interactive; |
243 | 103 | sound = std::make_shared<uin::Sound>(role, uri, volume, loop); | 105 | sound = m_sound_builder->create(role, uri, volume, loop); |
244 | 104 | } | 106 | } |
245 | 105 | 107 | ||
246 | 106 | // create the haptic feedback... | 108 | // create the haptic feedback... |
247 | @@ -189,14 +191,16 @@ | |||
248 | 189 | && (accounts_service_sound_get_other_vibrate(m_accounts_service_sound_proxy)); | 191 | && (accounts_service_sound_get_other_vibrate(m_accounts_service_sound_proxy)); |
249 | 190 | } | 192 | } |
250 | 191 | 193 | ||
252 | 192 | std::string get_alarm_uri(const Alarm& alarm, | 194 | std::string get_alarm_uri(const Appointment& appointment, |
253 | 195 | const Alarm& alarm, | ||
254 | 193 | const std::shared_ptr<const Settings>& settings) const | 196 | const std::shared_ptr<const Settings>& settings) const |
255 | 194 | { | 197 | { |
261 | 195 | const char* FALLBACK {"/usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg"}; | 198 | const auto is_alarm = appointment.is_ubuntu_alarm(); |
262 | 196 | 199 | const std::string candidates[] = { | |
263 | 197 | const std::string candidates[] = { alarm.audio_url, | 200 | alarm.audio_url, |
264 | 198 | settings->alarm_sound.get(), | 201 | is_alarm ? settings->alarm_sound.get() : settings->calendar_sound.get(), |
265 | 199 | FALLBACK }; | 202 | is_alarm ? ALARM_DEFAULT_SOUND : CALENDAR_DEFAULT_SOUND |
266 | 203 | }; | ||
267 | 200 | 204 | ||
268 | 201 | std::string uri; | 205 | std::string uri; |
269 | 202 | 206 | ||
270 | @@ -223,6 +227,7 @@ | |||
271 | 223 | } | 227 | } |
272 | 224 | 228 | ||
273 | 225 | const std::shared_ptr<unity::indicator::notifications::Engine> m_engine; | 229 | const std::shared_ptr<unity::indicator::notifications::Engine> m_engine; |
274 | 230 | const std::shared_ptr<unity::indicator::notifications::SoundBuilder> m_sound_builder; | ||
275 | 226 | const std::shared_ptr<const Settings> m_settings; | 231 | const std::shared_ptr<const Settings> m_settings; |
276 | 227 | std::set<int> m_notifications; | 232 | std::set<int> m_notifications; |
277 | 228 | GCancellable * m_cancellable {nullptr}; | 233 | GCancellable * m_cancellable {nullptr}; |
278 | @@ -234,8 +239,9 @@ | |||
279 | 234 | ***/ | 239 | ***/ |
280 | 235 | 240 | ||
281 | 236 | Snap::Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine, | 241 | Snap::Snap(const std::shared_ptr<unity::indicator::notifications::Engine>& engine, |
282 | 242 | const std::shared_ptr<unity::indicator::notifications::SoundBuilder>& sound_builder, | ||
283 | 237 | const std::shared_ptr<const Settings>& settings): | 243 | const std::shared_ptr<const Settings>& settings): |
285 | 238 | impl(new Impl(engine, settings)) | 244 | impl(new Impl(engine, sound_builder, settings)) |
286 | 239 | { | 245 | { |
287 | 240 | } | 246 | } |
288 | 241 | 247 | ||
289 | 242 | 248 | ||
290 | === modified file 'tests/CMakeLists.txt' | |||
291 | --- tests/CMakeLists.txt 2015-07-10 17:29:12 +0000 | |||
292 | +++ tests/CMakeLists.txt 2015-10-14 02:18:01 +0000 | |||
293 | @@ -73,6 +73,8 @@ | |||
294 | 73 | 73 | ||
295 | 74 | function(add_eds_ics_test_by_name name) | 74 | function(add_eds_ics_test_by_name name) |
296 | 75 | set (TEST_NAME ${name}) | 75 | set (TEST_NAME ${name}) |
297 | 76 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.ics.in" | ||
298 | 77 | "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.ics") | ||
299 | 76 | add_executable(${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled) | 78 | add_executable(${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled) |
300 | 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}) |
301 | 78 | add_test (${TEST_NAME} | 80 | add_test (${TEST_NAME} |
302 | @@ -81,7 +83,7 @@ | |||
303 | 81 | ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} # arg2: test executable path | 83 | ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} # arg2: test executable path |
304 | 82 | ${TEST_NAME} # arg3: test name | 84 | ${TEST_NAME} # arg3: test name |
305 | 83 | ${CMAKE_CURRENT_SOURCE_DIR}/test-eds-ics-config-files # arg4: base directory for config file template | 85 | ${CMAKE_CURRENT_SOURCE_DIR}/test-eds-ics-config-files # arg4: base directory for config file template |
307 | 84 | ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.ics) # arg5: the ical file for this test | 86 | ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.ics) # arg5: the ical file for this test |
308 | 85 | endfunction() | 87 | endfunction() |
309 | 86 | add_eds_ics_test_by_name(test-eds-ics-all-day-events) | 88 | add_eds_ics_test_by_name(test-eds-ics-all-day-events) |
310 | 87 | add_eds_ics_test_by_name(test-eds-ics-repeating-events) | 89 | add_eds_ics_test_by_name(test-eds-ics-repeating-events) |
311 | 88 | 90 | ||
312 | === modified file 'tests/manual-test-snap.cpp' | |||
313 | --- tests/manual-test-snap.cpp 2015-04-05 22:27:52 +0000 | |||
314 | +++ tests/manual-test-snap.cpp 2015-10-14 02:18:01 +0000 | |||
315 | @@ -92,7 +92,8 @@ | |||
316 | 92 | settings->alarm_volume.set(volume); | 92 | settings->alarm_volume.set(volume); |
317 | 93 | 93 | ||
318 | 94 | auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service"); | 94 | auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service"); |
320 | 95 | Snap snap (notification_engine, settings); | 95 | auto sound_builder = std::make_shared<uin::DefaultSoundBuilder>(); |
321 | 96 | Snap snap (notification_engine, sound_builder, settings); | ||
322 | 96 | snap(a, a.alarms.front(), on_snooze, on_ok); | 97 | snap(a, a.alarms.front(), on_snooze, on_ok); |
323 | 97 | g_main_loop_run(loop); | 98 | g_main_loop_run(loop); |
324 | 98 | 99 | ||
325 | 99 | 100 | ||
326 | === renamed file 'tests/test-eds-ics-all-day-events.ics' => 'tests/test-eds-ics-all-day-events.ics.in' | |||
327 | === modified file 'tests/test-eds-ics-missing-trigger.cpp' | |||
328 | --- tests/test-eds-ics-missing-trigger.cpp 2015-10-07 14:07:15 +0000 | |||
329 | +++ tests/test-eds-ics-missing-trigger.cpp 2015-10-14 02:18:01 +0000 | |||
330 | @@ -77,7 +77,7 @@ | |||
331 | 77 | a.begin = DateTime { gtz, 2015, 6, 18, 10, 0, 0}; | 77 | a.begin = DateTime { gtz, 2015, 6, 18, 10, 0, 0}; |
332 | 78 | a.end = a.begin; | 78 | a.end = a.begin; |
333 | 79 | a.alarms.resize(1); | 79 | a.alarms.resize(1); |
335 | 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; |
336 | 81 | a.alarms[0].time = a.begin; | 81 | a.alarms[0].time = a.begin; |
337 | 82 | a.alarms[0].text = a.summary; | 82 | a.alarms[0].text = a.summary; |
338 | 83 | expected.push_back(a); | 83 | expected.push_back(a); |
339 | 84 | 84 | ||
340 | === renamed file 'tests/test-eds-ics-missing-trigger.ics' => 'tests/test-eds-ics-missing-trigger.ics.in' | |||
341 | --- tests/test-eds-ics-missing-trigger.ics 2015-10-07 14:07:15 +0000 | |||
342 | +++ tests/test-eds-ics-missing-trigger.ics.in 2015-10-14 02:18:01 +0000 | |||
343 | @@ -14,7 +14,7 @@ | |||
344 | 14 | BEGIN:VALARM | 14 | BEGIN:VALARM |
345 | 15 | X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-2@ubuntu-phablet | 15 | X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-2@ubuntu-phablet |
346 | 16 | ACTION:AUDIO | 16 | ACTION:AUDIO |
348 | 17 | ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg | 17 | ATTACH:file://@ALARM_DEFAULT_SOUND@ |
349 | 18 | END:VALARM | 18 | END:VALARM |
350 | 19 | BEGIN:VALARM | 19 | BEGIN:VALARM |
351 | 20 | X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-3@ubuntu-phablet | 20 | X-EVOLUTION-ALARM-UID:20150617T211838Z-6217-32011-2036-3@ubuntu-phablet |
352 | @@ -34,7 +34,7 @@ | |||
353 | 34 | BEGIN:VALARM | 34 | BEGIN:VALARM |
354 | 35 | X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-6@ubuntu-phablet | 35 | X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-6@ubuntu-phablet |
355 | 36 | ACTION:AUDIO | 36 | ACTION:AUDIO |
357 | 37 | ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg | 37 | ATTACH:file://@ALARM_DEFAULT_SOUND@ |
358 | 38 | END:VALARM | 38 | END:VALARM |
359 | 39 | BEGIN:VALARM | 39 | BEGIN:VALARM |
360 | 40 | X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-7@ubuntu-phablet | 40 | X-EVOLUTION-ALARM-UID:20150617T211913Z-6217-32011-2036-7@ubuntu-phablet |
361 | 41 | 41 | ||
362 | === modified file 'tests/test-eds-ics-nonrepeating-events.cpp' | |||
363 | --- tests/test-eds-ics-nonrepeating-events.cpp 2015-10-07 14:07:15 +0000 | |||
364 | +++ tests/test-eds-ics-nonrepeating-events.cpp 2015-10-14 02:18:01 +0000 | |||
365 | @@ -73,7 +73,7 @@ | |||
366 | 73 | expected_appt.color = "#becedd"; | 73 | expected_appt.color = "#becedd"; |
367 | 74 | expected_appt.summary = "Alarm"; | 74 | expected_appt.summary = "Alarm"; |
368 | 75 | std::array<Alarm,1> expected_alarms = { | 75 | std::array<Alarm,1> expected_alarms = { |
370 | 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)}) |
371 | 77 | }; | 77 | }; |
372 | 78 | 78 | ||
373 | 79 | // compare it to what we actually loaded... | 79 | // compare it to what we actually loaded... |
374 | 80 | 80 | ||
375 | === renamed file 'tests/test-eds-ics-nonrepeating-events.ics' => 'tests/test-eds-ics-nonrepeating-events.ics.in' | |||
376 | --- tests/test-eds-ics-nonrepeating-events.ics 2015-10-07 14:07:15 +0000 | |||
377 | +++ tests/test-eds-ics-nonrepeating-events.ics.in 2015-10-14 02:18:01 +0000 | |||
378 | @@ -14,7 +14,7 @@ | |||
379 | 14 | BEGIN:VALARM | 14 | BEGIN:VALARM |
380 | 15 | X-EVOLUTION-ALARM-UID:20150520T223932Z-22506-32011-1771-2@ubuntu-phablet | 15 | X-EVOLUTION-ALARM-UID:20150520T223932Z-22506-32011-1771-2@ubuntu-phablet |
381 | 16 | ACTION:AUDIO | 16 | ACTION:AUDIO |
383 | 17 | ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg | 17 | ATTACH:file://@ALARM_DEFAULT_SOUND@ |
384 | 18 | TRIGGER;VALUE=DURATION;RELATED=START:PT0S | 18 | TRIGGER;VALUE=DURATION;RELATED=START:PT0S |
385 | 19 | END:VALARM | 19 | END:VALARM |
386 | 20 | BEGIN:VALARM | 20 | BEGIN:VALARM |
387 | 21 | 21 | ||
388 | === modified file 'tests/test-eds-ics-repeating-events.cpp' | |||
389 | --- tests/test-eds-ics-repeating-events.cpp 2015-10-07 14:07:15 +0000 | |||
390 | +++ tests/test-eds-ics-repeating-events.cpp 2015-10-14 02:18:01 +0000 | |||
391 | @@ -73,14 +73,14 @@ | |||
392 | 73 | expected_appt.color = "#becedd"; | 73 | expected_appt.color = "#becedd"; |
393 | 74 | expected_appt.summary = "Alarm"; | 74 | expected_appt.summary = "Alarm"; |
394 | 75 | std::array<Alarm,8> expected_alarms = { | 75 | std::array<Alarm,8> expected_alarms = { |
403 | 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)}), |
404 | 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)}), |
405 | 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)}), |
406 | 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)}), |
407 | 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)}), |
408 | 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)}), |
409 | 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)}), |
410 | 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)}) |
411 | 84 | }; | 84 | }; |
412 | 85 | 85 | ||
413 | 86 | // compare it to what we actually loaded... | 86 | // compare it to what we actually loaded... |
414 | 87 | 87 | ||
415 | === renamed file 'tests/test-eds-ics-repeating-events.ics' => 'tests/test-eds-ics-repeating-events.ics.in' | |||
416 | --- tests/test-eds-ics-repeating-events.ics 2015-10-07 14:07:15 +0000 | |||
417 | +++ tests/test-eds-ics-repeating-events.ics.in 2015-10-14 02:18:01 +0000 | |||
418 | @@ -15,7 +15,7 @@ | |||
419 | 15 | BEGIN:VALARM | 15 | BEGIN:VALARM |
420 | 16 | X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-2@ubuntu-phablet | 16 | X-EVOLUTION-ALARM-UID:20150507T211449Z-4262-32011-1418-2@ubuntu-phablet |
421 | 17 | ACTION:AUDIO | 17 | ACTION:AUDIO |
423 | 18 | ATTACH:file:///usr/share/sounds/ubuntu/ringtones/Alarm clock.ogg | 18 | ATTACH:file://@ALARM_DEFAULT_SOUND@ |
424 | 19 | TRIGGER;VALUE=DURATION;RELATED=START:PT0S | 19 | TRIGGER;VALUE=DURATION;RELATED=START:PT0S |
425 | 20 | END:VALARM | 20 | END:VALARM |
426 | 21 | BEGIN:VALARM | 21 | BEGIN:VALARM |
427 | 22 | 22 | ||
428 | === renamed file 'tests/test-eds-ics-repeating-valarms.ics' => 'tests/test-eds-ics-repeating-valarms.ics.in' | |||
429 | === renamed file 'tests/test-eds-ics-tzids-2.ics' => 'tests/test-eds-ics-tzids-2.ics.in' | |||
430 | === renamed file 'tests/test-eds-ics-tzids.ics' => 'tests/test-eds-ics-tzids.ics.in' | |||
431 | === modified file 'tests/test-settings.cpp' | |||
432 | --- tests/test-settings.cpp 2014-09-17 16:51:51 +0000 | |||
433 | +++ tests/test-settings.cpp 2015-10-14 02:18:01 +0000 | |||
434 | @@ -160,6 +160,7 @@ | |||
435 | 160 | TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S); | 160 | TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S); |
436 | 161 | TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S); | 161 | TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S); |
437 | 162 | TestStringProperty(m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S); | 162 | TestStringProperty(m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S); |
438 | 163 | TestStringProperty(m_settings->calendar_sound, SETTINGS_CALENDAR_SOUND_S); | ||
439 | 163 | TestStringProperty(m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S); | 164 | TestStringProperty(m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S); |
440 | 164 | } | 165 | } |
441 | 165 | 166 | ||
442 | 166 | 167 | ||
443 | === modified file 'tests/test-snap.cpp' | |||
444 | --- tests/test-snap.cpp 2015-04-08 23:48:24 +0000 | |||
445 | +++ tests/test-snap.cpp 2015-10-14 02:18:01 +0000 | |||
446 | @@ -34,6 +34,8 @@ | |||
447 | 34 | 34 | ||
448 | 35 | using namespace unity::indicator::datetime; | 35 | using namespace unity::indicator::datetime; |
449 | 36 | 36 | ||
450 | 37 | namespace uin = unity::indicator::notifications; | ||
451 | 38 | |||
452 | 37 | #include "glib-fixture.h" | 39 | #include "glib-fixture.h" |
453 | 38 | 40 | ||
454 | 39 | /*** | 41 | /*** |
455 | @@ -92,6 +94,7 @@ | |||
456 | 92 | static constexpr char const * PROP_SILENT_MODE {"SilentMode"}; | 94 | static constexpr char const * PROP_SILENT_MODE {"SilentMode"}; |
457 | 93 | 95 | ||
458 | 94 | Appointment appt; | 96 | Appointment appt; |
459 | 97 | Appointment ualarm; | ||
460 | 95 | GDBusConnection * system_bus = nullptr; | 98 | GDBusConnection * system_bus = nullptr; |
461 | 96 | GDBusConnection * session_bus = nullptr; | 99 | GDBusConnection * session_bus = nullptr; |
462 | 97 | DbusTestService * service = nullptr; | 100 | DbusTestService * service = nullptr; |
463 | @@ -113,15 +116,25 @@ | |||
464 | 113 | 116 | ||
465 | 114 | super::SetUp(); | 117 | super::SetUp(); |
466 | 115 | 118 | ||
468 | 116 | // init the Appointment | 119 | // init an Appointment |
469 | 117 | appt.color = "green"; | 120 | appt.color = "green"; |
471 | 118 | appt.summary = "Alarm"; | 121 | appt.summary = "Christmas"; |
472 | 119 | appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402"; | 122 | appt.uid = "D4B57D50247291478ED31DED17FF0A9838DED402"; |
473 | 120 | appt.type = Appointment::EVENT; | 123 | appt.type = Appointment::EVENT; |
474 | 121 | const auto christmas = DateTime::Local(2015,12,25,0,0,0); | 124 | const auto christmas = DateTime::Local(2015,12,25,0,0,0); |
475 | 122 | appt.begin = christmas.start_of_day(); | 125 | appt.begin = christmas.start_of_day(); |
476 | 123 | appt.end = christmas.end_of_day(); | 126 | appt.end = christmas.end_of_day(); |
478 | 124 | appt.alarms.push_back(Alarm{"Alarm Text", "", appt.begin}); | 127 | appt.alarms.push_back(Alarm{"Ho Ho Ho!", "", appt.begin}); |
479 | 128 | |||
480 | 129 | // init an Ubuntu Alarm | ||
481 | 130 | ualarm.color = "red"; | ||
482 | 131 | ualarm.summary = "Wakeup"; | ||
483 | 132 | ualarm.uid = "E4B57D50247291478ED31DED17FF0A9838DED403"; | ||
484 | 133 | ualarm.type = Appointment::UBUNTU_ALARM; | ||
485 | 134 | const auto tomorrow = DateTime::NowLocal().add_days(1); | ||
486 | 135 | ualarm.begin = tomorrow; | ||
487 | 136 | ualarm.end = tomorrow; | ||
488 | 137 | ualarm.alarms.push_back(Alarm{"It's Tomorrow!", "", appt.begin}); | ||
489 | 125 | 138 | ||
490 | 126 | service = dbus_test_service_new(nullptr); | 139 | service = dbus_test_service_new(nullptr); |
491 | 127 | 140 | ||
492 | @@ -360,6 +373,15 @@ | |||
493 | 360 | &error); | 373 | &error); |
494 | 361 | g_assert_no_error (error); | 374 | g_assert_no_error (error); |
495 | 362 | } | 375 | } |
496 | 376 | |||
497 | 377 | std::shared_ptr<Snap> create_snap(const std::shared_ptr<uin::Engine>& ne, | ||
498 | 378 | const std::shared_ptr<uin::SoundBuilder>& sb, | ||
499 | 379 | const std::shared_ptr<Settings>& settings) | ||
500 | 380 | { | ||
501 | 381 | auto snap = std::make_shared<Snap>(ne, sb, settings); | ||
502 | 382 | wait_msec(100); // wait a moment for the Snap to finish its async dbus bootstrapping | ||
503 | 383 | return snap; | ||
504 | 384 | } | ||
505 | 363 | }; | 385 | }; |
506 | 364 | 386 | ||
507 | 365 | /*** | 387 | /*** |
508 | @@ -381,13 +403,14 @@ | |||
509 | 381 | auto settings = std::make_shared<Settings>(); | 403 | auto settings = std::make_shared<Settings>(); |
510 | 382 | settings->alarm_duration.set(duration_minutes); | 404 | settings->alarm_duration.set(duration_minutes); |
511 | 383 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); | 405 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); |
513 | 384 | Snap snap (ne, settings); | 406 | auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>(); |
514 | 407 | auto snap = create_snap(ne, sb, settings); | ||
515 | 385 | 408 | ||
516 | 386 | make_interactive(); | 409 | make_interactive(); |
517 | 387 | 410 | ||
518 | 388 | // call the Snap Decision | 411 | // call the Snap Decision |
519 | 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);}; |
521 | 390 | snap(appt, appt.alarms.front(), func, func); | 413 | (*snap)(appt, appt.alarms.front(), func, func); |
522 | 391 | 414 | ||
523 | 392 | // confirm that Notify got called once | 415 | // confirm that Notify got called once |
524 | 393 | guint len = 0; | 416 | guint len = 0; |
525 | @@ -431,7 +454,8 @@ | |||
526 | 431 | { | 454 | { |
527 | 432 | auto settings = std::make_shared<Settings>(); | 455 | auto settings = std::make_shared<Settings>(); |
528 | 433 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); | 456 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); |
530 | 434 | auto snap = new Snap (ne, settings); | 457 | auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>(); |
531 | 458 | auto snap = create_snap(ne, sb, settings); | ||
532 | 435 | 459 | ||
533 | 436 | make_interactive(); | 460 | make_interactive(); |
534 | 437 | 461 | ||
535 | @@ -458,7 +482,7 @@ | |||
536 | 458 | 482 | ||
537 | 459 | // force-close the snap | 483 | // force-close the snap |
538 | 460 | wait_msec(100); | 484 | wait_msec(100); |
540 | 461 | delete snap; | 485 | snap.reset(); |
541 | 462 | wait_msec(100); | 486 | wait_msec(100); |
542 | 463 | 487 | ||
543 | 464 | // confirm that sleep got uninhibted | 488 | // confirm that sleep got uninhibted |
544 | @@ -486,7 +510,8 @@ | |||
545 | 486 | { | 510 | { |
546 | 487 | auto settings = std::make_shared<Settings>(); | 511 | auto settings = std::make_shared<Settings>(); |
547 | 488 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); | 512 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); |
549 | 489 | auto snap = new Snap (ne, settings); | 513 | auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>(); |
550 | 514 | auto snap = create_snap(ne, sb, settings); | ||
551 | 490 | 515 | ||
552 | 491 | make_interactive(); | 516 | make_interactive(); |
553 | 492 | 517 | ||
554 | @@ -507,7 +532,7 @@ | |||
555 | 507 | 532 | ||
556 | 508 | // force-close the snap | 533 | // force-close the snap |
557 | 509 | wait_msec(100); | 534 | wait_msec(100); |
559 | 510 | delete snap; | 535 | snap.reset(); |
560 | 511 | wait_msec(100); | 536 | wait_msec(100); |
561 | 512 | 537 | ||
562 | 513 | // confirm that sleep got uninhibted | 538 | // confirm that sleep got uninhibted |
563 | @@ -527,6 +552,7 @@ | |||
564 | 527 | { | 552 | { |
565 | 528 | auto settings = std::make_shared<Settings>(); | 553 | auto settings = std::make_shared<Settings>(); |
566 | 529 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); | 554 | auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); |
567 | 555 | auto sb = std::make_shared<unity::indicator::notifications::DefaultSoundBuilder>(); | ||
568 | 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);}; |
569 | 531 | GError * error = nullptr; | 557 | GError * error = nullptr; |
570 | 532 | 558 | ||
571 | @@ -541,7 +567,7 @@ | |||
572 | 541 | { true, "pulse", true } | 567 | { true, "pulse", true } |
573 | 542 | }; | 568 | }; |
574 | 543 | 569 | ||
576 | 544 | auto snap = std::make_shared<Snap>(ne, settings); | 570 | auto snap = create_snap(ne, sb, settings); |
577 | 545 | 571 | ||
578 | 546 | for(const auto& test_case : test_cases) | 572 | for(const auto& test_case : test_cases) |
579 | 547 | { | 573 | { |
580 | @@ -570,3 +596,74 @@ | |||
581 | 570 | EXPECT_EQ(test_case.expected_vibrate_called, vibrate_called); | 596 | EXPECT_EQ(test_case.expected_vibrate_called, vibrate_called); |
582 | 571 | } | 597 | } |
583 | 572 | } | 598 | } |
584 | 599 | |||
585 | 600 | /*** | ||
586 | 601 | **** | ||
587 | 602 | ***/ | ||
588 | 603 | |||
589 | 604 | /** | ||
590 | 605 | * A DefaultSoundBuilder wrapper which remembers the parameters of the last sound created. | ||
591 | 606 | */ | ||
592 | 607 | class TestSoundBuilder: public uin::SoundBuilder | ||
593 | 608 | { | ||
594 | 609 | public: | ||
595 | 610 | TestSoundBuilder() =default; | ||
596 | 611 | ~TestSoundBuilder() =default; | ||
597 | 612 | |||
598 | 613 | virtual std::shared_ptr<uin::Sound> create(const std::string& role, const std::string& uri, unsigned int volume, bool loop) override { | ||
599 | 614 | m_role = role; | ||
600 | 615 | m_uri = uri; | ||
601 | 616 | m_volume = volume; | ||
602 | 617 | m_loop = loop; | ||
603 | 618 | return m_impl.create(role, uri, volume, loop); | ||
604 | 619 | } | ||
605 | 620 | |||
606 | 621 | const std::string& role() { return m_role; } | ||
607 | 622 | const std::string& uri() { return m_uri; } | ||
608 | 623 | unsigned int volume() { return m_volume; } | ||
609 | 624 | bool loop() { return m_loop; } | ||
610 | 625 | |||
611 | 626 | private: | ||
612 | 627 | std::string m_role; | ||
613 | 628 | std::string m_uri; | ||
614 | 629 | unsigned int m_volume; | ||
615 | 630 | bool m_loop; | ||
616 | 631 | uin::DefaultSoundBuilder m_impl; | ||
617 | 632 | }; | ||
618 | 633 | |||
619 | 634 | std::string path_to_uri(const std::string& path) | ||
620 | 635 | { | ||
621 | 636 | auto file = g_file_new_for_path(path.c_str()); | ||
622 | 637 | auto uri_cstr = g_file_get_uri(file); | ||
623 | 638 | std::string uri = uri_cstr; | ||
624 | 639 | g_free(uri_cstr); | ||
625 | 640 | g_clear_pointer(&file, g_object_unref); | ||
626 | 641 | return uri; | ||
627 | 642 | } | ||
628 | 643 | |||
629 | 644 | TEST_F(SnapFixture,DefaultSounds) | ||
630 | 645 | { | ||
631 | 646 | auto settings = std::make_shared<Settings>(); | ||
632 | 647 | auto ne = std::make_shared<uin::Engine>(APP_NAME); | ||
633 | 648 | auto sb = std::make_shared<TestSoundBuilder>(); | ||
634 | 649 | auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);}; | ||
635 | 650 | |||
636 | 651 | const struct { | ||
637 | 652 | Appointment appointment; | ||
638 | 653 | std::string expected_role; | ||
639 | 654 | std::string expected_uri; | ||
640 | 655 | } test_cases[] = { | ||
641 | 656 | { ualarm, "alarm", path_to_uri(ALARM_DEFAULT_SOUND) }, | ||
642 | 657 | { appt, "alert", path_to_uri(CALENDAR_DEFAULT_SOUND) } | ||
643 | 658 | }; | ||
644 | 659 | |||
645 | 660 | auto snap = create_snap(ne, sb, settings); | ||
646 | 661 | |||
647 | 662 | for(const auto& test_case : test_cases) | ||
648 | 663 | { | ||
649 | 664 | (*snap)(test_case.appointment, test_case.appointment.alarms.front(), func, func); | ||
650 | 665 | wait_msec(100); | ||
651 | 666 | EXPECT_EQ(test_case.expected_uri, sb->uri()); | ||
652 | 667 | EXPECT_EQ(test_case.expected_role, sb->role()); | ||
653 | 668 | } | ||
654 | 669 | } |
FAILED: Continuous integration, rev:422 jenkins. qa.ubuntu. com/job/ indicator- datetime- 15.04-ci/ 8/ jenkins. qa.ubuntu. com/job/ indicator- datetime- 15.04-vivid- amd64-ci/ 8/console jenkins. qa.ubuntu. com/job/ indicator- datetime- 15.04-vivid- armhf-ci/ 8/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/indicator- datetime- 15.04-ci/ 8/rebuild
http://