OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 library pingpong_apptests; | 5 library pingpong_apptests; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:mojo_apptest/apptest.dart'; | 9 import 'package:mojo_apptest/apptest.dart'; |
10 import 'package:mojo/application.dart'; | 10 import 'package:mojo/application.dart'; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 }); | 56 }); |
57 | 57 |
58 // Verify that "pingpong.dart" can connect to "pingpong_target.dart", act as | 58 // Verify that "pingpong.dart" can connect to "pingpong_target.dart", act as |
59 // its client, and return a Future that only resolves after the | 59 // its client, and return a Future that only resolves after the |
60 // target.ping() => client.pong() methods have executed 9 times. | 60 // target.ping() => client.pong() methods have executed 9 times. |
61 test('Ping Target URL', () async { | 61 test('Ping Target URL', () async { |
62 var pingPongService = new PingPongServiceInterfaceRequest(); | 62 var pingPongService = new PingPongServiceInterfaceRequest(); |
63 pingPongService.ctrl.errorFuture.then((e) => fail('$e')); | 63 pingPongService.ctrl.errorFuture.then((e) => fail('$e')); |
64 application.connectToService("mojo:dart_pingpong", pingPongService); | 64 application.connectToService("mojo:dart_pingpong", pingPongService); |
65 | 65 |
66 var r = await pingPongService.pingTargetUrl( | 66 var c = new Completer(); |
67 "mojo:dart_pingpong_target", 9); | 67 pingPongService.pingTargetUrl("mojo:dart_pingpong_target", 9, (bool ok) { |
68 expect(r.ok, equals(true)); | 68 c.complete(ok); |
| 69 }); |
| 70 expect(await pingPongService.responseOrError(c.future), isTrue); |
69 | 71 |
70 await pingPongService.close(); | 72 await pingPongService.close(); |
71 }); | 73 }); |
72 | 74 |
73 // Same as the previous test except that instead of providing the | 75 // Same as the previous test except that instead of providing the |
74 // pingpong_target.dart URL, we provide a connection to its PingPongService. | 76 // pingpong_target.dart URL, we provide a connection to its PingPongService. |
75 test('Ping Target Service', () async { | 77 test('Ping Target Service', () async { |
76 var pingPongService = new PingPongServiceInterfaceRequest(); | 78 var pingPongService = new PingPongServiceInterfaceRequest(); |
77 pingPongService.ctrl.errorFuture.then((e) => fail('$e')); | 79 pingPongService.ctrl.errorFuture.then((e) => fail('$e')); |
78 application.connectToService("mojo:dart_pingpong", pingPongService); | 80 application.connectToService("mojo:dart_pingpong", pingPongService); |
79 | 81 |
80 var targetService = new PingPongServiceInterfaceRequest(); | 82 var targetService = new PingPongServiceInterfaceRequest(); |
81 targetService.ctrl.errorFuture.then((e) => fail('$e')); | 83 targetService.ctrl.errorFuture.then((e) => fail('$e')); |
82 application.connectToService("mojo:dart_pingpong_target", targetService); | 84 application.connectToService("mojo:dart_pingpong_target", targetService); |
83 | 85 |
84 var r = await pingPongService.pingTargetService(targetService, 9); | 86 var c = new Completer(); |
85 expect(r.ok, equals(true)); | 87 pingPongService.pingTargetService(targetService, 9, (bool ok) { |
| 88 c.complete(ok); |
| 89 }); |
| 90 expect(await pingPongService.responseOrError(c.future), isTrue); |
| 91 |
86 // This side no longer has access to the pipe. | 92 // This side no longer has access to the pipe. |
87 expect(targetService.ctrl.isOpen, equals(false)); | 93 expect(targetService.ctrl.isOpen, equals(false)); |
88 expect(targetService.ctrl.isBound, equals(false)); | 94 expect(targetService.ctrl.isBound, equals(false)); |
89 | 95 |
90 await pingPongService.close(); | 96 await pingPongService.close(); |
91 }); | 97 }); |
92 | 98 |
93 // Verify that Dart can implement an interface "request" parameter. | 99 // Verify that Dart can implement an interface "request" parameter. |
94 test('Get Target Service', () async { | 100 test('Get Target Service', () async { |
95 var pingPongService = new PingPongServiceInterfaceRequest(); | 101 var pingPongService = new PingPongServiceInterfaceRequest(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 targetService.ping(100); | 144 targetService.ping(100); |
139 pongValue = await pingPongClient.waitForPong(); | 145 pongValue = await pingPongClient.waitForPong(); |
140 expect(pongValue, equals(101)); | 146 expect(pongValue, equals(101)); |
141 | 147 |
142 await pingPongClient.client.close(); | 148 await pingPongClient.client.close(); |
143 await targetService.close(); | 149 await targetService.close(); |
144 await pingPongService.close(); | 150 await pingPongService.close(); |
145 }); | 151 }); |
146 }); | 152 }); |
147 } | 153 } |
OLD | NEW |