Merge lp:~chipaca/ubuntu-push/remove-duration into lp:ubuntu-push

Proposed by John Lenton
Status: Superseded
Proposed branch: lp:~chipaca/ubuntu-push/remove-duration
Merge into: lp:ubuntu-push
Prerequisite: lp:~chipaca/ubuntu-push/postal-setup-obj
Diff against target: 156 lines (+8/-48)
6 files modified
bus/haptic/haptic.go (+1/-4)
bus/haptic/haptic_test.go (+0/-30)
client/service/postal_test.go (+1/-1)
docs/highlevel.txt (+2/-5)
docs/lowlevel.txt (+2/-5)
launch_helper/helper_output.go (+2/-3)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/remove-duration
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers Pending
Review via email: mp+230069@code.launchpad.net

Commit message

Remove Vibration's confusing and redundant Duration attribute.

Description of the change

Remove Vibration's confusing and redundant Duration attribute.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bus/haptic/haptic.go'
--- bus/haptic/haptic.go 2014-07-25 10:25:59 +0000
+++ bus/haptic/haptic.go 2014-08-08 09:06:25 +0000
@@ -50,7 +50,7 @@
50 }50 }
5151
52 if notification.Vibrate == nil {52 if notification.Vibrate == nil {
53 haptic.log.Debugf("[%s] notification has no Vibrate: %#v", nid, notification.Vibrate)53 haptic.log.Debugf("[%s] notification has no Vibrate.", nid)
54 return false54 return false
55 }55 }
56 pattern := notification.Vibrate.Pattern56 pattern := notification.Vibrate.Pattern
@@ -58,9 +58,6 @@
58 if repeat == 0 {58 if repeat == 0 {
59 repeat = 159 repeat = 1
60 }60 }
61 if notification.Vibrate.Duration != 0 {
62 pattern = []uint32{notification.Vibrate.Duration}
63 }
64 if len(pattern) == 0 {61 if len(pattern) == 0 {
65 haptic.log.Debugf("[%s] not enough information in the Vibrate to create a pattern", nid)62 haptic.log.Debugf("[%s] not enough information in the Vibrate to create a pattern", nid)
66 return false63 return false
6764
=== modified file 'bus/haptic/haptic_test.go'
--- bus/haptic/haptic_test.go 2014-07-25 10:25:59 +0000
+++ bus/haptic/haptic_test.go 2014-08-08 09:06:25 +0000
@@ -71,36 +71,6 @@
71 c.Check(callArgs[0].Args, DeepEquals, []interface{}{[]uint32{200, 100}, uint32(1)})71 c.Check(callArgs[0].Args, DeepEquals, []interface{}{[]uint32{200, 100}, uint32(1)})
72}72}
7373
74// check that Present() makes a Pattern of [Duration] if Duration is given
75func (hs *hapticSuite) TestPresentBuildsPatternWithDuration(c *C) {
76 endp := testibus.NewTestingEndpoint(nil, condition.Work(true))
77
78 ec := New(endp, hs.log)
79 // note: no Repeat, no Pattern, just Duration:
80 notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200}}
81 c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
82 callArgs := testibus.GetCallArgs(endp)
83 c.Assert(callArgs, HasLen, 1)
84 c.Check(callArgs[0].Member, Equals, "VibratePattern")
85 // note: Pattern of [Duration], Repeat of 1:
86 c.Check(callArgs[0].Args, DeepEquals, []interface{}{[]uint32{200}, uint32(1)})
87}
88
89// check that Present() ignores Pattern and makes a Pattern of [Duration] if Duration is given
90func (hs *hapticSuite) TestPresentOverrides(c *C) {
91 endp := testibus.NewTestingEndpoint(nil, condition.Work(true))
92
93 ec := New(endp, hs.log)
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}}
96 c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
97 callArgs := testibus.GetCallArgs(endp)
98 c.Assert(callArgs, HasLen, 1)
99 c.Check(callArgs[0].Member, Equals, "VibratePattern")
100 // note: Pattern of [Duration], Repeat of 1:
101 c.Check(callArgs[0].Args, DeepEquals, []interface{}{[]uint32{200}, uint32(1)})
102}
103
104// check that Present() doesn't call VibratePattern if things are not right74// check that Present() doesn't call VibratePattern if things are not right
105func (hs *hapticSuite) TestSkipIfMissing(c *C) {75func (hs *hapticSuite) TestSkipIfMissing(c *C) {
106 endp := testibus.NewTestingEndpoint(nil, condition.Work(true))76 endp := testibus.NewTestingEndpoint(nil, condition.Work(true))
10777
=== modified file 'client/service/postal_test.go'
--- client/service/postal_test.go 2014-08-08 09:06:25 +0000
+++ client/service/postal_test.go 2014-08-08 09:06:25 +0000
@@ -522,7 +522,7 @@
522522
523 // Persist is false so we just check the log523 // Persist is false so we just check the log
524 card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Body: "body-value", Popup: true, Persist: false}524 card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Body: "body-value", Popup: true, Persist: false}
525 vib := &launch_helper.Vibration{Duration: 500}525 vib := &launch_helper.Vibration{Pattern: []uint32{1}}
526 emb := &launch_helper.EmblemCounter{Count: 2, Visible: true}526 emb := &launch_helper.EmblemCounter{Count: 2, Visible: true}
527 output := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{Card: card, EmblemCounter: emb, Vibrate: vib}}527 output := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{Card: card, EmblemCounter: emb, Vibrate: vib}}
528 b := svc.messageHandler(&click.AppId{}, "", output)528 b := svc.messageHandler(&click.AppId{}, "", output)
529529
=== modified file 'docs/highlevel.txt'
--- docs/highlevel.txt 2014-08-08 09:06:25 +0000
+++ docs/highlevel.txt 2014-08-08 09:06:25 +0000
@@ -208,7 +208,6 @@
208 "sound": "buzz.mp3",208 "sound": "buzz.mp3",
209 "vibrate": {209 "vibrate": {
210 "pattern": [200, 100],210 "pattern": [200, 100],
211 "duration": 200,
212 "repeat": 2211 "repeat": 2
213 }212 }
214 "emblem-counter": {213 "emblem-counter": {
@@ -249,8 +248,7 @@
249248
250The notification can contain a **vibrate** field, causing haptic feedback, that has the following content:249The notification can contain a **vibrate** field, causing haptic feedback, that has the following content:
251250
252:pattern: a list of integers describing a vibration pattern.251:pattern: a list of integers describing a vibration pattern (duration of alternating vibration/no vibration times, in milliseconds).
253:duration: duration in milliseconds. Is equivalent to setting pattern to [duration], and overrides pattern.
254:repeat: number of times the pattern has to be repeated (defaults to 1, 0 is the same as 1).252:repeat: number of times the pattern has to be repeated (defaults to 1, 0 is the same as 1).
255253
256The notification can contain a **emblem-counter** field, with the following content:254The notification can contain a **emblem-counter** field, with the following content:
@@ -304,8 +302,7 @@
304 "sound": "buzz.mp3",302 "sound": "buzz.mp3",
305 "tag": "foo",303 "tag": "foo",
306 "vibrate": {304 "vibrate": {
307 "duration": 200,305 "pattern": [200, 100],
308 "pattern": (200, 100),
309 "repeat": 2306 "repeat": 2
310 }307 }
311 "emblem-counter": {308 "emblem-counter": {
312309
=== modified file 'docs/lowlevel.txt'
--- docs/lowlevel.txt 2014-08-08 09:06:25 +0000
+++ docs/lowlevel.txt 2014-08-08 09:06:25 +0000
@@ -302,7 +302,6 @@
302 "sound": "buzz.mp3",302 "sound": "buzz.mp3",
303 "vibrate": {303 "vibrate": {
304 "pattern": [200, 100],304 "pattern": [200, 100],
305 "duration": 200,
306 "repeat": 2305 "repeat": 2
307 }306 }
308 "emblem-counter": {307 "emblem-counter": {
@@ -343,8 +342,7 @@
343342
344The notification can contain a **vibrate** field, causing haptic feedback, that has the following content:343The notification can contain a **vibrate** field, causing haptic feedback, that has the following content:
345344
346:pattern: a list of integers describing a vibration pattern.345:pattern: a list of integers describing a vibration pattern (duration of alternating vibration/no vibration times, in milliseconds).
347:duration: duration in milliseconds. Is equivalent to setting pattern to [duration], and overrides pattern.
348:repeat: number of times the pattern has to be repeated (defaults to 1, 0 is the same as 1).346:repeat: number of times the pattern has to be repeated (defaults to 1, 0 is the same as 1).
349347
350The notification can contain a **emblem-counter** field, with the following content:348The notification can contain a **emblem-counter** field, with the following content:
@@ -398,8 +396,7 @@
398 "sound": "buzz.mp3",396 "sound": "buzz.mp3",
399 "tag": "foo",397 "tag": "foo",
400 "vibrate": {398 "vibrate": {
401 "duration": 200,399 "pattern": [200, 100],
402 "pattern": (200, 100),
403 "repeat": 2400 "repeat": 2
404 }401 }
405 "emblem-counter": {402 "emblem-counter": {
406403
=== modified file 'launch_helper/helper_output.go'
--- launch_helper/helper_output.go 2014-08-08 09:06:25 +0000
+++ launch_helper/helper_output.go 2014-08-08 09:06:25 +0000
@@ -44,9 +44,8 @@
44// a Vibration generates a vibration in the form of a Pattern set in44// a Vibration generates a vibration in the form of a Pattern set in
45// duration a pattern of on off states, repeated a number of times45// duration a pattern of on off states, repeated a number of times
46type Vibration struct {46type Vibration struct {
47 Duration uint32 `json:"duration"` // if Duration is present and not 0, it's like a Pattern of [Duration]; otherwise, Pattern is used.47 Pattern []uint32 `json:"pattern"`
48 Pattern []uint32 `json:"pattern"`48 Repeat uint32 `json:"repeat"` // defaults to 1. A value of zero is ignored (so it's like 1).
49 Repeat uint32 `json:"repeat"` // defaults to 1. A value of zero is ignored (so it's like 1).
50}49}
5150
52// a Notification can be any of the above51// a Notification can be any of the above

Subscribers

People subscribed via source and target branches