| 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 echo_apptests; | 5 library echo_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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 "quit", milliseconds)).then((result) { | 79 "quit", milliseconds)).then((result) { |
| 80 fail('This future should not complete.'); | 80 fail('This future should not complete.'); |
| 81 }, onError: (e) { | 81 }, onError: (e) { |
| 82 expect(e is ProxyError, isTrue); | 82 expect(e is ProxyError, isTrue); |
| 83 }); | 83 }); |
| 84 | 84 |
| 85 return new Future.delayed( | 85 return new Future.delayed( |
| 86 new Duration(milliseconds: 10), () => echoProxy.close()); | 86 new Duration(milliseconds: 10), () => echoProxy.close()); |
| 87 }); | 87 }); |
| 88 | 88 |
| 89 test('Swap', () async { |
| 90 var echoProxy = |
| 91 new EchoServiceProxy.connectToService(application, "mojo:dart_echo"); |
| 92 |
| 93 for (int i = 0; i < 10; i++) { |
| 94 var v = |
| 95 await echoProxy.responseOrError(echoProxy.ptr.echoString("foo")); |
| 96 expect(v.value, equals("foo")); |
| 97 } |
| 98 |
| 99 echoProxy.impl.errorFuture.then((e) { |
| 100 fail("echoProxy: $e"); |
| 101 }); |
| 102 |
| 103 // Trigger an implementation swap in the echo server. |
| 104 echoProxy.ptr.swap(); |
| 105 |
| 106 expect(echoProxy.impl.isBound, isTrue); |
| 107 |
| 108 for (int i = 0; i < 10; i++) { |
| 109 var v = |
| 110 await echoProxy.responseOrError(echoProxy.ptr.echoString("foo")); |
| 111 expect(v.value, equals("foo")); |
| 112 } |
| 113 |
| 114 var q = await echoProxy.responseOrError(echoProxy.ptr.echoString("quit")); |
| 115 expect(q.value, equals("quit")); |
| 116 |
| 117 await echoProxy.close(); |
| 118 }); |
| 119 |
| 89 test('Multiple Error Checks Success', () { | 120 test('Multiple Error Checks Success', () { |
| 90 var echoProxy = | 121 var echoProxy = |
| 91 new EchoServiceProxy.connectToService(application, "mojo:dart_echo"); | 122 new EchoServiceProxy.connectToService(application, "mojo:dart_echo"); |
| 92 | 123 |
| 93 List<Future> futures = []; | 124 List<Future> futures = []; |
| 94 for (int i = 0; i < 100; i++) { | 125 for (int i = 0; i < 100; i++) { |
| 95 var f = echoProxy.responseOrError(echoProxy.ptr.echoString("foo")) | 126 var f = echoProxy.responseOrError(echoProxy.ptr.echoString("foo")) |
| 96 .then((r) { | 127 .then((r) { |
| 97 expect(r.value, equals("foo")); | 128 expect(r.value, equals("foo")); |
| 98 }, onError: (e) { | 129 }, onError: (e) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 await echoProxy.close(); | 309 await echoProxy.close(); |
| 279 | 310 |
| 280 r = await differentEchoProxy.responseOrError( | 311 r = await differentEchoProxy.responseOrError( |
| 281 differentEchoProxy.ptr.echoString("foo")); | 312 differentEchoProxy.ptr.echoString("foo")); |
| 282 expect(r.value, equals("foo")); | 313 expect(r.value, equals("foo")); |
| 283 | 314 |
| 284 await differentEchoProxy.close(); | 315 await differentEchoProxy.close(); |
| 285 }); | 316 }); |
| 286 }); | 317 }); |
| 287 } | 318 } |
| OLD | NEW |