Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | dobey | ||||||||||||
Approved revision: | 419 | ||||||||||||
Merged at revision: | 151 | ||||||||||||
Proposed branch: | lp:ubuntu-push/automatic | ||||||||||||
Merge into: | lp:ubuntu-push | ||||||||||||
Diff against target: |
1190 lines (+282/-172) 25 files modified
accounts/caccounts.go (+2/-0) click/click_test.go (+28/-13) client/client.go (+6/-1) client/client_test.go (+7/-0) client/service/postal.go (+17/-14) client/service/postal_test.go (+33/-12) client/service/service_test.go (+3/-1) client/session/session_test.go (+20/-8) config/config_test.go (+1/-1) debian/control (+1/-2) debian/rules (+17/-6) http13client/z_last_test.go (+2/-1) identifier/testing/testing_test.go (+3/-2) launch_helper/cual/cual_c.go (+2/-0) launch_helper/kindpool.go (+13/-4) launch_helper/kindpool_test.go (+34/-4) messaging/cmessaging/cmessaging_c.go (+2/-0) poller/poller.go (+27/-40) poller/poller_test.go (+10/-17) scripts/connect-many.py (+1/-1) signing-helper/CMakeLists.txt (+2/-2) signing-helper/signing-helper.cpp (+43/-38) signing-helper/signing.h (+5/-3) tests/autopilot/push_notifications/README (+1/-2) urldispatcher/curldispatcher/curldispatcher_c.go (+2/-0) |
||||||||||||
To merge this branch: | bzr merge lp:ubuntu-push/automatic | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Samuele Pedroni | Approve | ||
Review via email: mp+276920@code.launchpad.net |
Commit message
Add support for signing methods other than POST via argv[2].
Test fixes for Go 1.5.
Avoid losing notifications when screen is locked.
Fix lp:1469398 by using the connectivity state.
Fix case where a failed powerd wakeup request would deadlock step().
Assert whether or not there's a connection using the same method as local connectivity package.
Description of the change
To post a comment you must log in.
Revision history for this message
Samuele Pedroni (pedronis) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'accounts/caccounts.go' |
2 | --- accounts/caccounts.go 2014-09-05 10:47:29 +0000 |
3 | +++ accounts/caccounts.go 2015-11-30 21:13:39 +0000 |
4 | @@ -3,6 +3,8 @@ |
5 | /* |
6 | #include <libaccounts-glib/accounts-glib.h> |
7 | |
8 | +void gocb(); |
9 | + |
10 | static void cb(AgManager *manager, AgAccountId account_id, gpointer p) { |
11 | AgAccount *account = ag_manager_get_account(manager, account_id); |
12 | if (!account) { |
13 | |
14 | === modified file 'click/click_test.go' |
15 | --- click/click_test.go 2014-09-17 19:38:34 +0000 |
16 | +++ click/click_test.go 2015-11-30 21:13:39 +0000 |
17 | @@ -1,5 +1,5 @@ |
18 | /* |
19 | - Copyright 2013-2014 Canonical Ltd. |
20 | + Copyright 2013-2015 Canonical Ltd. |
21 | |
22 | This program is free software: you can redistribute it and/or modify it |
23 | under the terms of the GNU General Public License version 3, as published |
24 | @@ -19,6 +19,8 @@ |
25 | import ( |
26 | "encoding/json" |
27 | "fmt" |
28 | + "os/exec" |
29 | + "strings" |
30 | "testing" |
31 | |
32 | . "launchpad.net/gocheck" |
33 | @@ -32,6 +34,16 @@ |
34 | |
35 | var _ = Suite(&clickSuite{}) |
36 | |
37 | +func GetPyVer() string { |
38 | + out, err := exec.Command("python3", "-V").Output() |
39 | + if err != nil { |
40 | + panic(err) |
41 | + } |
42 | + pyver := strings.Replace(string(out[:]), "Python ", "", -1) |
43 | + vers := strings.Split(pyver, ".") |
44 | + return fmt.Sprintf("%s.%s", vers[0], vers[1]) |
45 | +} |
46 | + |
47 | func (cs *clickSuite) TestParseAppId(c *C) { |
48 | app, err := ParseAppId("com.ubuntu.clock_clock") |
49 | c.Assert(err, IsNil) |
50 | @@ -72,18 +84,19 @@ |
51 | } |
52 | |
53 | func (cs *clickSuite) TestParseAppIdLegacy(c *C) { |
54 | - app, err := ParseAppId("_python3.4") |
55 | + pyver := fmt.Sprintf("python%s", GetPyVer()) |
56 | + app, err := ParseAppId(fmt.Sprintf("_%s", pyver)) |
57 | c.Assert(err, IsNil) |
58 | c.Check(app.Package, Equals, "") |
59 | c.Check(app.InPackage(""), Equals, true) |
60 | - c.Check(app.Application, Equals, "python3.4") |
61 | + c.Check(app.Application, Equals, pyver) |
62 | c.Check(app.Version, Equals, "") |
63 | c.Check(app.Click, Equals, false) |
64 | - c.Check(app.Original(), Equals, "_python3.4") |
65 | - c.Check(app.Versioned(), Equals, "python3.4") |
66 | - c.Check(app.Base(), Equals, "python3.4") |
67 | - c.Check(app.DesktopId(), Equals, "python3.4.desktop") |
68 | - c.Check(app.DispatchPackage(), Equals, "python3.4") |
69 | + c.Check(app.Original(), Equals, fmt.Sprintf("_%s", pyver)) |
70 | + c.Check(app.Versioned(), Equals, pyver) |
71 | + c.Check(app.Base(), Equals, pyver) |
72 | + c.Check(app.DesktopId(), Equals, fmt.Sprintf("%s.desktop", pyver)) |
73 | + c.Check(app.DispatchPackage(), Equals, pyver) |
74 | |
75 | for _, s := range []string{"_.foo", "_foo/", "_/foo"} { |
76 | app, err = ParseAppId(s) |
77 | @@ -93,7 +106,8 @@ |
78 | } |
79 | |
80 | func (cs *clickSuite) TestJSON(c *C) { |
81 | - for _, appId := range []string{"com.ubuntu.clock_clock", "com.ubuntu.clock_clock_10", "_python3.4"} { |
82 | + pyver := fmt.Sprintf("python%s", GetPyVer()) |
83 | + for _, appId := range []string{"com.ubuntu.clock_clock", "com.ubuntu.clock_clock_10", fmt.Sprintf("_%s", pyver)} { |
84 | app, err := ParseAppId(appId) |
85 | c.Assert(err, IsNil, Commentf(appId)) |
86 | b, err := json.Marshal(app) |
87 | @@ -106,9 +120,10 @@ |
88 | } |
89 | |
90 | func (cs *clickSuite) TestIcon(c *C) { |
91 | - app, err := ParseAppId("_python3.4") |
92 | + pyver := fmt.Sprintf("python%s", GetPyVer()) |
93 | + app, err := ParseAppId(fmt.Sprintf("_%s", pyver)) |
94 | c.Assert(err, IsNil) |
95 | - c.Check(app.Icon(), Equals, "/usr/share/pixmaps/python3.4.xpm") |
96 | + c.Check(app.Icon(), Equals, fmt.Sprintf("/usr/share/pixmaps/%s.xpm", pyver)) |
97 | } |
98 | |
99 | func (s *clickSuite) TestUser(c *C) { |
100 | @@ -161,7 +176,7 @@ |
101 | func (s *clickSuite) TestInstalledLegacy(c *C) { |
102 | u, err := User() |
103 | c.Assert(err, IsNil) |
104 | - app, err := ParseAppId("_python3.4") |
105 | + app, err := ParseAppId(fmt.Sprintf("_python%s", GetPyVer())) |
106 | c.Assert(err, IsNil) |
107 | c.Check(u.Installed(app, false), Equals, true) |
108 | } |
109 | @@ -198,7 +213,7 @@ |
110 | func (s *clickSuite) TestSymbolicIconCallsSymbolic(c *C) { |
111 | symbolic = func(string) string { return "xyzzy" } |
112 | defer func() { symbolic = _symbolic }() |
113 | - app, err := ParseAppId("_python3.4") |
114 | + app, err := ParseAppId(fmt.Sprintf("_python%s", GetPyVer())) |
115 | c.Assert(err, IsNil) |
116 | c.Check(app.SymbolicIcon(), Equals, "xyzzy") |
117 | } |
118 | |
119 | === modified file 'client/client.go' |
120 | --- client/client.go 2015-04-01 17:43:20 +0000 |
121 | +++ client/client.go 2015-11-30 21:13:39 +0000 |
122 | @@ -442,6 +442,11 @@ |
123 | return nil |
124 | } |
125 | |
126 | +func (client *PushClient) handeConnNotification(conn bool) { |
127 | + client.session.HasConnectivity(conn) |
128 | + client.poller.HasConnectivity(conn) |
129 | +} |
130 | + |
131 | // doLoop connects events with their handlers |
132 | func (client *PushClient) doLoop(connhandler func(bool), bcasthandler func(*session.BroadcastNotification) error, ucasthandler func(session.AddressedNotification) error, unregisterhandler func(*click.AppId), accountshandler func()) { |
133 | for { |
134 | @@ -475,7 +480,7 @@ |
135 | |
136 | // Loop calls doLoop with the "real" handlers |
137 | func (client *PushClient) Loop() { |
138 | - client.doLoop(client.session.HasConnectivity, |
139 | + client.doLoop(client.handeConnNotification, |
140 | client.handleBroadcastNotification, |
141 | client.handleUnicastNotification, |
142 | client.handleUnregister, |
143 | |
144 | === modified file 'client/client_test.go' |
145 | --- client/client_test.go 2015-04-01 16:02:31 +0000 |
146 | +++ client/client_test.go 2015-11-30 21:13:39 +0000 |
147 | @@ -1032,6 +1032,7 @@ |
148 | ******************************************************************/ |
149 | |
150 | type loopSession struct{ hasConn bool } |
151 | +type loopPoller struct{} |
152 | |
153 | func (s *loopSession) ResetCookie() {} |
154 | func (s *loopSession) State() session.ClientSessionState { |
155 | @@ -1045,6 +1046,11 @@ |
156 | func (s *loopSession) KeepConnection() error { return nil } |
157 | func (s *loopSession) StopKeepConnection() {} |
158 | |
159 | +func (p *loopPoller) HasConnectivity(hasConn bool) {} |
160 | +func (p *loopPoller) IsConnected() bool { return false } |
161 | +func (p *loopPoller) Start() error { return nil } |
162 | +func (p *loopPoller) Run() error { return nil } |
163 | + |
164 | func (cs *clientSuite) TestLoop(c *C) { |
165 | cli := NewPushClient(cs.configPath, cs.leveldbPath) |
166 | cli.connCh = make(chan bool) |
167 | @@ -1070,6 +1076,7 @@ |
168 | c.Assert(cli.session, NotNil) |
169 | cli.session.StopKeepConnection() |
170 | cli.session = &loopSession{} |
171 | + cli.poller = &loopPoller{} |
172 | |
173 | go cli.Loop() |
174 | |
175 | |
176 | === modified file 'client/service/postal.go' |
177 | --- client/service/postal.go 2015-07-14 19:00:39 +0000 |
178 | +++ client/service/postal.go 2015-11-30 21:13:39 +0000 |
179 | @@ -428,27 +428,30 @@ |
180 | return false |
181 | } |
182 | |
183 | + locked := svc.unityGreeter.IsActive() |
184 | + focused := svc.windowStack.IsAppFocused(app) |
185 | + |
186 | if output.Notification.Card != nil && output.Notification.Card.Popup { |
187 | - if svc.unityGreeter.IsActive() { |
188 | + if locked { |
189 | // Screen is locked, ensure popup is false |
190 | output.Notification.Card.Popup = false |
191 | } |
192 | } |
193 | |
194 | - if !svc.windowStack.IsAppFocused(app) { |
195 | - if isBlacklisted(app) { |
196 | - svc.Log.Debugf("notification skipped (except emblem counter) because app is blacklisted") |
197 | - return svc.emblemCounter.Present(app, nid, output.Notification) |
198 | - } |
199 | - |
200 | - b := false |
201 | - for _, p := range svc.Presenters { |
202 | - // we don't want this to shortcut :) |
203 | - b = p.Present(app, nid, output.Notification) || b |
204 | - } |
205 | - return b |
206 | - } else { |
207 | + if !locked && focused { |
208 | svc.Log.Debugf("notification skipped because app is focused.") |
209 | return false |
210 | } |
211 | + |
212 | + if isBlacklisted(app) { |
213 | + svc.Log.Debugf("notification skipped (except emblem counter) because app is blacklisted") |
214 | + return svc.emblemCounter.Present(app, nid, output.Notification) |
215 | + } |
216 | + |
217 | + b := false |
218 | + for _, p := range svc.Presenters { |
219 | + // we don't want this to shortcut :) |
220 | + b = p.Present(app, nid, output.Notification) || b |
221 | + } |
222 | + return b |
223 | } |
224 | |
225 | === modified file 'client/service/postal_test.go' |
226 | --- client/service/postal_test.go 2015-04-16 15:46:46 +0000 |
227 | +++ client/service/postal_test.go 2015-11-30 21:13:39 +0000 |
228 | @@ -134,6 +134,7 @@ |
229 | } |
230 | |
231 | type fakeUrlDispatcher struct { |
232 | + DispatchDone chan bool |
233 | DispatchCalls [][]string |
234 | TestURLCalls []map[string][]string |
235 | NextTestURLResult bool |
236 | @@ -148,6 +149,7 @@ |
237 | if fud.DispatchShouldFail { |
238 | return errors.New("fail!") |
239 | } |
240 | + fud.DispatchDone <- true |
241 | return nil |
242 | } |
243 | |
244 | @@ -196,7 +198,13 @@ |
245 | ps.bus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true)) |
246 | ps.notifBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true)) |
247 | ps.counterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true)) |
248 | - ps.accountsBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), map[string]dbus.Variant{"IncomingMessageVibrate": dbus.Variant{true}}) |
249 | + ps.accountsBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), map[string]dbus.Variant{ |
250 | + "IncomingMessageVibrate": dbus.Variant{true}, |
251 | + "SilentMode": dbus.Variant{false}, |
252 | + "IncomingMessageSound": dbus.Variant{""}, |
253 | + "IncomingMessageVibrateSilentMode": dbus.Variant{false}, |
254 | + }) |
255 | + |
256 | ps.hapticBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true)) |
257 | ps.unityGreeterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), false) |
258 | ps.winStackBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), []windowstack.WindowsInfo{}) |
259 | @@ -557,14 +565,13 @@ |
260 | svc.NotificationsEndp = endp |
261 | svc.UnityGreeterEndp = ps.unityGreeterBus |
262 | svc.WindowStackEndp = ps.winStackBus |
263 | + nopTicker := make(chan []interface{}) |
264 | + testibus.SetWatchSource(endp, "ActionInvoked", nopTicker) |
265 | + defer close(nopTicker) |
266 | svc.launchers = map[string]launch_helper.HelperLauncher{} |
267 | svc.fallbackVibration = &launch_helper.Vibration{Pattern: []uint32{1}} |
268 | c.Assert(svc.Start(), IsNil) |
269 | |
270 | - nopTicker := make(chan []interface{}) |
271 | - testibus.SetWatchSource(endp, "ActionInvoked", nopTicker) |
272 | - defer close(nopTicker) |
273 | - |
274 | // Persist is false so we just check the log |
275 | card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Body: "body-value", Popup: true, Persist: false} |
276 | vib := json.RawMessage(`true`) |
277 | @@ -660,20 +667,19 @@ |
278 | app, _ := click.ParseAppId("com.example.test_test-app") |
279 | c.Assert(svc.Start(), IsNil) |
280 | fakeDisp := new(fakeUrlDispatcher) |
281 | + fakeDisp.DispatchDone = make(chan bool) |
282 | svc.urlDispatcher = fakeDisp |
283 | fakeDisp.NextTestURLResult = true |
284 | svc.messagingMenu = fmm |
285 | aCh := make(chan *notifications.RawAction) |
286 | rCh := make(chan *reply.MMActionReply) |
287 | - bCh := make(chan bool) |
288 | go func() { |
289 | aCh <- nil // just in case? |
290 | aCh <- ¬ifications.RawAction{App: app, Action: "potato://", Nid: "xyzzy"} |
291 | close(aCh) |
292 | - bCh <- true |
293 | }() |
294 | go svc.handleActions(aCh, rCh) |
295 | - takeNextBool(bCh) |
296 | + takeNextBool(fakeDisp.DispatchDone) |
297 | fakeDisp.Lock.Lock() |
298 | defer fakeDisp.Lock.Unlock() |
299 | c.Assert(len(fakeDisp.DispatchCalls), Equals, 1) |
300 | @@ -687,19 +693,18 @@ |
301 | c.Assert(svc.Start(), IsNil) |
302 | fakeDisp := new(fakeUrlDispatcher) |
303 | svc.urlDispatcher = fakeDisp |
304 | + fakeDisp.DispatchDone = make(chan bool) |
305 | fakeDisp.NextTestURLResult = true |
306 | app, _ := click.ParseAppId("com.example.test_test-app") |
307 | aCh := make(chan *notifications.RawAction) |
308 | rCh := make(chan *reply.MMActionReply) |
309 | - bCh := make(chan bool) |
310 | go func() { |
311 | rCh <- nil // just in case? |
312 | rCh <- &reply.MMActionReply{App: app, Action: "potato://", Notification: "foo.bar"} |
313 | close(rCh) |
314 | - bCh <- true |
315 | }() |
316 | go svc.handleActions(aCh, rCh) |
317 | - takeNextBool(bCh) |
318 | + takeNextBool(fakeDisp.DispatchDone) |
319 | fakeDisp.Lock.Lock() |
320 | defer fakeDisp.Lock.Unlock() |
321 | c.Assert(len(fakeDisp.DispatchCalls), Equals, 1) |
322 | @@ -857,6 +862,7 @@ |
323 | []windowstack.WindowsInfo{}, |
324 | []windowstack.WindowsInfo{}, |
325 | []windowstack.WindowsInfo{}) |
326 | + ps.unityGreeterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), false, false, false, false) |
327 | svc := ps.replaceBuses(NewPostalService(ps.cfg, ps.log)) |
328 | svc.Start() |
329 | ps.blacklisted = false |
330 | @@ -871,7 +877,22 @@ |
331 | c.Check(svc.messageHandler(app, "0", output), Equals, true) |
332 | c.Check(svc.messageHandler(app, "1", embOut), Equals, true) |
333 | ps.blacklisted = true |
334 | - // and regular notifications (but not emblem counters) are supprsessed if blacklisted. |
335 | + // and regular notifications (but not emblem counters) are suppressed if blacklisted. |
336 | c.Check(svc.messageHandler(app, "2", output), Equals, false) |
337 | c.Check(svc.messageHandler(app, "3", embOut), Equals, true) |
338 | } |
339 | + |
340 | +func (ps *postalSuite) TestFocusedAppButLockedScreenNotification(c *C) { |
341 | + appId := "com.example.test_test-app" |
342 | + ps.winStackBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), []windowstack.WindowsInfo{{0, appId, true, 0}}) |
343 | + ps.unityGreeterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), true) |
344 | + svc := ps.replaceBuses(NewPostalService(ps.cfg, ps.log)) |
345 | + // svc.WindowStackEndp = ps.winStackBus |
346 | + svc.Start() |
347 | + |
348 | + card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Persist: true} |
349 | + output := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{Card: card}} |
350 | + app := clickhelp.MustParseAppId(fmt.Sprintf("%v_0", appId)) |
351 | + |
352 | + c.Check(svc.messageHandler(app, "0", output), Equals, true) |
353 | +} |
354 | |
355 | === modified file 'client/service/service_test.go' |
356 | --- client/service/service_test.go 2014-11-25 17:30:03 +0000 |
357 | +++ client/service/service_test.go 2015-11-30 21:13:39 +0000 |
358 | @@ -36,7 +36,9 @@ |
359 | "launchpad.net/ubuntu-push/testing/condition" |
360 | ) |
361 | |
362 | -func TestService(t *testing.T) { TestingT(t) } |
363 | +func TestService(t *testing.T) { |
364 | + TestingT(t) |
365 | +} |
366 | |
367 | type serviceSuite struct { |
368 | log logger.Logger |
369 | |
370 | === modified file 'client/session/session_test.go' |
371 | --- client/session/session_test.go 2015-04-17 12:55:00 +0000 |
372 | +++ client/session/session_test.go 2015-11-30 21:13:39 +0000 |
373 | @@ -1021,8 +1021,20 @@ |
374 | }() |
375 | } |
376 | |
377 | +func (s *loopSuite) waitUntilRunning(c *C) { |
378 | + delay := time.Duration(1000) |
379 | + for i := 0; i < 5; i++ { |
380 | + if s.sess.State() == Running { |
381 | + return |
382 | + } |
383 | + time.Sleep(delay) |
384 | + delay *= 2 |
385 | + } |
386 | + c.Check(s.sess.State(), Equals, Running) |
387 | +} |
388 | + |
389 | func (s *loopSuite) TestLoopReadError(c *C) { |
390 | - c.Check(s.sess.State(), Equals, Running) |
391 | + s.waitUntilRunning(c) |
392 | s.upCh <- errors.New("Read") |
393 | err := <-s.sess.errCh |
394 | c.Check(err, ErrorMatches, "Read") |
395 | @@ -1030,7 +1042,7 @@ |
396 | } |
397 | |
398 | func (s *loopSuite) TestLoopPing(c *C) { |
399 | - c.Check(s.sess.State(), Equals, Running) |
400 | + s.waitUntilRunning(c) |
401 | c.Check(takeNext(s.downCh), Equals, "deadline 1ms") |
402 | s.upCh <- protocol.PingPongMsg{Type: "ping"} |
403 | c.Check(takeNext(s.downCh), Equals, protocol.PingPongMsg{Type: "pong"}) |
404 | @@ -1040,7 +1052,7 @@ |
405 | } |
406 | |
407 | func (s *loopSuite) TestLoopLoopsDaLoop(c *C) { |
408 | - c.Check(s.sess.State(), Equals, Running) |
409 | + s.waitUntilRunning(c) |
410 | for i := 1; i < 10; i++ { |
411 | c.Check(takeNext(s.downCh), Equals, "deadline 1ms") |
412 | s.upCh <- protocol.PingPongMsg{Type: "ping"} |
413 | @@ -1053,7 +1065,7 @@ |
414 | } |
415 | |
416 | func (s *loopSuite) TestLoopBroadcast(c *C) { |
417 | - c.Check(s.sess.State(), Equals, Running) |
418 | + s.waitUntilRunning(c) |
419 | b := &protocol.BroadcastMsg{ |
420 | Type: "broadcast", |
421 | AppId: "--ignored--", |
422 | @@ -1070,7 +1082,7 @@ |
423 | } |
424 | |
425 | func (s *loopSuite) TestLoopNotifications(c *C) { |
426 | - c.Check(s.sess.State(), Equals, Running) |
427 | + s.waitUntilRunning(c) |
428 | |
429 | n1 := protocol.Notification{ |
430 | AppId: "app1", |
431 | @@ -1090,7 +1102,7 @@ |
432 | } |
433 | |
434 | func (s *loopSuite) TestLoopSetParams(c *C) { |
435 | - c.Check(s.sess.State(), Equals, Running) |
436 | + s.waitUntilRunning(c) |
437 | setParams := protocol.SetParamsMsg{ |
438 | Type: "setparams", |
439 | SetCookie: "COOKIE", |
440 | @@ -1104,7 +1116,7 @@ |
441 | } |
442 | |
443 | func (s *loopSuite) TestLoopConnBroken(c *C) { |
444 | - c.Check(s.sess.State(), Equals, Running) |
445 | + s.waitUntilRunning(c) |
446 | broken := protocol.ConnBrokenMsg{ |
447 | Type: "connbroken", |
448 | Reason: "REASON", |
449 | @@ -1126,7 +1138,7 @@ |
450 | failure := errors.New("warn") |
451 | log := s.sess.Log.(*helpers.TestLogger) |
452 | |
453 | - c.Check(s.sess.State(), Equals, Running) |
454 | + s.waitUntilRunning(c) |
455 | c.Check(takeNext(s.downCh), Equals, "deadline 1ms") |
456 | log.ResetCapture() |
457 | s.upCh <- warn |
458 | |
459 | === modified file 'config/config_test.go' |
460 | --- config/config_test.go 2014-05-16 15:37:24 +0000 |
461 | +++ config/config_test.go 2015-11-30 21:13:39 +0000 |
462 | @@ -344,7 +344,7 @@ |
463 | "d": json.RawMessage(`"2s"`), |
464 | } |
465 | readUsingFlags(p, reflect.ValueOf(&cfg)) |
466 | - c.Check(buf.String(), Matches, `(?s).*-cfg@=<config.json>: get config values from file\n.*-d="2s": duration.*`) |
467 | + c.Check(buf.String(), Matches, `(?s).*get config values from file.*duration.*`) |
468 | } |
469 | |
470 | func (s *configFlagsSuite) TestReadUsingFlagsAlreadyParsed(c *C) { |
471 | |
472 | === modified file 'debian/control' |
473 | --- debian/control 2014-09-05 10:48:36 +0000 |
474 | +++ debian/control 2015-11-30 21:13:39 +0000 |
475 | @@ -62,10 +62,9 @@ |
476 | The Ubuntu Push Notifications dev & testing server. |
477 | |
478 | Package: ubuntu-push-autopilot |
479 | -Architecture: any |
480 | +Architecture: amd64 armhf i386 |
481 | Multi-Arch: foreign |
482 | Depends: unity8-autopilot, |
483 | - unity-scope-click, |
484 | ubuntu-push-client, |
485 | Recommends: ubuntu-push-dev-server, |
486 | Built-Using: ${misc:Built-Using} |
487 | |
488 | === modified file 'debian/rules' |
489 | --- debian/rules 2015-08-14 13:03:23 +0000 |
490 | +++ debian/rules 2015-11-30 21:13:39 +0000 |
491 | @@ -4,16 +4,27 @@ |
492 | export DH_GOPKG := launchpad.net/ubuntu-push |
493 | export UBUNTU_PUSH_TEST_RESOURCES_ROOT := $(CURDIR) |
494 | |
495 | +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) |
496 | + |
497 | +ifneq (,$(filter $(DEB_HOST_ARCH), arm64 powerpc ppc64el)) |
498 | + pkg_configs = ubuntuoneauth-2.0 libaccounts-glib click-0.4 ubuntu-app-launch-2 url-dispatcher-1 messaging-menu dbus-1 libnih libnih-dbus glib-2.0 gobject-2.0 |
499 | + export CGO_CFLAGS := \ |
500 | + $(shell $(foreach pkg, $(pkg_configs), pkg-config --cflags $(pkg); )) |
501 | + export CGO_CXXFLAGS := $(CGO_CFLAGS) |
502 | + export CGO_LDFLAGS := \ |
503 | + $(shell $(foreach pkg, $(pkg_configs), pkg-config --libs $(pkg); )) |
504 | + $(warning setting CGO_CFLAGS = $(CGO_CFLAGS)) |
505 | + $(warning setting CGO_CXXFLAGS = $(CGO_CXXFLAGS)) |
506 | + $(warning setting CGO_LDFLAGS = $(CGO_LDFLAGS)) |
507 | + |
508 | + # some tests seem to hang |
509 | + DEB_BUILD_OPTIONS := nocheck $(DEB_BUILD_OPTIONS) |
510 | +endif |
511 | + |
512 | override_dh_auto_build: |
513 | dh_auto_build --buildsystem=golang |
514 | (cd signing-helper && cmake . && make) |
515 | |
516 | -# overriding dh_auto_test because the http13client tests don't all pass on go < 1.3 |
517 | -# (should go away once we ship go 1.3) |
518 | -override_dh_auto_test: |
519 | - cd $$( find ./ -type d -regex '\./[^/]*/src/launchpad.net' -printf "%h\n" | head -n1) && \ |
520 | - env GOPATH=$$(cd ..; pwd) go test -v $$(env GOPATH=$$(cd ..; pwd) go list $(DH_GOPKG)/... | grep -v acceptance | grep -v http13client ) |
521 | - |
522 | override_dh_install: |
523 | dh_install -Xusr/bin/cmd --fail-missing |
524 | |
525 | |
526 | === modified file 'http13client/z_last_test.go' |
527 | --- http13client/z_last_test.go 2014-03-19 20:20:19 +0000 |
528 | +++ http13client/z_last_test.go 2015-11-30 21:13:39 +0000 |
529 | @@ -5,7 +5,7 @@ |
530 | package http_test |
531 | |
532 | import ( |
533 | - "launchpad.net/ubuntu-push/http13client" |
534 | + "net/http" |
535 | "runtime" |
536 | "sort" |
537 | "strings" |
538 | @@ -26,6 +26,7 @@ |
539 | strings.Contains(stack, "created by net.startServer") || |
540 | strings.Contains(stack, "created by testing.RunTests") || |
541 | strings.Contains(stack, "closeWriteAndWait") || |
542 | + strings.Contains(stack, "main.main(") || |
543 | strings.Contains(stack, "testing.Main(") || |
544 | // These only show up with GOTRACEBACK=2; Issue 5005 (comment 28) |
545 | strings.Contains(stack, "runtime.goexit") || |
546 | |
547 | === modified file 'identifier/testing/testing_test.go' |
548 | --- identifier/testing/testing_test.go 2014-08-04 20:40:50 +0000 |
549 | +++ identifier/testing/testing_test.go 2015-11-30 21:13:39 +0000 |
550 | @@ -17,9 +17,10 @@ |
551 | package testing |
552 | |
553 | import ( |
554 | - identifier ".." |
555 | + "testing" |
556 | + |
557 | . "launchpad.net/gocheck" |
558 | - "testing" |
559 | + "launchpad.net/ubuntu-push/identifier" |
560 | ) |
561 | |
562 | // hook up gocheck |
563 | |
564 | === modified file 'launch_helper/cual/cual_c.go' |
565 | --- launch_helper/cual/cual_c.go 2014-07-17 15:46:19 +0000 |
566 | +++ launch_helper/cual/cual_c.go 2015-11-30 21:13:39 +0000 |
567 | @@ -24,6 +24,8 @@ |
568 | |
569 | #define HELPER_ERROR g_quark_from_static_string ("cgo-ual-helper-error-quark") |
570 | |
571 | +void helperDone(gpointer gp, const gchar * ciid); |
572 | + |
573 | static void observer_of_stop (const gchar * app_id, const gchar * instance_id, const gchar * helper_type, gpointer user_data) { |
574 | helperDone (user_data, instance_id); |
575 | } |
576 | |
577 | === modified file 'launch_helper/kindpool.go' |
578 | --- launch_helper/kindpool.go 2015-04-24 09:25:47 +0000 |
579 | +++ launch_helper/kindpool.go 2015-11-30 21:13:39 +0000 |
580 | @@ -26,7 +26,7 @@ |
581 | "sync" |
582 | "time" |
583 | |
584 | - "launchpad.net/go-xdg/v0" |
585 | + xdg "launchpad.net/go-xdg/v0" |
586 | |
587 | "launchpad.net/ubuntu-push/click" |
588 | "launchpad.net/ubuntu-push/launch_helper/cual" |
589 | @@ -67,6 +67,8 @@ |
590 | hmap map[string]*HelperArgs |
591 | maxRuntime time.Duration |
592 | maxNum int |
593 | + // hook |
594 | + growBacklog func([]*HelperInput, *HelperInput) []*HelperInput |
595 | } |
596 | |
597 | // DefaultLaunchers produces the default map for kind -> HelperLauncher |
598 | @@ -79,13 +81,15 @@ |
599 | |
600 | // a HelperPool that delegates to different per kind HelperLaunchers |
601 | func NewHelperPool(launchers map[string]HelperLauncher, log logger.Logger) HelperPool { |
602 | - return &kindHelperPool{ |
603 | + newPool := &kindHelperPool{ |
604 | log: log, |
605 | hmap: make(map[string]*HelperArgs), |
606 | launchers: launchers, |
607 | maxRuntime: 5 * time.Second, |
608 | maxNum: 5, |
609 | } |
610 | + newPool.growBacklog = newPool.doGrowBacklog |
611 | + return newPool |
612 | } |
613 | |
614 | func (pool *kindHelperPool) Start() chan *HelperResult { |
615 | @@ -121,8 +125,7 @@ |
616 | return |
617 | } |
618 | if len(running) >= pool.maxNum || running[in.App.Original()] { |
619 | - backlog = append(backlog, in) |
620 | - pool.log.Debugf("current helper input backlog has grown to %d entries.", len(backlog)) |
621 | + backlog = pool.growBacklog(backlog, in) |
622 | } else { |
623 | if pool.tryOne(in) { |
624 | running[in.App.Original()] = true |
625 | @@ -154,6 +157,12 @@ |
626 | } |
627 | } |
628 | |
629 | +func (pool *kindHelperPool) doGrowBacklog(backlog []*HelperInput, in *HelperInput) []*HelperInput { |
630 | + backlog = append(backlog, in) |
631 | + pool.log.Debugf("current helper input backlog has grown to %d entries.", len(backlog)) |
632 | + return backlog |
633 | +} |
634 | + |
635 | func (pool *kindHelperPool) shrinkBacklog(backlog []*HelperInput, backlogSz int) []*HelperInput { |
636 | if backlogSz == 0 { |
637 | return nil |
638 | |
639 | === modified file 'launch_helper/kindpool_test.go' |
640 | --- launch_helper/kindpool_test.go 2015-08-14 11:55:33 +0000 |
641 | +++ launch_helper/kindpool_test.go 2015-11-30 21:13:39 +0000 |
642 | @@ -24,7 +24,7 @@ |
643 | "path/filepath" |
644 | "time" |
645 | |
646 | - "launchpad.net/go-xdg/v0" |
647 | + xdg "launchpad.net/go-xdg/v0" |
648 | . "launchpad.net/gocheck" |
649 | |
650 | "launchpad.net/ubuntu-push/click" |
651 | @@ -451,6 +451,15 @@ |
652 | // checks that the an Nth helper run goes to the backlog |
653 | func (s *poolSuite) TestRunNthAppToBacklog(c *C) { |
654 | s.pool.(*kindHelperPool).maxNum = 2 |
655 | + doGrowBacklog := s.pool.(*kindHelperPool).doGrowBacklog |
656 | + grownTo1 := make(chan struct{}) |
657 | + s.pool.(*kindHelperPool).growBacklog = func(bl []*HelperInput, in *HelperInput) []*HelperInput { |
658 | + res := doGrowBacklog(bl, in) |
659 | + if len(res) == 1 { |
660 | + close(grownTo1) |
661 | + } |
662 | + return res |
663 | + } |
664 | ch := s.pool.Start() |
665 | defer s.pool.Stop() |
666 | |
667 | @@ -482,6 +491,11 @@ |
668 | |
669 | s.pool.Run("fake", input3) |
670 | |
671 | + select { |
672 | + case <-grownTo1: |
673 | + case <-time.After(time.Second): |
674 | + c.Fatal("timeout waiting for result") |
675 | + } |
676 | go s.fakeLauncher.done("0") |
677 | s.waitForArgs(c, "Launch") |
678 | |
679 | @@ -502,6 +516,16 @@ |
680 | |
681 | func (s *poolSuite) TestRunBacklogFailedContinuesDiffApp(c *C) { |
682 | s.pool.(*kindHelperPool).maxNum = 1 |
683 | + doGrowBacklog := s.pool.(*kindHelperPool).doGrowBacklog |
684 | + grownTo3 := make(chan struct{}) |
685 | + s.pool.(*kindHelperPool).growBacklog = func(bl []*HelperInput, in *HelperInput) []*HelperInput { |
686 | + res := doGrowBacklog(bl, in) |
687 | + if len(res) == 3 { |
688 | + close(grownTo3) |
689 | + } |
690 | + return res |
691 | + } |
692 | + |
693 | ch := s.pool.Start() |
694 | defer s.pool.Stop() |
695 | |
696 | @@ -536,15 +560,21 @@ |
697 | s.pool.Run("fake", input3) |
698 | s.pool.Run("fake", input4) |
699 | |
700 | + select { |
701 | + case <-grownTo3: |
702 | + case <-time.After(time.Second): |
703 | + c.Fatal("timeout waiting for result") |
704 | + } |
705 | go s.fakeLauncher.done("0") |
706 | // Everything up to here was just set-up. |
707 | // |
708 | // What we're checking for is that, if a helper launch fails, the |
709 | // next one in the backlog is picked up. |
710 | - c.Assert(takeNext(ch, c).Input.App, Equals, app1) |
711 | - c.Assert(takeNext(ch, c).Input.App, Equals, app2) |
712 | - go s.fakeLauncher.done("2") |
713 | + takeNext(ch, c) |
714 | + takeNext(ch, c) |
715 | s.waitForArgs(c, "Launch") |
716 | + go s.fakeLauncher.done("1") |
717 | + c.Assert(takeNext(ch, c).Input.App, Equals, app3) |
718 | c.Check(s.log.Captured(), Matches, |
719 | `(?ms).* helper input backlog has grown to 3 entries\.$.*shrunk to 1 entries\.$`) |
720 | } |
721 | |
722 | === modified file 'messaging/cmessaging/cmessaging_c.go' |
723 | --- messaging/cmessaging/cmessaging_c.go 2014-07-24 10:33:28 +0000 |
724 | +++ messaging/cmessaging/cmessaging_c.go 2015-11-30 21:13:39 +0000 |
725 | @@ -21,6 +21,8 @@ |
726 | |
727 | // this is a .go file instead of a .c file because of dh-golang limitations |
728 | |
729 | +void handleActivate(gchar* c_action, const gchar * c_notification , gpointer obj); |
730 | + |
731 | static void activate_cb(MessagingMenuMessage* msg, gchar* action, GVariant* parameter, gpointer obj) { |
732 | handleActivate(action, messaging_menu_message_get_id(msg), obj); |
733 | } |
734 | |
735 | === modified file 'poller/poller.go' |
736 | --- poller/poller.go 2015-04-29 15:22:03 +0000 |
737 | +++ poller/poller.go 2015-11-30 21:13:39 +0000 |
738 | @@ -27,7 +27,6 @@ |
739 | "launchpad.net/ubuntu-push/bus" |
740 | "launchpad.net/ubuntu-push/bus/polld" |
741 | "launchpad.net/ubuntu-push/bus/powerd" |
742 | - "launchpad.net/ubuntu-push/bus/urfkill" |
743 | "launchpad.net/ubuntu-push/client/session" |
744 | "launchpad.net/ubuntu-push/logger" |
745 | "launchpad.net/ubuntu-push/util" |
746 | @@ -56,6 +55,7 @@ |
747 | IsConnected() bool |
748 | Start() error |
749 | Run() error |
750 | + HasConnectivity(bool) |
751 | } |
752 | |
753 | type PollerSetup struct { |
754 | @@ -69,9 +69,9 @@ |
755 | log logger.Logger |
756 | powerd powerd.Powerd |
757 | polld polld.Polld |
758 | - urfkill urfkill.URfkill |
759 | cookie string |
760 | sessionState stater |
761 | + connCh chan bool |
762 | requestWakeupCh chan struct{} |
763 | requestedWakeupErrCh chan error |
764 | holdsWakeLockCh chan bool |
765 | @@ -84,6 +84,7 @@ |
766 | powerd: nil, |
767 | polld: nil, |
768 | sessionState: setup.SessionStateGetter, |
769 | + connCh: make(chan bool), |
770 | requestWakeupCh: make(chan struct{}), |
771 | requestedWakeupErrCh: make(chan error), |
772 | holdsWakeLockCh: make(chan bool), |
773 | @@ -94,6 +95,10 @@ |
774 | return p.sessionState.State() == session.Running |
775 | } |
776 | |
777 | +func (p *poller) HasConnectivity(hasConn bool) { |
778 | + p.connCh <- hasConn |
779 | +} |
780 | + |
781 | func (p *poller) Start() error { |
782 | if p.log == nil { |
783 | return ErrUnconfigured |
784 | @@ -101,12 +106,12 @@ |
785 | if p.powerd != nil || p.polld != nil { |
786 | return ErrAlreadyStarted |
787 | } |
788 | + |
789 | powerdEndp := bus.SystemBus.Endpoint(powerd.BusAddress, p.log) |
790 | polldEndp := bus.SessionBus.Endpoint(polld.BusAddress, p.log) |
791 | - urEndp := bus.SystemBus.Endpoint(urfkill.BusAddress, p.log) |
792 | - urWLANKillswitchEndp := bus.SystemBus.Endpoint(urfkill.WLANKillswitchBusAddress, p.log) |
793 | + |
794 | var wg sync.WaitGroup |
795 | - wg.Add(4) |
796 | + wg.Add(2) |
797 | go func() { |
798 | n := util.NewAutoRedialer(powerdEndp).Redial() |
799 | p.log.Debugf("powerd dialed on try %d", n) |
800 | @@ -117,21 +122,10 @@ |
801 | p.log.Debugf("polld dialed in on try %d", n) |
802 | wg.Done() |
803 | }() |
804 | - go func() { |
805 | - n := util.NewAutoRedialer(urEndp).Redial() |
806 | - p.log.Debugf("URfkill dialed on try %d", n) |
807 | - wg.Done() |
808 | - }() |
809 | - go func() { |
810 | - n := util.NewAutoRedialer(urWLANKillswitchEndp).Redial() |
811 | - p.log.Debugf("URfkill (WLAN killswitch) dialed on try %d", n) |
812 | - wg.Done() |
813 | - }() |
814 | wg.Wait() |
815 | |
816 | p.powerd = powerd.New(powerdEndp, p.log) |
817 | p.polld = polld.New(polldEndp, p.log) |
818 | - p.urfkill = urfkill.New(urEndp, urWLANKillswitchEndp, p.log) |
819 | |
820 | // busy sleep loop to workaround go's timer/sleep |
821 | // not accounting for time when the system is suspended |
822 | @@ -154,7 +148,7 @@ |
823 | if p.log == nil { |
824 | return ErrUnconfigured |
825 | } |
826 | - if p.powerd == nil || p.polld == nil || p.urfkill == nil { |
827 | + if p.powerd == nil || p.polld == nil { |
828 | return ErrNotStarted |
829 | } |
830 | wakeupCh, err := p.powerd.WatchWakeups() |
831 | @@ -165,19 +159,8 @@ |
832 | if err != nil { |
833 | return err |
834 | } |
835 | - flightMode := p.urfkill.IsFlightMode() |
836 | - wlanKillswitchState := p.urfkill.GetWLANKillswitchState() |
837 | - flightModeCh, _, err := p.urfkill.WatchFlightMode() |
838 | - if err != nil { |
839 | - return err |
840 | - } |
841 | - wlanKillswitchStateCh, _, err := p.urfkill.WatchWLANKillswitchState() |
842 | - if err != nil { |
843 | - return err |
844 | - } |
845 | - |
846 | filteredWakeUpCh := make(chan bool) |
847 | - go p.control(wakeupCh, filteredWakeUpCh, flightMode, flightModeCh, wlanKillswitchState, wlanKillswitchStateCh) |
848 | + go p.control(wakeupCh, filteredWakeUpCh) |
849 | go p.run(filteredWakeUpCh, doneCh) |
850 | return nil |
851 | } |
852 | @@ -195,9 +178,10 @@ |
853 | return t, cookie, err |
854 | } |
855 | |
856 | -func (p *poller) control(wakeupCh <-chan bool, filteredWakeUpCh chan<- bool, flightMode bool, flightModeCh <-chan bool, wlanKillswitchState urfkill.KillswitchState, wlanKillswitchStateCh <-chan urfkill.KillswitchState) { |
857 | - wirelessEnabled := wlanKillswitchState == urfkill.KillswitchStateUnblocked |
858 | - dontPoll := flightMode && !wirelessEnabled |
859 | +func (p *poller) control(wakeupCh <-chan bool, filteredWakeUpCh chan<- bool) { |
860 | + // Assume a connection, and poll immediately. |
861 | + connected := true |
862 | + dontPoll := !connected |
863 | var t time.Time |
864 | cookie := "" |
865 | holdsWakeLock := false |
866 | @@ -234,12 +218,12 @@ |
867 | filteredWakeUpCh <- true |
868 | } |
869 | } |
870 | - case flightMode = <-flightModeCh: |
871 | - case wlanKillswitchState = <-wlanKillswitchStateCh: |
872 | - wirelessEnabled = wlanKillswitchState == urfkill.KillswitchStateUnblocked |
873 | + case state := <-p.connCh: |
874 | + connected = state |
875 | + p.log.Debugf("control: connected:%v", state) |
876 | } |
877 | - newDontPoll := flightMode && !wirelessEnabled |
878 | - p.log.Debugf("control: flightMode:%v wirelessEnabled:%v prevDontPoll:%v dontPoll:%v wakeupReq:%v holdsWakeLock:%v", flightMode, wirelessEnabled, dontPoll, newDontPoll, !t.IsZero(), holdsWakeLock) |
879 | + newDontPoll := !connected |
880 | + p.log.Debugf("control: prevDontPoll:%v dontPoll:%v wakeupReq:%v holdsWakeLock:%v", dontPoll, newDontPoll, !t.IsZero(), holdsWakeLock) |
881 | if newDontPoll != dontPoll { |
882 | if dontPoll = newDontPoll; dontPoll { |
883 | if !t.IsZero() { |
884 | @@ -255,7 +239,12 @@ |
885 | } else { |
886 | if t.IsZero() && !holdsWakeLock { |
887 | // reschedule soon |
888 | - t, cookie, _ = p.doRequestWakeup(p.times.NetworkWait / 20) |
889 | + var err error |
890 | + t, cookie, err = p.doRequestWakeup(p.times.NetworkWait / 20) |
891 | + if err != nil { |
892 | + // Make sure we break a potential deadlock by trying again. |
893 | + filteredWakeUpCh <- true |
894 | + } |
895 | } |
896 | } |
897 | } |
898 | @@ -291,8 +280,6 @@ |
899 | if lockCookie != "" { |
900 | if err := p.powerd.ClearWakelock(lockCookie); err != nil { |
901 | p.log.Errorf("ClearWakelock(%#v) got %v", lockCookie, err) |
902 | - } else { |
903 | - p.log.Debugf("cleared wakelock cookie %s.", lockCookie) |
904 | } |
905 | lockCookie = "" |
906 | } |
907 | |
908 | === modified file 'poller/poller_test.go' |
909 | --- poller/poller_test.go 2015-04-29 15:22:03 +0000 |
910 | +++ poller/poller_test.go 2015-11-30 21:13:39 +0000 |
911 | @@ -21,7 +21,6 @@ |
912 | |
913 | . "launchpad.net/gocheck" |
914 | |
915 | - "launchpad.net/ubuntu-push/bus/urfkill" |
916 | "launchpad.net/ubuntu-push/client/session" |
917 | helpers "launchpad.net/ubuntu-push/testing" |
918 | ) |
919 | @@ -91,11 +90,6 @@ |
920 | s.myd = &myD{} |
921 | } |
922 | |
923 | -const ( |
924 | - wlanOn = urfkill.KillswitchStateUnblocked |
925 | - wlanOff = urfkill.KillswitchStateSoftBlocked |
926 | -) |
927 | - |
928 | func (s *PrSuite) TestStep(c *C) { |
929 | p := &poller{ |
930 | times: Times{}, |
931 | @@ -106,6 +100,7 @@ |
932 | requestWakeupCh: make(chan struct{}), |
933 | requestedWakeupErrCh: make(chan error), |
934 | holdsWakeLockCh: make(chan bool), |
935 | + connCh: make(chan bool), |
936 | } |
937 | s.myd.reqLockCookie = "wakelock cookie" |
938 | s.myd.stateState = session.Running |
939 | @@ -117,7 +112,7 @@ |
940 | ch := make(chan string) |
941 | // now, run |
942 | filteredWakeUpCh := make(chan bool) |
943 | - go p.control(wakeupCh, filteredWakeUpCh, false, nil, wlanOn, nil) |
944 | + go p.control(wakeupCh, filteredWakeUpCh) |
945 | go func() { ch <- p.step(filteredWakeUpCh, doneCh, "old cookie") }() |
946 | select { |
947 | case s := <-ch: |
948 | @@ -139,15 +134,15 @@ |
949 | requestWakeupCh: make(chan struct{}), |
950 | requestedWakeupErrCh: make(chan error), |
951 | holdsWakeLockCh: make(chan bool), |
952 | + connCh: make(chan bool), |
953 | } |
954 | wakeUpCh := make(chan bool) |
955 | filteredWakeUpCh := make(chan bool) |
956 | s.myd.watchWakeCh = make(chan bool, 1) |
957 | - flightModeCh := make(chan bool) |
958 | - wlanKillswitchStateCh := make(chan urfkill.KillswitchState) |
959 | - go p.control(wakeUpCh, filteredWakeUpCh, false, flightModeCh, wlanOn, wlanKillswitchStateCh) |
960 | + go p.control(wakeUpCh, filteredWakeUpCh) |
961 | |
962 | // works |
963 | + p.HasConnectivity(true) |
964 | err := p.requestWakeup() |
965 | c.Assert(err, IsNil) |
966 | c.Check(<-s.myd.watchWakeCh, Equals, true) |
967 | @@ -161,19 +156,17 @@ |
968 | wakeUpCh <- true |
969 | <-filteredWakeUpCh |
970 | |
971 | - // flight mode |
972 | - flightModeCh <- true |
973 | - wlanKillswitchStateCh <- wlanOff |
974 | + p.HasConnectivity(false) |
975 | err = p.requestWakeup() |
976 | c.Assert(err, IsNil) |
977 | c.Check(s.myd.watchWakeCh, HasLen, 0) |
978 | |
979 | - // wireless on |
980 | - wlanKillswitchStateCh <- wlanOn |
981 | + // connected |
982 | + p.HasConnectivity(true) |
983 | c.Check(<-s.myd.watchWakeCh, Equals, true) |
984 | |
985 | - // wireless off |
986 | - wlanKillswitchStateCh <- wlanOff |
987 | + // disconnected |
988 | + p.HasConnectivity(false) |
989 | // pending wakeup was cleared |
990 | c.Check(<-s.myd.watchWakeCh, Equals, false) |
991 | |
992 | |
993 | === modified file 'scripts/connect-many.py' |
994 | --- scripts/connect-many.py 2014-08-04 14:47:00 +0000 |
995 | +++ scripts/connect-many.py 2015-11-30 21:13:39 +0000 |
996 | @@ -16,7 +16,7 @@ |
997 | try: |
998 | for i in range(soft+100): |
999 | s=socket.socket() |
1000 | - w = ssl.wrap_socket(s) |
1001 | + w = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1) |
1002 | w.settimeout(1) |
1003 | w.connect(addr) |
1004 | conns.append(w) |
1005 | |
1006 | === modified file 'signing-helper/CMakeLists.txt' |
1007 | --- signing-helper/CMakeLists.txt 2014-04-30 17:34:57 +0000 |
1008 | +++ signing-helper/CMakeLists.txt 2015-11-30 21:13:39 +0000 |
1009 | @@ -13,8 +13,8 @@ |
1010 | SET (CMAKE_AUTOMOC ON) |
1011 | find_package(Qt5Core REQUIRED) |
1012 | |
1013 | -FILE (GLOB SIGNING_SOURCES signing*.cpp) |
1014 | -FILE (GLOB SIGNING_HEADERS signing*.h) |
1015 | +SET (SIGNING_SOURCES signing-helper.cpp) |
1016 | +SET (SIGNING_HEADERS signing.h) |
1017 | |
1018 | add_executable (${SIGNING_EXE} |
1019 | ${SIGNING_SOURCES} |
1020 | |
1021 | === modified file 'signing-helper/signing-helper.cpp' |
1022 | --- signing-helper/signing-helper.cpp 2014-06-04 15:52:22 +0000 |
1023 | +++ signing-helper/signing-helper.cpp 2015-11-30 21:13:39 +0000 |
1024 | @@ -1,5 +1,5 @@ |
1025 | /* |
1026 | - * Copyright (C) 2013-2014 Canonical Ltd. |
1027 | + * Copyright (C) 2013-2015 Canonical Ltd. |
1028 | * |
1029 | * This program is free software: you can redistribute it and/or modify it |
1030 | * under the terms of the GNU General Public License version 3, as published |
1031 | @@ -27,6 +27,8 @@ |
1032 | * files in the program, then also delete it here. |
1033 | */ |
1034 | |
1035 | +#include "signing.h" |
1036 | + |
1037 | #include <iostream> |
1038 | #include <QCoreApplication> |
1039 | #include <QDebug> |
1040 | @@ -35,44 +37,44 @@ |
1041 | #include <QTimer> |
1042 | #include <QUrlQuery> |
1043 | |
1044 | -#include "ssoservice.h" |
1045 | -#include "token.h" |
1046 | - |
1047 | -#include "signing.h" |
1048 | - |
1049 | namespace UbuntuOne { |
1050 | |
1051 | - SigningExample::SigningExample(QObject *parent, QString url) : |
1052 | - QObject(parent) |
1053 | - { |
1054 | - QObject::connect(&service, SIGNAL(credentialsFound(const Token&)), |
1055 | - this, SLOT(handleCredentialsFound(Token))); |
1056 | - QObject::connect(&service, SIGNAL(credentialsNotFound()), |
1057 | - this, SLOT(handleCredentialsNotFound())); |
1058 | - this->url = url; |
1059 | - |
1060 | - } |
1061 | - |
1062 | - SigningExample::~SigningExample(){ |
1063 | - } |
1064 | - |
1065 | - void SigningExample::doExample() |
1066 | - { |
1067 | - service.getCredentials(); |
1068 | - } |
1069 | - |
1070 | - void SigningExample::handleCredentialsFound(Token token) |
1071 | - { |
1072 | - qDebug() << "Credentials found, signing url."; |
1073 | - std::cout << token.signUrl(this->url, QStringLiteral("POST")).toStdString(); |
1074 | - QCoreApplication::instance()->exit(0); |
1075 | - } |
1076 | - |
1077 | - void SigningExample::handleCredentialsNotFound() |
1078 | - { |
1079 | - qDebug() << "No credentials were found."; |
1080 | - QCoreApplication::instance()->exit(1); |
1081 | - } |
1082 | +SigningExample::SigningExample(QObject *parent, const QString& url) : |
1083 | + QObject(parent), |
1084 | + m_url(url), |
1085 | + m_method("POST") |
1086 | +{ |
1087 | + QObject::connect(&service, SIGNAL(credentialsFound(const Token&)), |
1088 | + this, SLOT(handleCredentialsFound(Token))); |
1089 | + QObject::connect(&service, SIGNAL(credentialsNotFound()), |
1090 | + this, SLOT(handleCredentialsNotFound())); |
1091 | +} |
1092 | + |
1093 | +SigningExample::~SigningExample(){ |
1094 | +} |
1095 | + |
1096 | +void SigningExample::setMethod(const QString& method) |
1097 | +{ |
1098 | + m_method = method; |
1099 | +} |
1100 | + |
1101 | +void SigningExample::doExample() |
1102 | +{ |
1103 | + service.getCredentials(); |
1104 | +} |
1105 | + |
1106 | +void SigningExample::handleCredentialsFound(Token token) |
1107 | +{ |
1108 | + qDebug() << "Credentials found, signing url."; |
1109 | + std::cout << token.signUrl(m_url, m_method).toStdString(); |
1110 | + QCoreApplication::instance()->exit(0); |
1111 | +} |
1112 | + |
1113 | +void SigningExample::handleCredentialsNotFound() |
1114 | +{ |
1115 | + qDebug() << "No credentials were found."; |
1116 | + QCoreApplication::instance()->exit(1); |
1117 | +} |
1118 | |
1119 | |
1120 | } // namespace UbuntuOne |
1121 | @@ -81,10 +83,13 @@ |
1122 | int main(int argc, char *argv[]) |
1123 | { |
1124 | QCoreApplication a(argc, argv); |
1125 | - if (argc<2) { |
1126 | + if (argc < 2) { |
1127 | return 2; |
1128 | } |
1129 | UbuntuOne::SigningExample *example = new UbuntuOne::SigningExample(&a, argv[1]); |
1130 | + if (argc == 3) { |
1131 | + example->setMethod(argv[2]); |
1132 | + } |
1133 | QObject::connect(example, SIGNAL(finished()), &a, SLOT(quit())); |
1134 | QTimer::singleShot(0, example, SLOT(doExample())); |
1135 | return a.exec(); |
1136 | |
1137 | === modified file 'signing-helper/signing.h' |
1138 | --- signing-helper/signing.h 2014-05-01 10:24:23 +0000 |
1139 | +++ signing-helper/signing.h 2015-11-30 21:13:39 +0000 |
1140 | @@ -48,9 +48,11 @@ |
1141 | |
1142 | public: |
1143 | |
1144 | - explicit SigningExample(QObject *parent = 0, QString url="https://one.ubuntu.com/api/account/"); |
1145 | + explicit SigningExample(QObject *parent = 0, const QString& url="https://one.ubuntu.com/api/account/"); |
1146 | ~SigningExample(); |
1147 | |
1148 | + void setMethod(const QString& method); |
1149 | + |
1150 | public slots: |
1151 | |
1152 | void doExample(); |
1153 | @@ -68,8 +70,8 @@ |
1154 | |
1155 | SSOService service; |
1156 | QNetworkAccessManager nam; |
1157 | - QString url; |
1158 | - |
1159 | + QString m_url; |
1160 | + QString m_method; |
1161 | }; |
1162 | |
1163 | } |
1164 | |
1165 | === modified file 'tests/autopilot/push_notifications/README' |
1166 | --- tests/autopilot/push_notifications/README 2014-06-24 14:46:26 +0000 |
1167 | +++ tests/autopilot/push_notifications/README 2015-11-30 21:13:39 +0000 |
1168 | @@ -31,8 +31,7 @@ |
1169 | |
1170 | Install depenendencies: |
1171 | |
1172 | -1) sudo apt-get install unity8-autopilot unity-click-scope |
1173 | - Note: unity-click-scope is required for unity8-autopilot tests and is currently required for running tests on emulator. |
1174 | +1) sudo apt-get install unity8-autopilot |
1175 | 2) bzr branch lp:ubuntu-push |
1176 | 3) Edit ip address and ports to match environment: ubuntu-push/tests/autopilot/push_notifications/config/push.conf: |
1177 | [config] |
1178 | |
1179 | === modified file 'urldispatcher/curldispatcher/curldispatcher_c.go' |
1180 | --- urldispatcher/curldispatcher/curldispatcher_c.go 2014-08-29 16:36:30 +0000 |
1181 | +++ urldispatcher/curldispatcher/curldispatcher_c.go 2015-11-30 21:13:39 +0000 |
1182 | @@ -23,6 +23,8 @@ |
1183 | #include <liburl-dispatcher-1/url-dispatcher.h> |
1184 | #include <glib.h> |
1185 | |
1186 | +char* handleDispatchURLResult(const gchar * url, gboolean success, gpointer user_data); |
1187 | + |
1188 | static void url_dispatch_callback(const gchar * url, gboolean success, gpointer user_data) { |
1189 | handleDispatchURLResult(url, success, user_data); |
1190 | } |