Chromium Code Reviews| Index: tests/standalone/io/socket_source_address_test.dart |
| diff --git a/tests/standalone/io/socket_source_address_test.dart b/tests/standalone/io/socket_source_address_test.dart |
| index b3c4289b992ec7c01c3dcd28a71f7e2acf1b0fac..d0ead81d1556caf30bb31793a97f36e56b3c8a19 100644 |
| --- a/tests/standalone/io/socket_source_address_test.dart |
| +++ b/tests/standalone/io/socket_source_address_test.dart |
| @@ -70,11 +70,21 @@ Future testConnect(InternetAddress bindAddress, |
| bool v6Only, |
| Function connectFunction, |
| Function closeDestroyFunction) async { |
| + var successCount = 0; |
| + if (!v6Only) successCount += ipV4SourceAddresses.length; |
| + if (bindAddress.type == InternetAddressType.IP_V6) { |
| + successCount += ipV6SourceAddresses.length; |
| + } |
| + var count = 0; |
| + var allConnected = new Completer(); |
| + if (successCount == 0) allConnected.complete(); |
| + |
| asyncStart(); |
| var server = await ServerSocket.bind(bindAddress, 0, v6Only: v6Only); |
| server.listen((s) { |
| s.destroy(); |
| - asyncEnd(); |
| + count++; |
| + if (count == successCount) allConnected.complete(); |
| }, onDone: () => asyncEnd()); |
| asyncStart(); |
| @@ -82,7 +92,6 @@ Future testConnect(InternetAddress bindAddress, |
| // Connect with IPv4 source addesses. |
| for (var sourceAddress in ipV4SourceAddresses) { |
| if (!v6Only) { |
| - asyncStart(); // Matching asyncEnd in server.listen above. |
| var s = await connectFunction(InternetAddress.LOOPBACK_IP_V4, |
| server.port, |
| sourceAddress: sourceAddress); |
| @@ -100,7 +109,6 @@ Future testConnect(InternetAddress bindAddress, |
| // Connect with IPv6 source addesses. |
| for (var sourceAddress in ipV6SourceAddresses) { |
| if (bindAddress.type == InternetAddressType.IP_V6) { |
| - asyncStart(); // Matching asyncEnd in server.listen above. |
| var s = await connectFunction(InternetAddress.LOOPBACK_IP_V6, |
| server.port, |
| sourceAddress: sourceAddress); |
| @@ -114,6 +122,7 @@ Future testConnect(InternetAddress bindAddress, |
| } |
| } |
| + await allConnected.future; |
| server.close(); |
|
kustermann
2015/02/10 14:20:17
-> await server.close() ?
Søren Gjesse
2015/02/10 14:29:10
Done.
|
| asyncEnd(); |
| } |