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

Proposed by John Lenton
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 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

reinstated a test

Unmerged revisions

275. By John Lenton

reinstated a test

274. By John Lenton

pass the tag into the presenters

273. By John Lenton

Merged present-cleanup into helper-outputs-tag.

272. By John Lenton

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

271. By John Lenton

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

270. By John Lenton

tags in helper output

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bus/emblemcounter/emblemcounter.go'
--- bus/emblemcounter/emblemcounter.go 2014-07-22 13:26:44 +0000
+++ bus/emblemcounter/emblemcounter.go 2014-07-22 13:26:44 +0000
@@ -49,7 +49,7 @@
4949
50// Look for an EmblemCounter section in a Notification and, if50// Look for an EmblemCounter section in a Notification and, if
51// present, presents it to the user.51// present, presents it to the user.
52func (ctr *EmblemCounter) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {52func (ctr *EmblemCounter) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
53 if notification == nil {53 if notification == nil {
54 panic("please check notification is not nil before calling present")54 panic("please check notification is not nil before calling present")
55 }55 }
5656
=== modified file 'bus/emblemcounter/emblemcounter_test.go'
--- bus/emblemcounter/emblemcounter_test.go 2014-07-22 13:26:44 +0000
+++ bus/emblemcounter/emblemcounter_test.go 2014-07-22 13:26:44 +0000
@@ -52,7 +52,7 @@
5252
53 ec := New(endp, ecs.log)53 ec := New(endp, ecs.log)
54 notif := launch_helper.Notification{EmblemCounter: &launch_helper.EmblemCounter{Count: 42, Visible: true}}54 notif := launch_helper.Notification{EmblemCounter: &launch_helper.EmblemCounter{Count: 42, Visible: true}}
55 c.Check(ec.Present(ecs.app, "nid", &notif), Equals, true)55 c.Check(ec.Present(ecs.app, "nid", "tag", &notif), Equals, true)
56 callArgs := testibus.GetCallArgs(endp)56 callArgs := testibus.GetCallArgs(endp)
57 c.Assert(callArgs, HasLen, 2)57 c.Assert(callArgs, HasLen, 2)
58 c.Check(callArgs[0].Member, Equals, "::SetProperty")58 c.Check(callArgs[0].Member, Equals, "::SetProperty")
@@ -68,11 +68,11 @@
68 ec := New(endp, ecs.log)68 ec := New(endp, ecs.log)
6969
70 // nothing happens if no EmblemCounter in Notification70 // nothing happens if no EmblemCounter in Notification
71 c.Check(ec.Present(ecs.app, "nid", &launch_helper.Notification{}), Equals, false)71 c.Check(ec.Present(ecs.app, "nid", "tag", &launch_helper.Notification{}), Equals, false)
72 c.Assert(testibus.GetCallArgs(endp), HasLen, 0)72 c.Assert(testibus.GetCallArgs(endp), HasLen, 0)
7373
74 // but an empty EmblemCounter is acted on74 // but an empty EmblemCounter is acted on
75 c.Check(ec.Present(ecs.app, "nid", &launch_helper.Notification{EmblemCounter: &launch_helper.EmblemCounter{}}), Equals, true)75 c.Check(ec.Present(ecs.app, "nid", "tag", &launch_helper.Notification{EmblemCounter: &launch_helper.EmblemCounter{}}), Equals, true)
76 callArgs := testibus.GetCallArgs(endp)76 callArgs := testibus.GetCallArgs(endp)
77 c.Assert(callArgs, HasLen, 2)77 c.Assert(callArgs, HasLen, 2)
78 c.Check(callArgs[0].Member, Equals, "::SetProperty")78 c.Check(callArgs[0].Member, Equals, "::SetProperty")
@@ -87,5 +87,5 @@
87 ec := New(endp, ecs.log)87 ec := New(endp, ecs.log)
8888
89 // nothing happens if no EmblemCounter in Notification89 // nothing happens if no EmblemCounter in Notification
90 c.Check(func() { ec.Present(ecs.app, "nid", nil) }, Panics, `please check notification is not nil before calling present`)90 c.Check(func() { ec.Present(ecs.app, "nid", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
91}91}
9292
=== modified file 'bus/haptic/haptic.go'
--- bus/haptic/haptic.go 2014-07-22 13:26:44 +0000
+++ bus/haptic/haptic.go 2014-07-22 13:26:44 +0000
@@ -44,7 +44,7 @@
44}44}
4545
46// Present presents the notification via a vibrate pattern46// Present presents the notification via a vibrate pattern
47func (haptic *Haptic) Present(_ *click.AppId, nid string, notification *launch_helper.Notification) bool {47func (haptic *Haptic) Present(_ *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
48 if notification == nil {48 if notification == nil {
49 panic("please check notification is not nil before calling present")49 panic("please check notification is not nil before calling present")
50 }50 }
5151
=== modified file 'bus/haptic/haptic_test.go'
--- bus/haptic/haptic_test.go 2014-07-22 13:26:44 +0000
+++ bus/haptic/haptic_test.go 2014-07-22 13:26:44 +0000
@@ -49,7 +49,7 @@
4949
50 ec := New(endp, hs.log)50 ec := New(endp, hs.log)
51 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Pattern: []uint32{200, 100}, Repeat: 2}}51 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Pattern: []uint32{200, 100}, Repeat: 2}}
52 c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)52 c.Check(ec.Present(hs.app, "nid", "tag", &notif), Equals, true)
53 callArgs := testibus.GetCallArgs(endp)53 callArgs := testibus.GetCallArgs(endp)
54 c.Assert(callArgs, HasLen, 1)54 c.Assert(callArgs, HasLen, 1)
55 c.Check(callArgs[0].Member, Equals, "VibratePattern")55 c.Check(callArgs[0].Member, Equals, "VibratePattern")
@@ -63,7 +63,7 @@
63 ec := New(endp, hs.log)63 ec := New(endp, hs.log)
64 // note: no Repeat:64 // note: no Repeat:
65 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Pattern: []uint32{200, 100}}}65 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Pattern: []uint32{200, 100}}}
66 c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)66 c.Check(ec.Present(hs.app, "nid", "tag", &notif), Equals, true)
67 callArgs := testibus.GetCallArgs(endp)67 callArgs := testibus.GetCallArgs(endp)
68 c.Assert(callArgs, HasLen, 1)68 c.Assert(callArgs, HasLen, 1)
69 c.Check(callArgs[0].Member, Equals, "VibratePattern")69 c.Check(callArgs[0].Member, Equals, "VibratePattern")
@@ -78,7 +78,7 @@
78 ec := New(endp, hs.log)78 ec := New(endp, hs.log)
79 // note: no Repeat, no Pattern, just Duration:79 // note: no Repeat, no Pattern, just Duration:
80 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200}}80 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200}}
81 c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)81 c.Check(ec.Present(hs.app, "nid", "tag", &notif), Equals, true)
82 callArgs := testibus.GetCallArgs(endp)82 callArgs := testibus.GetCallArgs(endp)
83 c.Assert(callArgs, HasLen, 1)83 c.Assert(callArgs, HasLen, 1)
84 c.Check(callArgs[0].Member, Equals, "VibratePattern")84 c.Check(callArgs[0].Member, Equals, "VibratePattern")
@@ -93,7 +93,7 @@
93 ec := New(endp, hs.log)93 ec := New(endp, hs.log)
94 // note: Duration given, as well as Pattern; Repeat given as 0:94 // note: Duration given, as well as Pattern; Repeat given as 0:
95 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200, Pattern: []uint32{500}, Repeat: 0}}95 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200, Pattern: []uint32{500}, Repeat: 0}}
96 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)97 callArgs := testibus.GetCallArgs(endp)
98 c.Assert(callArgs, HasLen, 1)98 c.Assert(callArgs, HasLen, 1)
99 c.Check(callArgs[0].Member, Equals, "VibratePattern")99 c.Check(callArgs[0].Member, Equals, "VibratePattern")
@@ -107,9 +107,9 @@
107107
108 ec := New(endp, hs.log)108 ec := New(endp, hs.log)
109 // no Vibration in the notificaton109 // no Vibration in the notificaton
110 c.Check(ec.Present(hs.app, "", &launch_helper.Notification{}), Equals, false)110 c.Check(ec.Present(hs.app, "", "tag", &launch_helper.Notification{}), Equals, false)
111 // empty Vibration111 // empty Vibration
112 c.Check(ec.Present(hs.app, "", &launch_helper.Notification{Vibrate: &launch_helper.Vibration{}}), Equals, false)112 c.Check(ec.Present(hs.app, "", "tag", &launch_helper.Notification{Vibrate: &launch_helper.Vibration{}}), Equals, false)
113}113}
114114
115// check that Present() panics if the notification is nil115// check that Present() panics if the notification is nil
@@ -118,5 +118,5 @@
118118
119 ec := New(endp, hs.log)119 ec := New(endp, hs.log)
120 // no notification at all120 // no notification at all
121 c.Check(func() { ec.Present(hs.app, "", nil) }, Panics, `please check notification is not nil before calling present`)121 c.Check(func() { ec.Present(hs.app, "", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
122}122}
123123
=== modified file 'bus/notifications/raw.go'
--- bus/notifications/raw.go 2014-07-22 13:26:44 +0000
+++ bus/notifications/raw.go 2014-07-22 13:26:44 +0000
@@ -131,7 +131,7 @@
131// If card.Actions has 1 action, it's an interactive notification.131// If card.Actions has 1 action, it's an interactive notification.
132// If card.Actions has 2 actions, it will show as a snap decision.132// If card.Actions has 2 actions, it will show as a snap decision.
133// If it has more actions, who knows (good luck).133// If it has more actions, who knows (good luck).
134func (raw *RawNotifications) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {134func (raw *RawNotifications) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
135 if notification == nil {135 if notification == nil {
136 panic("please check notification is not nil before calling present")136 panic("please check notification is not nil before calling present")
137 }137 }
138138
=== modified file 'bus/notifications/raw_test.go'
--- bus/notifications/raw_test.go 2014-07-22 13:26:44 +0000
+++ bus/notifications/raw_test.go 2014-07-22 13:26:44 +0000
@@ -160,14 +160,16 @@
160func (s *RawSuite) TestPresentNotifies(c *C) {160func (s *RawSuite) TestPresentNotifies(c *C) {
161 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))161 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
162 raw := Raw(endp, s.log)162 raw := Raw(endp, s.log)
163 worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true}})163 notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true}}
164 worked := raw.Present(s.app, "notifId", "tag", notif)
164 c.Check(worked, Equals, true)165 c.Check(worked, Equals, true)
165}166}
166167
167func (s *RawSuite) TestPresentOneAction(c *C) {168func (s *RawSuite) TestPresentOneAction(c *C) {
168 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))169 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
169 raw := Raw(endp, s.log)170 raw := Raw(endp, s.log)
170 worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes"}}})171 notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes"}}}
172 worked := raw.Present(s.app, "notifId", "tag", notif)
171 c.Check(worked, Equals, true)173 c.Check(worked, Equals, true)
172 callArgs := testibus.GetCallArgs(endp)174 callArgs := testibus.GetCallArgs(endp)
173 c.Assert(callArgs, HasLen, 1)175 c.Assert(callArgs, HasLen, 1)
@@ -191,7 +193,8 @@
191func (s *RawSuite) TestPresentTwoActions(c *C) {193func (s *RawSuite) TestPresentTwoActions(c *C) {
192 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))194 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
193 raw := Raw(endp, s.log)195 raw := Raw(endp, s.log)
194 worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No"}}})196 notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No"}}}
197 worked := raw.Present(s.app, "notifId", "tag", notif)
195 c.Check(worked, Equals, true)198 c.Check(worked, Equals, true)
196 callArgs := testibus.GetCallArgs(endp)199 callArgs := testibus.GetCallArgs(endp)
197 c.Assert(callArgs, HasLen, 1)200 c.Assert(callArgs, HasLen, 1)
@@ -218,7 +221,8 @@
218func (s *RawSuite) TestPresentThreeActions(c *C) {221func (s *RawSuite) TestPresentThreeActions(c *C) {
219 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))222 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
220 raw := Raw(endp, s.log)223 raw := Raw(endp, s.log)
221 worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No", "What"}}})224 notif := &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary", Popup: true, Actions: []string{"Yes", "No", "What"}}}
225 worked := raw.Present(s.app, "notifId", "tag", notif)
222 c.Check(worked, Equals, true)226 c.Check(worked, Equals, true)
223 callArgs := testibus.GetCallArgs(endp)227 callArgs := testibus.GetCallArgs(endp)
224 c.Assert(callArgs, HasLen, 1)228 c.Assert(callArgs, HasLen, 1)
@@ -238,26 +242,26 @@
238func (s *RawSuite) TestPresentNoNotificationPanics(c *C) {242func (s *RawSuite) TestPresentNoNotificationPanics(c *C) {
239 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))243 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
240 raw := Raw(endp, s.log)244 raw := Raw(endp, s.log)
241 c.Check(func() { raw.Present(s.app, "notifId", nil) }, Panics, `please check notification is not nil before calling present`)245 c.Check(func() { raw.Present(s.app, "notifId", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
242}246}
243247
244func (s *RawSuite) TestPresentNoCardDoesNotNotify(c *C) {248func (s *RawSuite) TestPresentNoCardDoesNotNotify(c *C) {
245 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))249 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
246 raw := Raw(endp, s.log)250 raw := Raw(endp, s.log)
247 worked := raw.Present(s.app, "notifId", &launch_helper.Notification{})251 worked := raw.Present(s.app, "notifId", "tag", &launch_helper.Notification{})
248 c.Check(worked, Equals, false)252 c.Check(worked, Equals, false)
249}253}
250254
251func (s *RawSuite) TestPresentNoSummaryDoesNotNotify(c *C) {255func (s *RawSuite) TestPresentNoSummaryDoesNotNotify(c *C) {
252 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))256 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
253 raw := Raw(endp, s.log)257 raw := Raw(endp, s.log)
254 worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{}})258 worked := raw.Present(s.app, "notifId", "tag", &launch_helper.Notification{Card: &launch_helper.Card{}})
255 c.Check(worked, Equals, false)259 c.Check(worked, Equals, false)
256}260}
257261
258func (s *RawSuite) TestPresentNoPopupNoNotify(c *C) {262func (s *RawSuite) TestPresentNoPopupNoNotify(c *C) {
259 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))263 endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
260 raw := Raw(endp, s.log)264 raw := Raw(endp, s.log)
261 worked := raw.Present(s.app, "notifId", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary"}})265 worked := raw.Present(s.app, "notifId", "tag", &launch_helper.Notification{Card: &launch_helper.Card{Summary: "summary"}})
262 c.Check(worked, Equals, false)266 c.Check(worked, Equals, false)
263}267}
264268
=== modified file 'client/service/postal.go'
--- client/service/postal.go 2014-07-22 13:26:44 +0000
+++ client/service/postal.go 2014-07-22 13:26:44 +0000
@@ -43,7 +43,7 @@
4343
44// a Presenter is something that knows how to present a Notification44// a Presenter is something that knows how to present a Notification
45type Presenter interface {45type Presenter interface {
46 Present(*click.AppId, string, *launch_helper.Notification) bool46 Present(*click.AppId, string, string, *launch_helper.Notification) bool
47}47}
4848
49// PostalService is the dbus api49// PostalService is the dbus api
@@ -332,7 +332,7 @@
332 b := false332 b := false
333 for _, p := range svc.Presenters {333 for _, p := range svc.Presenters {
334 // we don't want this to shortcut :)334 // we don't want this to shortcut :)
335 b = p.Present(app, nid, output.Notification) || b335 b = p.Present(app, nid, output.Tag, output.Notification) || b
336 }336 }
337 return b337 return b
338 } else {338 } else {
339339
=== modified file 'client/service/postal_test.go'
--- client/service/postal_test.go 2014-07-22 13:26:44 +0000
+++ client/service/postal_test.go 2014-07-22 13:26:44 +0000
@@ -492,7 +492,7 @@
492 c.Check(svc.GetMessageHandler(), IsNil)492 c.Check(svc.GetMessageHandler(), IsNil)
493 svc.SetMessageHandler(f)493 svc.SetMessageHandler(f)
494 c.Check(svc.GetMessageHandler(), NotNil)494 c.Check(svc.GetMessageHandler(), NotNil)
495 hOutput := &launch_helper.HelperOutput{[]byte("37"), nil}495 hOutput := &launch_helper.HelperOutput{[]byte("37"), nil, ""}
496 c.Check(svc.msgHandler(nil, "", hOutput), Equals, false)496 c.Check(svc.msgHandler(nil, "", hOutput), Equals, false)
497 c.Check(ext, DeepEquals, hOutput)497 c.Check(ext, DeepEquals, hOutput)
498}498}
@@ -560,7 +560,7 @@
560func (ps *postalSuite) TestMessageHandlerReportsButIgnoresUnmarshalErrors(c *C) {560func (ps *postalSuite) TestMessageHandlerReportsButIgnoresUnmarshalErrors(c *C) {
561 svc := ps.replaceBuses(NewPostalService(nil, ps.log))561 svc := ps.replaceBuses(NewPostalService(nil, ps.log))
562 c.Assert(svc.Start(), IsNil)562 c.Assert(svc.Start(), IsNil)
563 output := &launch_helper.HelperOutput{[]byte(`broken`), nil}563 output := &launch_helper.HelperOutput{[]byte(`broken`), nil, ""}
564 b := svc.messageHandler(nil, "", output)564 b := svc.messageHandler(nil, "", output)
565 c.Check(b, Equals, false)565 c.Check(b, Equals, false)
566 c.Check(ps.log.Captured(), Matches, "(?msi).*skipping notification: nil.*")566 c.Check(ps.log.Captured(), Matches, "(?msi).*skipping notification: nil.*")
@@ -571,7 +571,7 @@
571 svc := ps.replaceBuses(NewPostalService(nil, ps.log))571 svc := ps.replaceBuses(NewPostalService(nil, ps.log))
572 c.Assert(svc.Start(), IsNil)572 c.Assert(svc.Start(), IsNil)
573 svc.NotificationsEndp = endp573 svc.NotificationsEndp = endp
574 output := &launch_helper.HelperOutput{[]byte(`{}`), nil}574 output := &launch_helper.HelperOutput{[]byte(`{}`), nil, ""}
575 b := svc.messageHandler(nil, "", output)575 b := svc.messageHandler(nil, "", output)
576 c.Assert(b, Equals, false)576 c.Assert(b, Equals, false)
577 c.Check(ps.log.Captured(), Matches, "(?msi).*skipping notification: nil.*")577 c.Check(ps.log.Captured(), Matches, "(?msi).*skipping notification: nil.*")
578578
=== modified file 'launch_helper/helper_output.go'
--- launch_helper/helper_output.go 2014-07-18 14:23:34 +0000
+++ launch_helper/helper_output.go 2014-07-22 13:26:44 +0000
@@ -60,6 +60,7 @@
60type HelperOutput struct {60type HelperOutput struct {
61 Message json.RawMessage `json:"message,omitempty"` // what to put in the post office's queue61 Message json.RawMessage `json:"message,omitempty"` // what to put in the post office's queue
62 Notification *Notification `json:"notification,omitempty"` // what to present to the user62 Notification *Notification `json:"notification,omitempty"` // what to present to the user
63 Tag string `json:"tag,omitempty"` // tag used for Clear/ListPersistent.
63}64}
6465
65// HelperResult is the result of a helper run for a particular app id66// HelperResult is the result of a helper run for a particular app id
6667
=== modified file 'launch_helper/kindpool_test.go'
--- launch_helper/kindpool_test.go 2014-07-19 00:18:18 +0000
+++ launch_helper/kindpool_test.go 2014-07-22 13:26:44 +0000
@@ -268,12 +268,51 @@
268 c.Check(res.Message, DeepEquals, input.Payload)268 c.Check(res.Message, DeepEquals, input.Payload)
269}269}
270270
271func (s *poolSuite) TestOneDoneOnValid(c *C) {
272 pool := s.pool.(*kindHelperPool)
273 ch := pool.Start()
274 defer pool.Stop()
275
276 d := c.MkDir()
277
278 app := clickhelp.MustParseAppId("com.example.test_test-app")
279 input := &HelperInput{
280 App: app,
281 }
282 args := HelperArgs{
283 Input: input,
284 FileOut: filepath.Join(d, "file_out.json"),
285 Timer: &time.Timer{},
286 }
287 pool.hmap["l:1"] = &args
288
289 f, err := os.Create(args.FileOut)
290 c.Assert(err, IsNil)
291 defer f.Close()
292 _, err = f.Write([]byte(`{"tag": "24", "notification": {"sound": "hello"}}`))
293 c.Assert(err, IsNil)
294
295 go pool.OneDone("l:1")
296
297 var res *HelperResult
298 select {
299 case res = <-ch:
300 case <-time.After(100 * time.Millisecond):
301 c.Fatal("timeout")
302 }
303
304 expected := HelperOutput{Tag: "24", Notification: &Notification{Sound: "hello"}}
305 c.Check(res.HelperOutput, DeepEquals, expected)
306 c.Check(pool.hmap, HasLen, 0)
307}
308
271func (s *poolSuite) TestOneDoneNop(c *C) {309func (s *poolSuite) TestOneDoneNop(c *C) {
272 pool := s.pool.(*kindHelperPool)310 pool := s.pool.(*kindHelperPool)
273 pool.OneDone("")311 pool.OneDone("")
312 // huzzah, that didn't blow up.
274}313}
275314
276func (s *poolSuite) TestOneDoneOnValid(c *C) {315func (s *poolSuite) TestOneDoneValidWNoTag(c *C) {
277 pool := s.pool.(*kindHelperPool)316 pool := s.pool.(*kindHelperPool)
278 ch := pool.Start()317 ch := pool.Start()
279 defer pool.Stop()318 defer pool.Stop()
280319
=== modified file 'messaging/messaging.go'
--- messaging/messaging.go 2014-07-22 13:26:44 +0000
+++ messaging/messaging.go 2014-07-22 13:26:44 +0000
@@ -97,7 +97,7 @@
97 mmu.stopCleanupLoopCh <- true97 mmu.stopCleanupLoopCh <- true
98}98}
9999
100func (mmu *MessagingMenu) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {100func (mmu *MessagingMenu) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
101 if notification == nil {101 if notification == nil {
102 panic("please check notification is not nil before calling present")102 panic("please check notification is not nil before calling present")
103 }103 }
104104
=== modified file 'messaging/messaging_test.go'
--- messaging/messaging_test.go 2014-07-22 13:26:44 +0000
+++ messaging/messaging_test.go 2014-07-22 13:26:44 +0000
@@ -55,7 +55,7 @@
55 card := launch_helper.Card{Summary: "ehlo", Persist: true}55 card := launch_helper.Card{Summary: "ehlo", Persist: true}
56 notif := launch_helper.Notification{Card: &card}56 notif := launch_helper.Notification{Card: &card}
5757
58 c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, true)58 c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, true)
5959
60 c.Check(ms.log.Captured(), Matches, `(?s).* ADD:.*notif-id.*`)60 c.Check(ms.log.Captured(), Matches, `(?s).* ADD:.*notif-id.*`)
61}61}
@@ -65,7 +65,7 @@
65 card := launch_helper.Card{Persist: true}65 card := launch_helper.Card{Persist: true}
66 notif := launch_helper.Notification{Card: &card}66 notif := launch_helper.Notification{Card: &card}
6767
68 c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, false)68 c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, false)
6969
70 c.Check(ms.log.Captured(), Matches, "(?sm).*has no persistable card.*")70 c.Check(ms.log.Captured(), Matches, "(?sm).*has no persistable card.*")
71}71}
@@ -75,19 +75,19 @@
75 card := launch_helper.Card{Summary: "ehlo"}75 card := launch_helper.Card{Summary: "ehlo"}
76 notif := launch_helper.Notification{Card: &card}76 notif := launch_helper.Notification{Card: &card}
7777
78 c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, false)78 c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, false)
7979
80 c.Check(ms.log.Captured(), Matches, "(?sm).*has no persistable card.*")80 c.Check(ms.log.Captured(), Matches, "(?sm).*has no persistable card.*")
81}81}
8282
83func (ms *MessagingSuite) TestPresentPanicsIfNil(c *C) {83func (ms *MessagingSuite) TestPresentPanicsIfNil(c *C) {
84 mmu := New(ms.log)84 mmu := New(ms.log)
85 c.Check(func() { mmu.Present(ms.app, "notif-id", nil) }, Panics, `please check notification is not nil before calling present`)85 c.Check(func() { mmu.Present(ms.app, "notif-id", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
86}86}
8787
88func (ms *MessagingSuite) TestPresentDoesNotPresentsIfNilCard(c *C) {88func (ms *MessagingSuite) TestPresentDoesNotPresentsIfNilCard(c *C) {
89 mmu := New(ms.log)89 mmu := New(ms.log)
90 c.Check(mmu.Present(ms.app, "notif-id", &launch_helper.Notification{}), Equals, false)90 c.Check(mmu.Present(ms.app, "notif-id", "tag", &launch_helper.Notification{}), Equals, false)
91 c.Check(ms.log.Captured(), Matches, "(?sm).*no persistable card.*")91 c.Check(ms.log.Captured(), Matches, "(?sm).*no persistable card.*")
92}92}
9393
@@ -96,7 +96,7 @@
96 card := launch_helper.Card{Summary: "ehlo", Persist: true, Actions: []string{"action-1"}}96 card := launch_helper.Card{Summary: "ehlo", Persist: true, Actions: []string{"action-1"}}
97 notif := launch_helper.Notification{Card: &card}97 notif := launch_helper.Notification{Card: &card}
9898
99 c.Check(mmu.Present(ms.app, "notif-id", &notif), Equals, true)99 c.Check(mmu.Present(ms.app, "notif-id", "tag", &notif), Equals, true)
100100
101 c.Check(ms.log.Captured(), Matches, `(?s).* ADD:.*notif-id.*`)101 c.Check(ms.log.Captured(), Matches, `(?s).* ADD:.*notif-id.*`)
102102
103103
=== modified file 'sounds/sounds.go'
--- sounds/sounds.go 2014-07-22 13:26:44 +0000
+++ sounds/sounds.go 2014-07-22 13:26:44 +0000
@@ -39,7 +39,7 @@
39 return &Sound{player: "paplay", log: log, dataDirs: xdg.Data.Dirs, dataFind: xdg.Data.Find}39 return &Sound{player: "paplay", log: log, dataDirs: xdg.Data.Dirs, dataFind: xdg.Data.Find}
40}40}
4141
42func (snd *Sound) Present(app *click.AppId, nid string, notification *launch_helper.Notification) bool {42func (snd *Sound) Present(app *click.AppId, nid string, tag string, notification *launch_helper.Notification) bool {
43 if notification == nil {43 if notification == nil {
44 panic("please check notification is not nil before calling present")44 panic("please check notification is not nil before calling present")
45 }45 }
4646
=== modified file 'sounds/sounds_test.go'
--- sounds/sounds_test.go 2014-07-22 13:26:44 +0000
+++ sounds/sounds_test.go 2014-07-22 13:26:44 +0000
@@ -56,7 +56,7 @@
56 dataFind: func(s string) (string, error) { return s, nil },56 dataFind: func(s string) (string, error) { return s, nil },
57 }57 }
5858
59 c.Check(s.Present(ss.app, "",59 c.Check(s.Present(ss.app, "", "tag",
60 &launch_helper.Notification{Sound: "hello"}), Equals, true)60 &launch_helper.Notification{Sound: "hello"}), Equals, true)
61 c.Check(ss.log.Captured(), Matches, `(?sm).* playing sound com.example.test/hello using echo`)61 c.Check(ss.log.Captured(), Matches, `(?sm).* playing sound com.example.test/hello using echo`)
62}62}
@@ -70,14 +70,14 @@
70 }70 }
7171
72 // nil notification72 // nil notification
73 c.Check(func() { s.Present(ss.app, "", nil) }, Panics, `please check notification is not nil before calling present`)73 c.Check(func() { s.Present(ss.app, "", "tag", nil) }, Panics, `please check notification is not nil before calling present`)
74 // no Sound74 // no Sound
75 c.Check(s.Present(ss.app, "", &launch_helper.Notification{}), Equals, false)75 c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{}), Equals, false)
76 // bad player76 // bad player
77 c.Check(s.Present(ss.app, "", &launch_helper.Notification{Sound: "hello"}), Equals, false)77 c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{Sound: "hello"}), Equals, false)
78 s.player = "echo"78 s.player = "echo"
79 // no file found79 // no file found
80 c.Check(s.Present(ss.app, "", &launch_helper.Notification{Sound: "hello"}), Equals, false)80 c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{Sound: "hello"}), Equals, false)
8181
82 // and now, just to prove it would've worked,82 // and now, just to prove it would've worked,
8383
@@ -86,5 +86,5 @@
86 c.Assert(err, IsNil)86 c.Assert(err, IsNil)
87 f.Close()87 f.Close()
88 s.dataDirs = func() []string { return []string{"", d} }88 s.dataDirs = func() []string { return []string{"", d} }
89 c.Check(s.Present(ss.app, "", &launch_helper.Notification{Sound: "hello"}), Equals, true)89 c.Check(s.Present(ss.app, "", "tag", &launch_helper.Notification{Sound: "hello"}), Equals, true)
90}90}

Subscribers

People subscribed via source and target branches