| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "dart:async"; | 6 import "dart:async"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 import "dart:isolate"; | 8 import "dart:isolate"; |
| 9 | 9 |
| 10 void sendData(List<int> data, int port) { | 10 void sendData(List<int> data, int port) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 bool calledOnError = false; | 32 bool calledOnError = false; |
| 33 ReceivePort port = new ReceivePort(); | 33 ReceivePort port = new ReceivePort(); |
| 34 server.listen( | 34 server.listen( |
| 35 (request) { | 35 (request) { |
| 36 Expect.isTrue(expectRequest); | 36 Expect.isTrue(expectRequest); |
| 37 Expect.isFalse(calledOnError); | 37 Expect.isFalse(calledOnError); |
| 38 Expect.isFalse(calledOnRequest, "onRequest called multiple times"); | 38 Expect.isFalse(calledOnRequest, "onRequest called multiple times"); |
| 39 calledOnRequest = true; | 39 calledOnRequest = true; |
| 40 request.listen( | 40 request.listen( |
| 41 (_) {}, | 41 (_) {}, |
| 42 onError: (e) { | 42 onError: (error) { |
| 43 Expect.isFalse(calledOnError); | 43 Expect.isFalse(calledOnError); |
| 44 Expect.equals(exception, e.error.message); | 44 Expect.equals(exception, error.message); |
| 45 calledOnError = true; | 45 calledOnError = true; |
| 46 port.close(); | 46 port.close(); |
| 47 c.complete(null); | 47 c.complete(null); |
| 48 }); | 48 }); |
| 49 }, | 49 }, |
| 50 onError: (e) { | 50 onError: (error) { |
| 51 Expect.isFalse(calledOnError); | 51 Expect.isFalse(calledOnError); |
| 52 Expect.equals(exception, e.error.message); | 52 Expect.equals(exception, error.message); |
| 53 Expect.equals(expectRequest, calledOnRequest); | 53 Expect.equals(expectRequest, calledOnRequest); |
| 54 calledOnError = true; | 54 calledOnError = true; |
| 55 port.close(); | 55 port.close(); |
| 56 c.complete(null); | 56 c.complete(null); |
| 57 }); | 57 }); |
| 58 | 58 |
| 59 List<int> d; | 59 List<int> d; |
| 60 if (data is List<int>) d = data; | 60 if (data is List<int>) d = data; |
| 61 if (data is String) d = data.codeUnits; | 61 if (data is String) d = data.codeUnits; |
| 62 if (d == null) Expect.fail("Invalid data"); | 62 if (d == null) Expect.fail("Invalid data"); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 socket.done.catchError((_) {}); | 157 socket.done.catchError((_) {}); |
| 158 }); | 158 }); |
| 159 }); | 159 }); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void main() { | 162 void main() { |
| 163 testEarlyClose1(); | 163 testEarlyClose1(); |
| 164 testEarlyClose2(); | 164 testEarlyClose2(); |
| 165 testEarlyClose3(); | 165 testEarlyClose3(); |
| 166 } | 166 } |
| OLD | NEW |