Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: mojo/dart/apptests/dart_apptests/lib/src/pingpong_apptests.dart

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Move code from mojo_patch to proxy.dart Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
71
72 // var r = await pingPongService.pingTargetUrl(
73 // "mojo:dart_pingpong_target", 9);
74 // expect(r.ok, equals(true));
69 75
70 await pingPongService.close(); 76 await pingPongService.close();
71 }); 77 });
72 78
73 // Same as the previous test except that instead of providing the 79 // Same as the previous test except that instead of providing the
74 // pingpong_target.dart URL, we provide a connection to its PingPongService. 80 // pingpong_target.dart URL, we provide a connection to its PingPongService.
75 test('Ping Target Service', () async { 81 test('Ping Target Service', () async {
76 var pingPongService = new PingPongServiceInterfaceRequest(); 82 var pingPongService = new PingPongServiceInterfaceRequest();
77 pingPongService.ctrl.errorFuture.then((e) => fail('$e')); 83 pingPongService.ctrl.errorFuture.then((e) => fail('$e'));
78 application.connectToService("mojo:dart_pingpong", pingPongService); 84 application.connectToService("mojo:dart_pingpong", pingPongService);
79 85
80 var targetService = new PingPongServiceInterfaceRequest(); 86 var targetService = new PingPongServiceInterfaceRequest();
81 targetService.ctrl.errorFuture.then((e) => fail('$e')); 87 targetService.ctrl.errorFuture.then((e) => fail('$e'));
82 application.connectToService("mojo:dart_pingpong_target", targetService); 88 application.connectToService("mojo:dart_pingpong_target", targetService);
83 89
84 var r = await pingPongService.pingTargetService(targetService, 9); 90 var c = new Completer();
85 expect(r.ok, equals(true)); 91 pingPongService.pingTargetService(targetService, 9, (bool ok) {
92 c.complete(ok);
93 });
94 expect(await pingPongService.responseOrError(c.future), isTrue);
95
96 //var r = await pingPongService.pingTargetService(targetService, 9);
97 //expect(r.ok, equals(true));
98
86 // This side no longer has access to the pipe. 99 // This side no longer has access to the pipe.
87 expect(targetService.ctrl.isOpen, equals(false)); 100 expect(targetService.ctrl.isOpen, equals(false));
88 expect(targetService.ctrl.isBound, equals(false)); 101 expect(targetService.ctrl.isBound, equals(false));
89 102
90 await pingPongService.close(); 103 await pingPongService.close();
91 }); 104 });
92 105
93 // Verify that Dart can implement an interface "request" parameter. 106 // Verify that Dart can implement an interface "request" parameter.
94 test('Get Target Service', () async { 107 test('Get Target Service', () async {
95 var pingPongService = new PingPongServiceInterfaceRequest(); 108 var pingPongService = new PingPongServiceInterfaceRequest();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 targetService.ping(100); 151 targetService.ping(100);
139 pongValue = await pingPongClient.waitForPong(); 152 pongValue = await pingPongClient.waitForPong();
140 expect(pongValue, equals(101)); 153 expect(pongValue, equals(101));
141 154
142 await pingPongClient.client.close(); 155 await pingPongClient.client.close();
143 await targetService.close(); 156 await targetService.close();
144 await pingPongService.close(); 157 await pingPongService.close();
145 }); 158 });
146 }); 159 });
147 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698