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