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

Side by Side Diff: services/dart/dart_apptests/pingpong_apptests.dart

Issue 982673002: Dart: Removes need to call listen(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Don't pile up callbacks Created 5 years, 9 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 import 'dart:async'; 5 import 'dart:async';
6 import 'mojo:application'; 6 import 'mojo:application';
7 import 'mojo:bindings'; 7 import 'mojo:bindings';
8 import 'mojo:core'; 8 import 'mojo:core';
9 9
10 import 'package:apptest/apptest.dart'; 10 import 'package:apptest/apptest.dart';
(...skipping 21 matching lines...) Expand all
32 pingpongApptests(Application application) { 32 pingpongApptests(Application application) {
33 group('Ping-Pong Service Apptests', () { 33 group('Ping-Pong Service Apptests', () {
34 // Verify that "pingpong.dart" implements the PingPongService interface 34 // Verify that "pingpong.dart" implements the PingPongService interface
35 // and sends responses to our client. 35 // and sends responses to our client.
36 test('Ping Service To Pong Client', () async { 36 test('Ping Service To Pong Client', () async {
37 var pingPongServiceProxy = new PingPongServiceProxy.unbound(); 37 var pingPongServiceProxy = new PingPongServiceProxy.unbound();
38 application.connectToService("mojo:dart_pingpong", pingPongServiceProxy); 38 application.connectToService("mojo:dart_pingpong", pingPongServiceProxy);
39 39
40 var pingPongClient = new _TestingPingPongClient.unbound(); 40 var pingPongClient = new _TestingPingPongClient.unbound();
41 pingPongServiceProxy.ptr.setClient(pingPongClient.stub); 41 pingPongServiceProxy.ptr.setClient(pingPongClient.stub);
42 pingPongClient.stub.listen();
43 42
44 pingPongServiceProxy.ptr.ping(1); 43 pingPongServiceProxy.ptr.ping(1);
45 var pongValue = await pingPongClient.waitForPong(); 44 var pongValue = await pingPongClient.waitForPong();
46 expect(pongValue, equals(2)); 45 expect(pongValue, equals(2));
47 46
48 pingPongServiceProxy.ptr.ping(100); 47 pingPongServiceProxy.ptr.ping(100);
49 pongValue = await pingPongClient.waitForPong(); 48 pongValue = await pingPongClient.waitForPong();
50 expect(pongValue, equals(101)); 49 expect(pongValue, equals(101));
51 50
52 pingPongClient.stub.close(); 51 pingPongClient.stub.close();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Verify that Dart can implement an interface "request" parameter. 92 // Verify that Dart can implement an interface "request" parameter.
94 test('Get Target Service', () async { 93 test('Get Target Service', () async {
95 var pingPongServiceProxy = new PingPongServiceProxy.unbound(); 94 var pingPongServiceProxy = new PingPongServiceProxy.unbound();
96 application.connectToService("mojo:dart_pingpong", pingPongServiceProxy); 95 application.connectToService("mojo:dart_pingpong", pingPongServiceProxy);
97 96
98 var targetServiceProxy = new PingPongServiceProxy.unbound(); 97 var targetServiceProxy = new PingPongServiceProxy.unbound();
99 pingPongServiceProxy.ptr.getPingPongService(targetServiceProxy); 98 pingPongServiceProxy.ptr.getPingPongService(targetServiceProxy);
100 99
101 var pingPongClient = new _TestingPingPongClient.unbound(); 100 var pingPongClient = new _TestingPingPongClient.unbound();
102 targetServiceProxy.ptr.setClient(pingPongClient.stub); 101 targetServiceProxy.ptr.setClient(pingPongClient.stub);
103 pingPongClient.stub.listen();
104 102
105 targetServiceProxy.ptr.ping(1); 103 targetServiceProxy.ptr.ping(1);
106 var pongValue = await pingPongClient.waitForPong(); 104 var pongValue = await pingPongClient.waitForPong();
107 expect(pongValue, equals(2)); 105 expect(pongValue, equals(2));
108 106
109 targetServiceProxy.ptr.ping(100); 107 targetServiceProxy.ptr.ping(100);
110 pongValue = await pingPongClient.waitForPong(); 108 pongValue = await pingPongClient.waitForPong();
111 expect(pongValue, equals(101)); 109 expect(pongValue, equals(101));
112 110
113 pingPongClient.stub.close(); 111 pingPongClient.stub.close();
114 targetServiceProxy.close(); 112 targetServiceProxy.close();
115 pingPongServiceProxy.close(); 113 pingPongServiceProxy.close();
116 }); 114 });
117 }); 115 });
118 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698