Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 import 'dart:async'; | |
| 6 import 'mojo:application'; | |
| 7 import 'mojo:bindings'; | |
| 8 import 'mojo:core'; | |
| 9 | |
| 10 import 'package:apptest/apptest.dart'; | |
| 11 import 'package:services/dart/test/pingpong_service.mojom.dart'; | |
| 12 | |
| 13 class _TestingPingPongClient extends PingPongClient { | |
| 14 final PingPongClientStub stub; | |
| 15 Completer _completer; | |
| 16 | |
| 17 _TestingPingPongClient.unbound() : stub = new PingPongClientStub.unbound() { | |
| 18 stub.delegate = this; | |
| 19 } | |
| 20 | |
| 21 waitForPong() async { | |
| 22 _completer = new Completer(); | |
| 23 return _completer.future; | |
| 24 } | |
| 25 | |
| 26 void pong(int pongValue) { | |
| 27 _completer.complete(pongValue); | |
| 28 _completer = null; | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 pingpongApptests(Application application) { | |
| 33 group('Ping-Pong Service Apptests', () { | |
| 34 // Verify that "pingpong.dart" implements the PingPongService interface | |
| 35 // and sends responses to our client. | |
| 36 test('Ping Service To Pong Client', () async { | |
| 37 var pingPongServiceProxy = new PingPongServiceProxy.unbound(); | |
| 38 application.connectToService("mojo:dart_pingpong", pingPongServiceProxy); | |
| 39 | |
| 40 var pingPongClient = new _TestingPingPongClient.unbound(); | |
| 41 pingPongServiceProxy.ptr.setClient(pingPongClient.stub); | |
| 42 pingPongClient.stub.listen(); | |
| 43 | |
| 44 pingPongServiceProxy.ptr.ping(1); | |
| 45 var pongValue = await pingPongClient.waitForPong(); | |
| 46 expect(pongValue, equals(2)); | |
| 47 | |
| 48 pingPongServiceProxy.ptr.ping(100); | |
| 49 pongValue = await pingPongClient.waitForPong(); | |
| 50 expect(pongValue, equals(101)); | |
| 51 | |
| 52 pingPongClient.stub.close(); | |
| 53 pingPongServiceProxy.close(); | |
| 54 }); | |
| 55 | |
| 56 // Verify that "pingpong.dart" can connect to "pingpong_target.dart", act as | |
| 57 // its client, and return a Future that only resolves after the | |
| 58 // target.ping() => client.pong() methods have executed 9 times. | |
| 59 test('Ping Target URL', () async { | |
| 60 var pingPongServiceProxy = new PingPongServiceProxy.unbound(); | |
| 61 application.connectToService("mojo:dart_pingpong", pingPongServiceProxy); | |
| 62 | |
| 63 var r = await pingPongServiceProxy.ptr.pingTargetUrl( | |
| 64 "mojo:dart_pingpong_target", 9); | |
| 65 expect(r.ok, equals(true)); | |
| 66 | |
| 67 pingPongServiceProxy.close(); | |
| 68 }); | |
|
Elliot Glaysher
2015/03/02 22:37:17
This is incomplete and I'm currently working on th
| |
| 69 }); | |
| 70 } | |
| OLD | NEW |