Chromium Code Reviews| 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 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 const ANY = InternetAddressType.ANY; | 10 const ANY = InternetAddressType.ANY; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 socket.destroy(); | 44 socket.destroy(); |
| 45 }); | 45 }); |
| 46 }); | 46 }); |
| 47 }); | 47 }); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void testIPv6toIPv4() { | 50 void testIPv6toIPv4() { |
| 51 asyncStart(); | 51 asyncStart(); |
| 52 InternetAddress.lookup("::1", type: ANY).then((clientAddr) { | 52 InternetAddress.lookup("::1", type: ANY).then((clientAddr) { |
| 53 ServerSocket.bind("127.0.0.1", 0).then((server) { | 53 ServerSocket.bind("127.0.0.1", 0).then((server) { |
| 54 Expect.equals('127.0.0.1', server.address.host); | 54 Expect.equals('127.0.0.1', server.address.host); |
|
kustermann
2016/12/13 19:36:45
Maybe indent this here for readability
Florian Schneider
2016/12/13 20:23:16
Done.
| |
| 55 Expect.equals('127.0.0.1', server.address.address); | 55 Expect.equals('127.0.0.1', server.address.address); |
| 56 server.listen((socket) { | 56 server.listen((socket) { |
| 57 throw "Unexpected socket"; | 57 throw "Unexpected socket"; |
| 58 }); | 58 }); |
| 59 Socket.connect(clientAddr.first, server.port).catchError((e) { | 59 Socket.connect(clientAddr.first, server.port).then((socket) { |
| 60 socket.destroy(); | |
| 61 server.close(); | |
| 62 asyncEnd(); | |
|
kustermann
2016/12/13 19:36:45
If you add this then the test is disabled (same be
Florian Schneider
2016/12/13 20:23:16
Done.
| |
| 63 }).catchError((e) { | |
| 60 server.close(); | 64 server.close(); |
| 61 asyncEnd(); | 65 asyncEnd(); |
| 62 }); | 66 }); |
| 63 }); | 67 }); |
| 64 }); | 68 }); |
| 65 } | 69 } |
| 66 | 70 |
| 67 void testIPv4toIPv4() { | 71 void testIPv4toIPv4() { |
| 68 asyncStart(); | 72 asyncStart(); |
| 69 ServerSocket.bind("127.0.0.1", 0).then((server) { | 73 ServerSocket.bind("127.0.0.1", 0).then((server) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 112 |
| 109 void testIPv4toIPv6_IPV6Only() { | 113 void testIPv4toIPv6_IPV6Only() { |
| 110 asyncStart(); | 114 asyncStart(); |
| 111 InternetAddress.lookup("::0", type: ANY) | 115 InternetAddress.lookup("::0", type: ANY) |
| 112 .then((serverAddr) { | 116 .then((serverAddr) { |
| 113 ServerSocket.bind(serverAddr.first, 0, v6Only: true) | 117 ServerSocket.bind(serverAddr.first, 0, v6Only: true) |
| 114 .then((server) { | 118 .then((server) { |
| 115 server.listen((socket) { | 119 server.listen((socket) { |
| 116 throw "Unexpected socket"; | 120 throw "Unexpected socket"; |
| 117 }); | 121 }); |
| 118 Socket.connect("127.0.0.1", server.port).catchError((error) { | 122 Socket.connect("127.0.0.1", server.port) |
| 119 server.close(); | 123 .then((socket) { |
| 120 asyncEnd(); | 124 socket.destroy(); |
| 121 }); | 125 server.close(); |
| 126 asyncEnd(); | |
| 127 }) | |
| 128 .catchError((error) { | |
| 129 server.close(); | |
| 130 asyncEnd(); | |
| 131 }); | |
| 122 }); | 132 }); |
| 123 }); | 133 }); |
| 124 } | 134 } |
| 125 | 135 |
| 126 void main() { | 136 void main() { |
| 127 testIPv6toIPv6(); /// none: ok | 137 testIPv6toIPv6(); /// none: ok |
| 128 testIPv4toIPv6(); /// 01: ok | 138 testIPv4toIPv6(); /// 01: ok |
| 129 testIPv6toIPv4(); /// 02: ok | 139 testIPv6toIPv4(); /// 02: ok |
| 130 testIPv4toIPv4(); /// 03: ok | 140 testIPv4toIPv4(); /// 03: ok |
| 131 testIPv6Lookup(); /// 04: ok | 141 testIPv6Lookup(); /// 04: ok |
| 132 testIPv4Lookup(); /// 05: ok | 142 testIPv4Lookup(); /// 05: ok |
| 133 | 143 |
| 134 testIPv4toIPv6_IPV6Only(); /// 06: ok | 144 testIPv4toIPv6_IPV6Only(); /// 06: ok |
| 135 } | 145 } |
| OLD | NEW |