Merge lp:~chipaca/ubuntu-push/helper-outputs-tag into lp:ubuntu-push/automatic

Proposed by John Lenton on 2014-07-22
Status: Work in progress
Proposed branch: lp:~chipaca/ubuntu-push/helper-outputs-tag
Merge into: lp:ubuntu-push/automatic
Prerequisite: lp:~chipaca/ubuntu-push/present-cleanup
Diff against target: 446 lines (+86/-42)
14 files modified
bus/emblemcounter/emblemcounter.go (+1/-1)
bus/emblemcounter/emblemcounter_test.go (+4/-4)
bus/haptic/haptic.go (+1/-1)
bus/haptic/haptic_test.go (+7/-7)
bus/notifications/raw.go (+1/-1)
bus/notifications/raw_test.go (+12/-8)
client/service/postal.go (+2/-2)
client/service/postal_test.go (+3/-3)
launch_helper/helper_output.go (+1/-0)
launch_helper/kindpool_test.go (+40/-1)
messaging/messaging.go (+1/-1)
messaging/messaging_test.go (+6/-6)
sounds/sounds.go (+1/-1)
sounds/sounds_test.go (+6/-6)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/helper-outputs-tag
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers 2014-07-22 Pending
Review via email: mp+227734@code.launchpad.net

Commit message

Helper output now includes a tag, which is passed to the presenters.

Description of the change

Helper output now includes a tag, which is passed to the presenters.

To post a comment you must log in.
275. By John Lenton on 2014-07-22

reinstated a test

Unmerged revisions

275. By John Lenton on 2014-07-22

reinstated a test

274. By John Lenton on 2014-07-22

pass the tag into the presenters

273. By John Lenton on 2014-07-22

Merged present-cleanup into helper-outputs-tag.

272. By John Lenton on 2014-07-22

Merged cleanup-mmu-notif-map into helper-outputs-tag.

271. By John Lenton on 2014-07-22

Merged cleanup-mmu-notif-map into helper-outputs-tag.

270. By John Lenton on 2014-07-22

tags in helper output

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bus/emblemcounter/emblemcounter.go'
2--- bus/emblemcounter/emblemcounter.go 2014-07-22 13:26:44 +0000
3+++ bus/emblemcounter/emblemcounter.go 2014-07-22 13:26:44 +0000
4@@ -49,7 +49,7 @@
5
6 // Look for an EmblemCounter section in a Notification and, if
7 // present, presents it to the user.
8-func (ctr *EmblemCounter) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {
9+func (ctr *EmblemCounter) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
10 if notification == nil {
11 panic("please check notification is not nil before calling present")
12 }
13
14=== modified file 'bus/emblemcounter/emblemcounter_test.go'
15--- bus/emblemcounter/emblemcounter_test.go 2014-07-22 13:26:44 +0000
16+++ bus/emblemcounter/emblemcounter_test.go 2014-07-22 13:26:44 +0000
17@@ -52,7 +52,7 @@
18
19 ec := New(endp, ecs.log)
20 notif := launch_helper.Notification{EmblemCounter: &launch_helper.EmblemCounter{Count: 42, Visible: true}}
21- c.Check(ec.Present(ecs.app, "nid", &notif), Equals, true)
22+ c.Check(ec.Present(ecs.app, "nid", "tag", &notif), Equals, true)
23 callArgs := testibus.GetCallArgs(endp)
24 c.Assert(callArgs, HasLen, 2)
25 c.Check(callArgs[0].Member, Equals, "::SetProperty")
26@@ -68,11 +68,11 @@
27 ec := New(endp, ecs.log)
28
29 // nothing happens if no EmblemCounter in Notification
30- c.Check(ec.Present(ecs.app, "nid", &launch_helper.Notification{}), Equals, false)
31+ c.Check(ec.Present(ecs.app, "nid", "tag", &launch_helper.Notification{}), Equals, false)
32 c.Assert(testibus.GetCallArgs(endp), HasLen, 0)
33
34 // but an empty EmblemCounter is acted on
35- c.Check(ec.Present(ecs.app, "nid", &launch_helper.Notification{EmblemCounter: &launch_helper.EmblemCounter{}}), Equals, true)
36+ c.Check(ec.Present(ecs.app, "nid", "tag", &launch_helper.Notification{EmblemCounter: &launch_helper.EmblemCounter{}}), Equals, true)
37 callArgs := testibus.GetCallArgs(endp)
38 c.Assert(callArgs, HasLen, 2)
39 c.Check(callArgs[0].Member, Equals, "::SetProperty")
40@@ -87,5 +87,5 @@
41 ec := New(endp, ecs.log)
42
43 // nothing happens if no EmblemCounter in Notification
44- c.Check(func() { ec.Present(ecs.app, "nid", nil) }, Panics, `please check notification is not nil before calling present`)
45+ c.Check(func() { ec.Present(ecs.app, "nid", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
46 }
47
48=== modified file 'bus/haptic/haptic.go'
49--- bus/haptic/haptic.go 2014-07-22 13:26:44 +0000
50+++ bus/haptic/haptic.go 2014-07-22 13:26:44 +0000
51@@ -44,7 +44,7 @@
52 }
53
54 // Present presents the notification via a vibrate pattern
55-func (haptic *Haptic) Present(_ *click.AppId, nid string, notification *launch_helper.Notification) bool {
56+func (haptic *Haptic) Present(_ *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
57 if notification == nil {
58 panic("please check notification is not nil before calling present")
59 }
60
61=== modified file 'bus/haptic/haptic_test.go'
62--- bus/haptic/haptic_test.go 2014-07-22 13:26:44 +0000
63+++ bus/haptic/haptic_test.go 2014-07-22 13:26:44 +0000
64@@ -49,7 +49,7 @@
65
66 ec := New(endp, hs.log)
67 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Pattern: []uint32{200, 100}, Repeat: 2}}
68- c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
69+ c.Check(ec.Present(hs.app, "nid", "tag", &notif), Equals, true)
70 callArgs := testibus.GetCallArgs(endp)
71 c.Assert(callArgs, HasLen, 1)
72 c.Check(callArgs[0].Member, Equals, "VibratePattern")
73@@ -63,7 +63,7 @@
74 ec := New(endp, hs.log)
75 // note: no Repeat:
76 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Pattern: []uint32{200, 100}}}
77- c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
78+ c.Check(ec.Present(hs.app, "nid", "tag", &notif), Equals, true)
79 callArgs := testibus.GetCallArgs(endp)
80 c.Assert(callArgs, HasLen, 1)
81 c.Check(callArgs[0].Member, Equals, "VibratePattern")
82@@ -78,7 +78,7 @@
83 ec := New(endp, hs.log)
84 // note: no Repeat, no Pattern, just Duration:
85 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200}}
86- c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
87+ c.Check(ec.Present(hs.app, "nid", "tag", &notif), Equals, true)
88 callArgs := testibus.GetCallArgs(endp)
89 c.Assert(callArgs, HasLen, 1)
90 c.Check(callArgs[0].Member, Equals, "VibratePattern")
91@@ -93,7 +93,7 @@
92 ec := New(endp, hs.log)
93 // note: Duration given, as well as Pattern; Repeat given as 0:
94 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200, Pattern: []uint32{500}, Repeat: 0}}
95- c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
96+ c.Check(ec.Present(hs.app, "nid", "tag", &notif), Equals, true)
97 callArgs := testibus.GetCallArgs(endp)
98 c.Assert(callArgs, HasLen, 1)
99 c.Check(callArgs[0].Member, Equals, "VibratePattern")
100@@ -107,9 +107,9 @@
101
102 ec := New(endp, hs.log)
103 // no Vibration in the notificaton
104- c.Check(ec.Present(hs.app, "", &launch_helper.Notification{}), Equals, false)
105+ c.Check(ec.Present(hs.app, "", "tag", &launch_helper.Notification{}), Equals, false)
106 // empty Vibration
107- c.Check(ec.Present(hs.app, "", &launch_helper.Notification{Vibrate: &launch_helper.Vibration{}}), Equals, false)
108+ c.Check(ec.Present(hs.app, "", "tag", &launch_helper.Notification{Vibrate: &launch_helper.Vibration{}}), Equals, false)
109 }
110
111 // check that Present() panics if the notification is nil
112@@ -118,5 +118,5 @@
113
114 ec := New(endp, hs.log)
115 // no notification at all
116- c.Check(func() { ec.Present(hs.app, "", nil) }, Panics, `please check notification is not nil before calling present`)
117+ c.Check(func() { ec.Present(hs.app, "", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
118 }
119
120=== modified file 'bus/notifications/raw.go'
121--- bus/notifications/raw.go 2014-07-22 13:26:44 +0000
122+++ bus/notifications/raw.go 2014-07-22 13:26:44 +0000
123@@ -131,7 +131,7 @@
124 // If card.Actions has 1 action, it's an interactive notification.
125 // If card.Actions has 2 actions, it will show as a snap decision.
126 // If it has more actions, who knows (good luck).
127-func (raw *RawNotifications) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {
128+func (raw *RawNotifications) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
129 if notification == nil {
130 panic("please check notification is not nil before calling present")
131 }
132
133=== modified file 'bus/notifications/raw_test.go'
134--- bus/notifications/raw_test.go 2014-07-22 13:26:44 +0000
135+++ bus/notifications/raw_test.go 2014-07-22 13:26:44 +0000
136@@ -160,14 +160,16 @@
137 func (s *RawSuite) TestPresentNotifies(c *C) {
138 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
139 raw := Raw(endp, s.log)
140- worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true}})
141+ notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true}}
142+ worked := raw.Present(s.app, "notifId", "tag", notif)
143 c.Check(worked, Equals, true)
144 }
145
146 func (s *RawSuite) TestPresentOneAction(c *C) {
147 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
148 raw := Raw(endp, s.log)
149- worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes"}}})
150+ notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes"}}}
151+ worked := raw.Present(s.app, "notifId", "tag", notif)
152 c.Check(worked, Equals, true)
153 callArgs := testibus.GetCallArgs(endp)
154 c.Assert(callArgs, HasLen, 1)
155@@ -191,7 +193,8 @@
156 func (s *RawSuite) TestPresentTwoActions(c *C) {
157 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
158 raw := Raw(endp, s.log)
159- worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No"}}})
160+ notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No"}}}
161+ worked := raw.Present(s.app, "notifId", "tag", notif)
162 c.Check(worked, Equals, true)
163 callArgs := testibus.GetCallArgs(endp)
164 c.Assert(callArgs, HasLen, 1)
165@@ -218,7 +221,8 @@
166 func (s *RawSuite) TestPresentThreeActions(c *C) {
167 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
168 raw := Raw(endp, s.log)
169- worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No", "What"}}})
170+ notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No", "What"}}}
171+ worked := raw.Present(s.app, "notifId", "tag", notif)
172 c.Check(worked, Equals, true)
173 callArgs := testibus.GetCallArgs(endp)
174 c.Assert(callArgs, HasLen, 1)
175@@ -238,26 +242,26 @@
176 func (s *RawSuite) TestPresentNoNotificationPanics(c *C) {
177 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
178 raw := Raw(endp, s.log)
179- c.Check(func() { raw.Present(s.app, "notifId", nil) }, Panics, `please check notification is not nil before calling present`)
180+ c.Check(func() { raw.Present(s.app, "notifId", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
181 }
182
183 func (s *RawSuite) TestPresentNoCardDoesNotNotify(c *C) {
184 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
185 raw := Raw(endp, s.log)
186- worked := raw.Present(s.app, "notifId", &launch_helper.Notification{})
187+ worked := raw.Present(s.app, "notifId", "tag", &launch_helper.Notification{})
188 c.Check(worked, Equals, false)
189 }
190
191 func (s *RawSuite) TestPresentNoSummaryDoesNotNotify(c *C) {
192 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
193 raw := Raw(endp, s.log)
194- worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{}})
195+ worked := raw.Present(s.app, "notifId", "tag", &launch_helper.Notification{Card: &launch_helper.Card{}})
196 c.Check(worked, Equals, false)
197 }
198
199 func (s *RawSuite) TestPresentNoPopupNoNotify(c *C) {
200 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
201 raw := Raw(endp, s.log)
202- worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary"}})
203+ worked := raw.Present(s.app, "notifId", "tag", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary"}})
204 c.Check(worked, Equals, false)
205 }
206
207=== modified file 'client/service/postal.go'
208--- client/service/postal.go 2014-07-22 13:26:44 +0000
209+++ client/service/postal.go 2014-07-22 13:26:44 +0000
210@@ -43,7 +43,7 @@
211
212 // a Presenter is something that knows how to present a Notification
213 type Presenter interface {
214- Present(*click.AppId, string, *launch_helper.Notification) bool
215+ Present(*click.AppId, string, string, *launch_helper.Notification) bool
216 }
217
218 // PostalService is the dbus api
219@@ -332,7 +332,7 @@
220 b := false
221 for _, p := range svc.Presenters {
222 // we don't want this to shortcut :)
223- b = p.Present(app, nid, output.Notification) || b
224+ b = p.Present(app, nid, output.Tag, output.Notification) || b
225 }
226 return b
227 } else {
228
229=== modified file 'client/service/postal_test.go'
230--- client/service/postal_test.go 2014-07-22 13:26:44 +0000
231+++ client/service/postal_test.go 2014-07-22 13:26:44 +0000
232@@ -492,7 +492,7 @@
233 c.Check(svc.GetMessageHandler(), IsNil)
234 svc.SetMessageHandler(f)
235 c.Check(svc.GetMessageHandler(), NotNil)
236- hOutput := &launch_helper.HelperOutput{[]byte("37"), nil}
237+ hOutput := &launch_helper.HelperOutput{[]byte("37"), nil, ""}
238 c.Check(svc.msgHandler(nil, "", hOutput), Equals, false)
239 c.Check(ext, DeepEquals, hOutput)
240 }
241@@ -560,7 +560,7 @@
242 func (ps *postalSuite) TestMessageHandlerReportsButIgnoresUnmarshalErrors(c *C) {
243 svc := ps.replaceBuses(NewPostalService(nil, ps.log))
244 c.Assert(svc.Start(), IsNil)
245- output := &launch_helper.HelperOutput{[]byte(`broken`), nil}
246+ output := &launch_helper.HelperOutput{[]byte(`broken`), nil, ""}
247 b := svc.messageHandler(nil, "", output)
248 c.Check(b, Equals, false)
249 c.Check(ps.log.Captured(), Matches, "(?msi).*skipping notification: nil.*")
250@@ -571,7 +571,7 @@
251 svc := ps.replaceBuses(NewPostalService(nil, ps.log))
252 c.Assert(svc.Start(), IsNil)
253 svc.NotificationsEndp = endp
254- output := &launch_helper.HelperOutput{[]byte(`{}`), nil}
255+ output := &launch_helper.HelperOutput{[]byte(`{}`), nil, ""}
256 b := svc.messageHandler(nil, "", output)
257 c.Assert(b, Equals, false)
258 c.Check(ps.log.Captured(), Matches, "(?msi).*skipping notification: nil.*")
259
260=== modified file 'launch_helper/helper_output.go'
261--- launch_helper/helper_output.go 2014-07-18 14:23:34 +0000
262+++ launch_helper/helper_output.go 2014-07-22 13:26:44 +0000
263@@ -60,6 +60,7 @@
264 type HelperOutput struct {
265 Message json.RawMessage `json:"message,omitempty"` // what to put in the post office's queue
266 Notification *Notification `json:"notification,omitempty"` // what to present to the user
267+ Tag string `json:"tag,omitempty"` // tag used for Clear/ListPersistent.
268 }
269
270 // HelperResult is the result of a helper run for a particular app id
271
272=== modified file 'launch_helper/kindpool_test.go'
273--- launch_helper/kindpool_test.go 2014-07-19 00:18:18 +0000
274+++ launch_helper/kindpool_test.go 2014-07-22 13:26:44 +0000
275@@ -268,12 +268,51 @@
276 c.Check(res.Message, DeepEquals, input.Payload)
277 }
278
279+func (s *poolSuite) TestOneDoneOnValid(c *C) {
280+ pool := s.pool.(*kindHelperPool)
281+ ch := pool.Start()
282+ defer pool.Stop()
283+
284+ d := c.MkDir()
285+
286+ app := clickhelp.MustParseAppId("com.example.test_test-app")
287+ input := &HelperInput{
288+ App: app,
289+ }
290+ args := HelperArgs{
291+ Input: input,
292+ FileOut: filepath.Join(d, "file_out.json"),
293+ Timer: &time.Timer{},
294+ }
295+ pool.hmap["l:1"] = &args
296+
297+ f, err := os.Create(args.FileOut)
298+ c.Assert(err, IsNil)
299+ defer f.Close()
300+ _, err = f.Write([]byte(`{"tag": "24", "notification": {"sound": "hello"}}`))
301+ c.Assert(err, IsNil)
302+
303+ go pool.OneDone("l:1")
304+
305+ var res *HelperResult
306+ select {
307+ case res = <-ch:
308+ case <-time.After(100 * time.Millisecond):
309+ c.Fatal("timeout")
310+ }
311+
312+ expected := HelperOutput{Tag: "24", Notification: &Notification{Sound: "hello"}}
313+ c.Check(res.HelperOutput, DeepEquals, expected)
314+ c.Check(pool.hmap, HasLen, 0)
315+}
316+
317 func (s *poolSuite) TestOneDoneNop(c *C) {
318 pool := s.pool.(*kindHelperPool)
319 pool.OneDone("")
320+ // huzzah, that didn't blow up.
321 }
322
323-func (s *poolSuite) TestOneDoneOnValid(c *C) {
324+func (s *poolSuite) TestOneDoneValidWNoTag(c *C) {
325 pool := s.pool.(*kindHelperPool)
326 ch := pool.Start()
327 defer pool.Stop()
328
329=== modified file 'messaging/messaging.go'
330--- messaging/messaging.go 2014-07-22 13:26:44 +0000
331+++ messaging/messaging.go 2014-07-22 13:26:44 +0000
332@@ -97,7 +97,7 @@
333 mmu.stopCleanupLoopCh <- true
334 }
335
336-func (mmu *MessagingMenu) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {
337+func (mmu *MessagingMenu) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
338 if notification == nil {
339 panic("please check notification is not nil before calling present")
340 }
341
342=== modified file 'messaging/messaging_test.go'
343--- messaging/messaging_test.go 2014-07-22 13:26:44 +0000
344+++ messaging/messaging_test.go 2014-07-22 13:26:44 +0000
345@@ -55,7 +55,7 @@
346 card := launch_helper.Card{Summary: "ehlo", Persist: true}
347 notif := launch_helper.Notification{Card: &card}
348
349- c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, true)
350+ c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, true)
351
352 c.Check(ms.log.Captured(), Matches, `(?s).* ADD:.*notif-id.*`)
353 }
354@@ -65,7 +65,7 @@
355 card := launch_helper.Card{Persist: true}
356 notif := launch_helper.Notification{Card: &card}
357
358- c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, false)
359+ c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, false)
360
361 c.Check(ms.log.Captured(), Matches, "(?sm).*has no persistable card.*")
362 }
363@@ -75,19 +75,19 @@
364 card := launch_helper.Card{Summary: "ehlo"}
365 notif := launch_helper.Notification{Card: &card}
366
367- c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, false)
368+ c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, false)
369
370 c.Check(ms.log.Captured(), Matches, "(?sm).*has no persistable card.*")
371 }
372
373 func (ms *MessagingSuite) TestPresentPanicsIfNil(c *C) {
374 mmu := New(ms.log)
375- c.Check(func() { mmu.Present(ms.app, "notif-id", nil) }, Panics, `please check notification is not nil before calling present`)
376+ c.Check(func() { mmu.Present(ms.app, "notif-id", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
377 }
378
379 func (ms *MessagingSuite) TestPresentDoesNotPresentsIfNilCard(c *C) {
380 mmu := New(ms.log)
381- c.Check(mmu.Present(ms.app, "notif-id", &launch_helper.Notification{}), Equals, false)
382+ c.Check(mmu.Present(ms.app, "notif-id", "tag", &launch_helper.Notification{}), Equals, false)
383 c.Check(ms.log.Captured(), Matches, "(?sm).*no persistable card.*")
384 }
385
386@@ -96,7 +96,7 @@
387 card := launch_helper.Card{Summary: "ehlo", Persist: true, Actions: []string{"action-1"}}
388 notif := launch_helper.Notification{Card: &card}
389
390- c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, true)
391+ c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, true)
392
393 c.Check(ms.log.Captured(), Matches, `(?s).* ADD:.*notif-id.*`)
394
395
396=== modified file 'sounds/sounds.go'
397--- sounds/sounds.go 2014-07-22 13:26:44 +0000
398+++ sounds/sounds.go 2014-07-22 13:26:44 +0000
399@@ -39,7 +39,7 @@
400 return &Sound{player: "paplay", log: log, dataDirs: xdg.Data.Dirs, dataFind: xdg.Data.Find}
401 }
402
403-func (snd *Sound) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {
404+func (snd *Sound) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
405 if notification == nil {
406 panic("please check notification is not nil before calling present")
407 }
408
409=== modified file 'sounds/sounds_test.go'
410--- sounds/sounds_test.go 2014-07-22 13:26:44 +0000
411+++ sounds/sounds_test.go 2014-07-22 13:26:44 +0000
412@@ -56,7 +56,7 @@
413 dataFind: func(s string) (string, error) { return s, nil },
414 }
415
416- c.Check(s.Present(ss.app, "",
417+ c.Check(s.Present(ss.app, "", "tag",
418 &launch_helper.Notification{Sound: "hello"}), Equals, true)
419 c.Check(ss.log.Captured(), Matches, `(?sm).* playing sound com.example.test/hello using echo`)
420 }
421@@ -70,14 +70,14 @@
422 }
423
424 // nil notification
425- c.Check(func() { s.Present(ss.app, "", nil) }, Panics, `please check notification is not nil before calling present`)
426+ c.Check(func() { s.Present(ss.app, "", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
427 // no Sound
428- c.Check(s.Present(ss.app, "", &launch_helper.Notification{}), Equals, false)
429+ c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{}), Equals, false)
430 // bad player
431- c.Check(s.Present(ss.app, "", &launch_helper.Notification{Sound: "hello"}), Equals, false)
432+ c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{Sound: "hello"}), Equals, false)
433 s.player = "echo"
434 // no file found
435- c.Check(s.Present(ss.app, "", &launch_helper.Notification{Sound: "hello"}), Equals, false)
436+ c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{Sound: "hello"}), Equals, false)
437
438 // and now, just to prove it would've worked,
439
440@@ -86,5 +86,5 @@
441 c.Assert(err, IsNil)
442 f.Close()
443 s.dataDirs = func() []string { return []string{"", d} }
444- c.Check(s.Present(ss.app, "", &launch_helper.Notification{Sound: "hello"}), Equals, true)
445+ c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{Sound: "hello"}), Equals, true)
446 }

Subscribers

People subscribed via source and target branches