Merge lp:~artmello/ubuntu-push/ubuntu-push-use_fallback_for_nil_sound_vibe into lp:ubuntu-push

Proposed by Arthur Mello
Status: Approved
Approved by: Bill Filler
Approved revision: 177
Proposed branch: lp:~artmello/ubuntu-push/ubuntu-push-use_fallback_for_nil_sound_vibe
Merge into: lp:ubuntu-push
Diff against target: 113 lines (+26/-9)
5 files modified
debian/rules (+1/-1)
launch_helper/helper_output.go (+4/-2)
launch_helper/helper_output_test.go (+12/-3)
sounds/sounds.go (+8/-2)
sounds/sounds_test.go (+1/-1)
To merge this branch: bzr merge lp:~artmello/ubuntu-push/ubuntu-push-use_fallback_for_nil_sound_vibe
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Approve
system-apps-ci-bot continuous-integration Needs Fixing
Review via email: mp+303134@code.launchpad.net

Commit message

Use fallback when notification has nil RawSound/RawVibration

Description of the change

Use fallback when notification has nil RawSound/RawVibration

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
170. By Arthur Mello

Change to use GStreamer to play audio on the Sound Presenter

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
171. By Arthur Mello

Add missing build deps

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
172. By Arthur Mello

Disable tests bases on aplay player

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
173. By Arthur Mello

Remove unused imports

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
174. By Arthur Mello

Undo the changes to use GStreamer since that is not fully support on all build archs

175. By Arthur Mello

Prioritize fallback audio file defined on ubuntu-push config over the accounts one

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
176. By Arthur Mello

Fix test

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
177. By Arthur Mello

Disable tests on arm64

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

LGTM, thanks!

review: Approve

Unmerged revisions

177. By Arthur Mello

Disable tests on arm64

176. By Arthur Mello

Fix test

175. By Arthur Mello

Prioritize fallback audio file defined on ubuntu-push config over the accounts one

174. By Arthur Mello

Undo the changes to use GStreamer since that is not fully support on all build archs

173. By Arthur Mello

Remove unused imports

172. By Arthur Mello

Disable tests bases on aplay player

171. By Arthur Mello

Add missing build deps

170. By Arthur Mello

Change to use GStreamer to play audio on the Sound Presenter

169. By Arthur Mello

Use fallback when notification has nil RawSound/RawVibration

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/rules'
2--- debian/rules 2016-07-08 20:20:36 +0000
3+++ debian/rules 2016-08-25 01:06:12 +0000
4@@ -6,7 +6,7 @@
5
6 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
7 # Skip tests on the archs they are known to be flaky with current configuration
8-testskip_architectures := powerpc s390x
9+testskip_architectures := powerpc s390x arm64
10
11 ifneq (,$(filter $(DEB_HOST_ARCH), arm64 powerpc ppc64el s390x))
12 pkg_configs = ubuntuoneauth-2.0 libaccounts-glib click-0.4 ubuntu-app-launch-2 url-dispatcher-1 messaging-menu dbus-1 libnih libnih-dbus glib-2.0 gobject-2.0
13
14=== modified file 'launch_helper/helper_output.go'
15--- launch_helper/helper_output.go 2014-08-08 10:55:29 +0000
16+++ launch_helper/helper_output.go 2016-08-25 01:06:12 +0000
17@@ -91,8 +91,9 @@
18 var b bool
19 var vib *Vibration
20
21+ // If notification does not define a RawVibration return fallback one
22 if notification.RawVibration == nil {
23- return nil
24+ return fallback
25 }
26 if json.Unmarshal(notification.RawVibration, &b) == nil {
27 if !b {
28@@ -115,8 +116,9 @@
29 var b bool
30 var s string
31
32+ // If notification does not define a RawSound return fallback one
33 if notification.RawSound == nil {
34- return ""
35+ return fallback
36 }
37 if json.Unmarshal(notification.RawSound, &b) == nil {
38 if !b {
39
40=== modified file 'launch_helper/helper_output_test.go'
41--- launch_helper/helper_output_test.go 2014-08-08 10:28:10 +0000
42+++ launch_helper/helper_output_test.go 2016-08-25 01:06:12 +0000
43@@ -40,7 +40,6 @@
44 func (*outSuite) TestBadVibeBegetsNilVibe(c *C) {
45 fbck := &Vibration{Repeat: 2}
46 for _, s := range []string{
47- `{}`,
48 `{"vibrate": "foo"}`,
49 `{"vibrate": {}}`,
50 `{"vibrate": false}`, // not bad, but rather pointless
51@@ -61,6 +60,16 @@
52 }
53 }
54
55+func (*outSuite) TestNilVibeBegetsFallbackVibe(c *C) {
56+ fbck := &Vibration{Repeat: 2}
57+ var notif *Notification
58+ err := json.Unmarshal([]byte(`{}`), &notif)
59+ c.Assert(err, IsNil)
60+ c.Assert(notif, NotNil)
61+ c.Check(notif.Vibration(fbck), Equals, fbck, Commentf("not fallback Vibration() for: `{}`"))
62+ c.Check(notif.Vibration(fbck), Equals, fbck, Commentf("not fallback second call to Vibration() for: `{}`"))
63+}
64+
65 func (*outSuite) TestGoodVibe(c *C) {
66 var notif *Notification
67 err := json.Unmarshal([]byte(`{"vibrate": {"pattern": [1,2,3], "repeat": 2}}`), &notif)
68@@ -82,8 +91,8 @@
69 c.Check((&Notification{RawSound: json.RawMessage("foo")}).Sound("x"), Equals, "")
70 }
71
72-func (*outSuite) TestNilSoundBegetsNoSound(c *C) {
73- c.Check((&Notification{RawSound: nil}).Sound("x"), Equals, "")
74+func (*outSuite) TestNilSoundBegetsFallbackSound(c *C) {
75+ c.Check((&Notification{RawSound: nil}).Sound("x"), Equals, "x")
76 }
77
78 func (*outSuite) TestGoodSound(c *C) {
79
80=== modified file 'sounds/sounds.go'
81--- sounds/sounds.go 2016-07-08 17:05:38 +0000
82+++ sounds/sounds.go 2016-08-25 01:06:12 +0000
83@@ -99,9 +99,15 @@
84 return ""
85 }
86
87- fallback := snd.acc.MessageSoundFile()
88+ // FIXME: Do not prioritize account's message sound over fallback sound
89+ // defined on ubuntu-push config file. On krillin the account's
90+ // message sound is an .mp3 file and that is not supported by the
91+ // default player. We should stop calling aplay directly and start
92+ // using another audio player solution (i.e. Qt Audio, QMediaPlayer or
93+ // libmedia-hub-client)
94+ fallback := snd.fallback
95 if fallback == "" {
96- fallback = snd.fallback
97+ fallback = snd.acc.MessageSoundFile()
98 }
99
100 sound := notification.Sound(fallback)
101
102=== modified file 'sounds/sounds_test.go'
103--- sounds/sounds_test.go 2015-12-04 15:31:27 +0000
104+++ sounds/sounds_test.go 2016-08-25 01:06:12 +0000
105@@ -94,7 +94,7 @@
106 ss.log.ResetCapture()
107 c.Check(s.Present(ss.app, "",
108 &launch_helper.Notification{RawSound: json.RawMessage(`true`)}), Equals, true)
109- c.Check(ss.log.Captured(), Matches, `(?sm).* playing sound com.example.test/from-prefs using echo`)
110+ c.Check(ss.log.Captured(), Matches, `(?sm).* playing sound com.example.test/fallback using echo`)
111 }
112
113 func (ss *soundsSuite) TestPresentFails(c *C) {

Subscribers

People subscribed via source and target branches