188
246
func (cs *clientSuite) TestConfigureSetsUpEndpoints(c *C) {
189
247
cli := NewPushClient(cs.configPath, cs.leveldbPath)
191
// keep these in the same order as in the client struct, for sanity
192
c.Check(cli.notificationsEndp, IsNil)
193
c.Check(cli.urlDispatcherEndp, IsNil)
194
249
c.Check(cli.connectivityEndp, IsNil)
195
c.Check(cli.emblemcounterEndp, IsNil)
196
c.Check(cli.hapticEndp, IsNil)
197
250
c.Check(cli.systemImageEndp, IsNil)
198
c.Check(cli.pushServiceEndpoint, IsNil)
199
c.Check(cli.postalServiceEndpoint, IsNil)
200
251
err := cli.configure()
201
252
c.Assert(err, IsNil)
202
c.Check(cli.notificationsEndp, NotNil)
203
c.Check(cli.urlDispatcherEndp, NotNil)
204
253
c.Check(cli.connectivityEndp, NotNil)
205
c.Check(cli.emblemcounterEndp, NotNil)
206
c.Check(cli.hapticEndp, NotNil)
207
254
c.Check(cli.systemImageEndp, NotNil)
208
c.Check(cli.pushServiceEndpoint, NotNil)
209
c.Check(cli.postalServiceEndpoint, NotNil)
212
257
func (cs *clientSuite) TestConfigureSetsUpConnCh(c *C) {
279
326
addresses checking tests
280
327
******************************************************************/
329
type testInstalledChecker func(*click.AppId, bool) bool
331
func (tic testInstalledChecker) Installed(app *click.AppId, setVersion bool) bool {
332
return tic(app, setVersion)
336
appId1 = "com.example.app1_app1"
337
appId2 = "com.example.app2_app2"
338
appIdHello = "com.example.test_hello"
339
app1 = clickhelp.MustParseAppId(appId1)
340
app2 = clickhelp.MustParseAppId(appId2)
341
appHello = clickhelp.MustParseAppId(appIdHello)
282
344
func (cs *clientSuite) TestCheckForAddressee(c *C) {
283
345
cli := NewPushClient(cs.configPath, cs.leveldbPath)
284
cli.unregisterCh = make(chan string, 5)
347
cli.unregisterCh = make(chan *click.AppId, 5)
285
348
cli.StartAddresseeBatch()
287
cli.hasPackage = func(appId string) bool {
350
cli.installedChecker = testInstalledChecker(func(app *click.AppId, setVersion bool) bool {
352
c.Assert(setVersion, Equals, true)
353
if app.Original() == appId1 {
294
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: "app1"}), Equals, false)
359
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: "bad-id"}), IsNil)
360
c.Check(calls, Equals, 0)
361
c.Assert(cli.unregisterCh, HasLen, 0)
362
c.Check(cs.log.Captured(), Matches, `DEBUG notification "" for invalid app id "bad-id".\n`)
363
cs.log.ResetCapture()
365
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: appId1}), IsNil)
295
366
c.Check(calls, Equals, 1)
296
367
c.Assert(cli.unregisterCh, HasLen, 1)
297
c.Check(<-cli.unregisterCh, Equals, "app1")
298
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: "app2"}), Equals, true)
299
c.Check(calls, Equals, 2)
300
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: "app1"}), Equals, false)
301
c.Check(calls, Equals, 2)
302
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: "app2"}), Equals, true)
368
c.Check(<-cli.unregisterCh, DeepEquals, app1)
369
c.Check(cs.log.Captured(), Matches, `DEBUG notification "" for missing app id "com.example.app1_app1".\n`)
370
cs.log.ResetCapture()
372
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: appId2}), DeepEquals, app2)
373
c.Check(calls, Equals, 2)
374
c.Check(cs.log.Captured(), Matches, "")
375
cs.log.ResetCapture()
377
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: appId1}), IsNil)
378
c.Check(calls, Equals, 2)
379
c.Check(cli.CheckForAddressee(&protocol.Notification{AppId: appId2}), DeepEquals, app2)
303
380
c.Check(calls, Equals, 2)
304
381
c.Check(cli.unregisterCh, HasLen, 0)
382
c.Check(cs.log.Captured(), Matches, "")
307
385
/*****************************************************************
396
475
startService tests
397
476
******************************************************************/
399
func (cs *clientSuite) TestStartServiceWorks(c *C) {
400
cs.writeTestConfig(map[string]interface{}{
401
"auth_helper": helpers.ScriptAbsPath("dummyauth.sh"),
403
cli := NewPushClient(cs.configPath, cs.leveldbPath)
404
err := cli.configure()
407
cli.deviceId = "fake-id"
408
cli.pushServiceEndpoint = testibus.NewTestingEndpoint(condition.Work(true), nil)
409
cli.postalServiceEndpoint = testibus.NewTestingEndpoint(condition.Work(true), nil)
410
c.Check(cli.pushService, IsNil)
411
c.Check(cli.startService(), IsNil)
412
c.Assert(cli.pushService, NotNil)
413
pushService := cli.pushService.(*service.PushService)
414
c.Check(pushService.IsRunning(), Equals, true)
415
c.Assert(cli.setupPostalService(), IsNil)
416
c.Assert(cli.startPostalService(), IsNil)
417
c.Check(cli.postalService.IsRunning(), Equals, true)
419
cli.postalService.Stop()
422
func (cs *clientSuite) TestStartServiceSetupError(c *C) {
478
func (cs *clientSuite) TestStartPushServiceCallsStart(c *C) {
479
cli := NewPushClient(cs.configPath, cs.leveldbPath)
482
c.Check(cli.startPushService(), IsNil)
483
c.Check(d.startCount, Equals, 1)
486
func (cs *clientSuite) TestStartPostServiceCallsStart(c *C) {
487
cli := NewPushClient(cs.configPath, cs.leveldbPath)
489
cli.postalService = d
490
c.Check(cli.startPostalService(), IsNil)
491
c.Check(d.startCount, Equals, 1)
494
func (cs *clientSuite) TestSetupPushServiceSetupError(c *C) {
423
495
cs.writeTestConfig(map[string]interface{}{
424
496
"registration_url": "%gh",
426
498
cli := NewPushClient(cs.configPath, cs.leveldbPath)
427
499
err := cli.configure()
428
500
c.Assert(err, IsNil)
429
err = cli.startService()
501
err = cli.setupPushService()
430
502
c.Check(err, ErrorMatches, "cannot parse registration url:.*")
433
func (cs *clientSuite) TestStartServiceErrorsOnNilLog(c *C) {
434
cli := NewPushClient(cs.configPath, cs.leveldbPath)
435
c.Check(cli.log, IsNil)
436
c.Check(cli.startService(), NotNil)
437
c.Assert(cli.setupPostalService(), IsNil)
438
c.Assert(cli.startPostalService(), NotNil)
441
func (cs *clientSuite) TestStartServiceErrorsOnBusDialPushFail(c *C) {
442
cli := NewPushClient(cs.configPath, cs.leveldbPath)
444
cli.pushServiceEndpoint = testibus.NewTestingEndpoint(condition.Work(false), nil)
445
cli.postalServiceEndpoint = testibus.NewTestingEndpoint(condition.Work(false), nil)
446
c.Check(cli.startService(), NotNil)
447
c.Assert(cli.setupPostalService(), IsNil)
448
c.Assert(cli.startPostalService(), NotNil)
451
func (cs *clientSuite) TestStartServiceErrorsOnBusDialPostalFail(c *C) {
452
cli := NewPushClient(cs.configPath, cs.leveldbPath)
454
cli.pushServiceEndpoint = testibus.NewTestingEndpoint(condition.Work(true), nil)
455
cli.postalServiceEndpoint = testibus.NewTestingEndpoint(condition.Work(false), nil)
456
c.Check(cli.startService(), IsNil)
457
c.Assert(cli.setupPostalService(), IsNil)
458
c.Assert(cli.startPostalService(), NotNil)
505
func (cs *clientSuite) TestSetupPushService(c *C) {
506
cli := NewPushClient(cs.configPath, cs.leveldbPath)
507
c.Assert(cli.configure(), IsNil)
508
c.Check(cli.pushService, IsNil)
509
c.Check(cli.setupPushService(), IsNil)
510
c.Check(cli.pushService, NotNil)
513
func (cs *clientSuite) TestStartPushErrorsOnPushStartError(c *C) {
514
cli := NewPushClient(cs.configPath, cs.leveldbPath)
516
err := errors.New("potato")
519
c.Check(cli.startPushService(), Equals, err)
520
c.Check(d.startCount, Equals, 1)
523
func (cs *clientSuite) TestStartPostalErrorsOnPostalStartError(c *C) {
524
cli := NewPushClient(cs.configPath, cs.leveldbPath)
526
err := errors.New("potato")
528
cli.postalService = d
529
c.Check(cli.startPostalService(), Equals, err)
530
c.Check(d.startCount, Equals, 1)
461
533
/*****************************************************************
511
578
siCond := condition.Fail2Work(2)
512
579
siEndp := testibus.NewMultiValuedTestingEndpoint(siCond, condition.Work(true), []interface{}{int32(101), "mako", "daily", "Unknown", map[string]string{}})
513
580
testibus.SetWatchTicker(cEndp, make(chan bool))
514
ecCond := condition.Fail2Work(13)
515
ecEndp := testibus.NewTestingEndpoint(ecCond, condition.Work(true))
516
haCond := condition.Fail2Work(2)
517
haEndp := testibus.NewTestingEndpoint(haCond, condition.Work(true))
518
581
// ok, create the thing
519
582
cli := NewPushClient(cs.configPath, cs.leveldbPath)
521
584
err := cli.configure()
522
585
c.Assert(err, IsNil)
523
// the user actions channel has not been set up
524
c.Check(cli.actionsCh, IsNil)
526
587
// and stomp on things for testing
527
588
cli.config.ConnectivityConfig.ConnectivityCheckURL = ts.URL
528
589
cli.config.ConnectivityConfig.ConnectivityCheckMD5 = staticHash
529
cli.notificationsEndp = nEndp
530
cli.urlDispatcherEndp = uEndp
531
590
cli.connectivityEndp = cEndp
532
cli.emblemcounterEndp = ecEndp
533
cli.hapticEndp = haEndp
534
591
cli.systemImageEndp = siEndp
536
593
c.Assert(cli.takeTheBus(), IsNil)
537
c.Assert(cli.setupPostalService(), IsNil)
538
c.Assert(cli.takePostalServiceBus(), IsNil)
539
// the notifications and urldispatcher endpoints retried until connected
540
c.Check(nCond.OK(), Equals, true)
541
c.Check(uCond.OK(), Equals, true)
542
// the user actions channel has now been set up
543
c.Check(cli.actionsCh, NotNil)
544
595
c.Check(takeNextBool(cli.connCh), Equals, false)
545
596
c.Check(takeNextBool(cli.connCh), Equals, true)
546
597
// the connectivity endpoint retried until connected
547
598
c.Check(cCond.OK(), Equals, true)
548
599
// the systemimage endpoint retried until connected
549
600
c.Check(siCond.OK(), Equals, true)
550
// the emblemcounter endpoint retried until connected
551
c.Check(ecCond.OK(), Equals, true)
552
// the haptic endpoint retried until connected
553
c.Check(haCond.OK(), Equals, true)
556
603
// takeTheBus can, in fact, fail
559
606
err := cli.configure()
561
608
c.Assert(err, IsNil)
562
// the user actions channel has not been set up
563
c.Check(cli.actionsCh, IsNil)
565
610
// and stomp on things for testing
566
cli.notificationsEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(false))
567
cli.urlDispatcherEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(false))
568
611
cli.connectivityEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(false))
569
cli.emblemcounterEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(false))
570
cli.hapticEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(false))
571
612
cli.systemImageEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(false))
573
614
c.Check(cli.takeTheBus(), NotNil)
574
615
c.Assert(cli.setupPostalService(), IsNil)
575
c.Assert(cli.takePostalServiceBus(), NotNil)
576
c.Check(cli.actionsCh, IsNil)
579
618
/*****************************************************************
763
802
func (cs *clientSuite) TestHandleBroadcastNotification(c *C) {
764
803
cli := NewPushClient(cs.configPath, cs.leveldbPath)
765
804
cli.systemImageInfo = siInfoRes
766
endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
767
cli.notificationsEndp = endp
769
cli.postalServiceEndpoint = testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
770
cli.setupPostalService()
807
cli.postalService = d
771
808
c.Check(cli.handleBroadcastNotification(positiveBroadcastNotification), IsNil)
772
// check we sent the notification
773
args := testibus.GetCallArgs(endp)
774
c.Assert(args, HasLen, 1)
775
c.Check(args[0].Member, Equals, "Notify")
776
c.Check(cs.log.Captured(), Matches, `(?s).* got notification id \d+\s*`)
810
c.Check(d.bcastCount, Equals, 1)
811
c.Assert(d.postArgs, HasLen, 1)
812
expectedApp, _ := click.ParseAppId("_ubuntu-system-settings")
813
c.Check(d.postArgs[0].app, DeepEquals, expectedApp)
814
expectedData, _ := json.Marshal(positiveBroadcastNotification.Decoded[0])
815
c.Check([]byte(d.postArgs[0].payload), DeepEquals, expectedData)
779
818
func (cs *clientSuite) TestHandleBroadcastNotificationNothingToDo(c *C) {
780
819
cli := NewPushClient(cs.configPath, cs.leveldbPath)
781
820
cli.systemImageInfo = siInfoRes
782
endp := testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
783
cli.notificationsEndp = endp
823
cli.postalService = d
785
824
c.Check(cli.handleBroadcastNotification(negativeBroadcastNotification), IsNil)
786
// check we sent the notification
787
args := testibus.GetCallArgs(endp)
788
c.Assert(args, HasLen, 0)
789
c.Check(cs.log.Captured(), Matches, "")
825
// we not dun no posted
826
c.Check(d.bcastCount, Equals, 0)
792
829
func (cs *clientSuite) TestHandleBroadcastNotificationFail(c *C) {
793
830
cli := NewPushClient(cs.configPath, cs.leveldbPath)
794
831
cli.systemImageInfo = siInfoRes
796
endp := testibus.NewTestingEndpoint(nil, condition.Work(false))
797
cli.notificationsEndp = endp
798
cli.postalServiceEndpoint = testibus.NewTestingEndpoint(nil, condition.Work(true), uint32(1))
799
cli.setupPostalService()
800
c.Check(cli.handleBroadcastNotification(positiveBroadcastNotification), NotNil)
834
err := errors.New("potato")
836
cli.postalService = d
837
c.Check(cli.handleBroadcastNotification(positiveBroadcastNotification), Equals, err)
838
c.Check(d.bcastCount, Equals, 1)
803
841
/*****************************************************************
805
843
******************************************************************/
807
845
var payload = `{"message": "aGVsbG8=", "notification": {"card": {"icon": "icon-value", "summary": "summary-value", "body": "body-value", "actions": []}}}`
808
var notif = &protocol.Notification{AppId: "com.example.test_hello", Payload: []byte(payload), MsgId: "42"}
846
var notif = &protocol.Notification{AppId: appIdHello, Payload: []byte(payload), MsgId: "42"}
810
848
func (cs *clientSuite) TestHandleUcastNotification(c *C) {
811
849
cli := NewPushClient(cs.configPath, cs.leveldbPath)
812
postEndp := testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), uint32(1))
814
cli.postalServiceEndpoint = postEndp
815
c.Assert(cli.setupPostalService(), IsNil)
816
c.Assert(cli.startPostalService(), IsNil)
817
c.Check(cli.handleUnicastNotification(notif), IsNil)
818
// check we sent the notification
819
args := testibus.GetCallArgs(postEndp)
820
c.Assert(len(args), Not(Equals), 0)
821
c.Check(args[len(args)-1].Member, Equals, "::Signal")
822
c.Check(cs.log.Captured(), Matches, `(?m).*sending notification "42" for "com.example.test_hello".*`)
825
func (cs *clientSuite) TestHandleUcastFailsOnBadAppId(c *C) {
826
notif := &protocol.Notification{AppId: "bad-app-id", MsgId: "-1"}
827
cli := NewPushClient(cs.configPath, cs.leveldbPath)
829
c.Check(cli.handleUnicastNotification(notif), ErrorMatches, "invalid app id in notification")
832
/*****************************************************************
834
******************************************************************/
836
var ACTION_ID_BROADCAST = service.ACTION_ID_PREFIX + service.SystemUpdateUrl + service.ACTION_ID_SUFFIX
838
func (cs *clientSuite) TestHandleClick(c *C) {
839
cli := NewPushClient(cs.configPath, cs.leveldbPath)
841
endp := testibus.NewTestingEndpoint(nil, condition.Work(true))
842
cli.urlDispatcherEndp = endp
843
// check we don't fail on something random
844
c.Check(cli.handleClick("something random"), IsNil)
845
// ... but we don't send anything either
846
args := testibus.GetCallArgs(endp)
847
c.Assert(args, HasLen, 0)
848
// check we worked with the right action id
849
c.Check(cli.handleClick(ACTION_ID_BROADCAST), IsNil)
850
// check we sent the notification
851
args = testibus.GetCallArgs(endp)
852
c.Assert(args, HasLen, 1)
853
c.Check(args[0].Member, Equals, "DispatchURL")
854
c.Check(args[0].Args, DeepEquals, []interface{}{service.SystemUpdateUrl})
855
// check we worked with the right action id
856
c.Check(cli.handleClick(service.ACTION_ID_PREFIX+"foo"), IsNil)
857
// check we sent the notification
858
args = testibus.GetCallArgs(endp)
859
c.Assert(args, HasLen, 2)
860
c.Check(args[1].Member, Equals, "DispatchURL")
861
c.Check(args[1].Args, DeepEquals, []interface{}{"foo"})
852
cli.postalService = d
854
c.Check(cli.handleUnicastNotification(session.AddressedNotification{appHello, notif}), IsNil)
855
// check we sent the notification
856
c.Check(d.postCount, Equals, 1)
857
c.Assert(d.postArgs, HasLen, 1)
858
c.Check(d.postArgs[0].app, Equals, appHello)
859
c.Check(d.postArgs[0].nid, Equals, notif.MsgId)
860
c.Check(d.postArgs[0].payload, DeepEquals, notif.Payload)
863
func (cs *clientSuite) TestHandleUcastNotificationError(c *C) {
864
cli := NewPushClient(cs.configPath, cs.leveldbPath)
867
cli.postalService = d
868
fail := errors.New("fail")
871
c.Check(cli.handleUnicastNotification(session.AddressedNotification{appHello, notif}), Equals, fail)
872
// check we sent the notification
873
c.Check(d.postCount, Equals, 1)
864
876
/*****************************************************************
882
894
func (cs *clientSuite) TestHandleUnregister(c *C) {
883
895
cli := NewPushClient(cs.configPath, cs.leveldbPath)
885
cli.hasPackage = func(appId string) bool {
886
c.Check(appId, Equals, "app1")
897
cli.installedChecker = testInstalledChecker(func(app *click.AppId, setVersion bool) bool {
898
c.Check(setVersion, Equals, false)
899
c.Check(app.Original(), Equals, appId1)
889
902
ps := &testPushService{}
890
903
cli.pushService = ps
891
cli.handleUnregister("app1")
892
c.Assert(ps.unregistered, Equals, "app1")
893
c.Check(cs.log.Captured(), Equals, "")
904
cli.handleUnregister(app1)
905
c.Assert(ps.unregistered, Equals, appId1)
906
c.Check(cs.log.Captured(), Equals, "DEBUG unregistered token for com.example.app1_app1\n")
896
909
func (cs *clientSuite) TestHandleUnregisterNop(c *C) {
897
910
cli := NewPushClient(cs.configPath, cs.leveldbPath)
899
cli.hasPackage = func(appId string) bool {
900
c.Check(appId, Equals, "app1")
912
cli.installedChecker = testInstalledChecker(func(app *click.AppId, setVersion bool) bool {
913
c.Check(setVersion, Equals, false)
914
c.Check(app.Original(), Equals, appId1)
903
917
ps := &testPushService{}
904
918
cli.pushService = ps
905
cli.handleUnregister("app1")
919
cli.handleUnregister(app1)
906
920
c.Assert(ps.unregistered, Equals, "")
909
923
func (cs *clientSuite) TestHandleUnregisterError(c *C) {
910
924
cli := NewPushClient(cs.configPath, cs.leveldbPath)
912
cli.hasPackage = func(appId string) bool {
926
cli.installedChecker = testInstalledChecker(func(app *click.AppId, setVersion bool) bool {
915
929
fail := errors.New("BAD")
916
930
ps := &testPushService{err: fail}
917
931
cli.pushService = ps
918
cli.handleUnregister("app1")
919
c.Check(cs.log.Captured(), Matches, "ERROR unregistering app1: BAD\n")
932
cli.handleUnregister(app1)
933
c.Check(cs.log.Captured(), Matches, "ERROR unregistering com.example.app1_app1: BAD\n")
922
936
/*****************************************************************
939
952
c.Assert(cli.initSession(), IsNil)
941
954
ch := make(chan bool, 1)
942
go cli.doLoop(func(bool) { ch <- true }, nopClick, nopBcast, nopUcast, nopError, nopUnregister)
943
c.Check(takeNextBool(ch), Equals, true)
946
func (cs *clientSuite) TestDoLoopClick(c *C) {
947
cli := NewPushClient(cs.configPath, cs.leveldbPath)
949
cli.systemImageInfo = siInfoRes
950
c.Assert(cli.initSession(), IsNil)
951
aCh := make(chan notifications.RawActionReply, 1)
952
aCh <- notifications.RawActionReply{}
955
ch := make(chan bool, 1)
956
go cli.doLoop(nopConn, func(_ string) error { ch <- true; return nil }, nopBcast, nopUcast, nopError, nopUnregister)
955
go cli.doLoop(func(bool) { ch <- true }, nopBcast, nopUcast, nopError, nopUnregister)
957
956
c.Check(takeNextBool(ch), Equals, true)
976
975
cli.systemImageInfo = siInfoRes
977
976
c.Assert(cli.initSession(), IsNil)
978
cli.session.NotificationsCh = make(chan *protocol.Notification, 1)
979
cli.session.NotificationsCh <- &protocol.Notification{}
977
cli.session.NotificationsCh = make(chan session.AddressedNotification, 1)
978
cli.session.NotificationsCh <- session.AddressedNotification{}
981
980
ch := make(chan bool, 1)
982
go cli.doLoop(nopConn, nopClick, nopBcast, func(*protocol.Notification) error { ch <- true; return nil }, nopError, nopUnregister)
981
go cli.doLoop(nopConn, nopBcast, func(session.AddressedNotification) error { ch <- true; return nil }, nopError, nopUnregister)
983
982
c.Check(takeNextBool(ch), Equals, true)
1001
1000
cli.log = cs.log
1002
1001
cli.systemImageInfo = siInfoRes
1003
1002
c.Assert(cli.initSession(), IsNil)
1004
cli.unregisterCh = make(chan string, 1)
1005
cli.unregisterCh <- "app1"
1003
cli.unregisterCh = make(chan *click.AppId, 1)
1004
cli.unregisterCh <- app1
1007
1006
ch := make(chan bool, 1)
1008
go cli.doLoop(nopConn, nopClick, nopBcast, nopUcast, nopError, func(appId string) { c.Check(appId, Equals, "app1"); ch <- true })
1007
go cli.doLoop(nopConn, nopBcast, nopUcast, nopError, func(app *click.AppId) { c.Check(app.Original(), Equals, appId1); ch <- true })
1009
1008
c.Check(takeNextBool(ch), Equals, true)
1044
1043
cli := NewPushClient(cs.configPath, cs.leveldbPath)
1045
1044
cli.connCh = make(chan bool)
1046
1045
cli.sessionConnectedCh = make(chan uint32)
1047
aCh := make(chan notifications.RawActionReply, 1)
1049
1046
cli.log = cs.log
1050
cli.notificationsEndp = testibus.NewMultiValuedTestingEndpoint(condition.Work(true),
1051
condition.Work(true), []interface{}{uint32(1), "hello"})
1052
cli.urlDispatcherEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(false))
1053
1047
cli.connectivityEndp = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true),
1054
1048
uint32(networkmanager.ConnectedGlobal))
1055
1049
cli.systemImageInfo = siInfoRes
1056
cli.postalServiceEndpoint = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), uint32(1))
1057
cli.setupPostalService()
1050
d := new(dumbPostal)
1051
cli.postalService = d
1052
c.Assert(cli.startPostalService(), IsNil)
1058
1054
c.Assert(cli.initSession(), IsNil)
1060
1056
cli.session.BroadcastCh = make(chan *session.BroadcastNotification)