Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2006)

Unified Diff: tests/standalone/io/socket_source_address_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 9670ac546011697e3b1210e250181a45ac9db61e..f6f581c9863a1538adf89850c7488baf3a2a3b2f 100644
--- a/tests/standalone/io/socket_source_address_test.dart
+++ b/tests/standalone/io/socket_source_address_test.dart
@@ -29,8 +29,8 @@ Future testArguments(connectFunction) async {
var sourceAddress;
asyncStart();
- var server = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4,
- freePort);
+ var server =
+ await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, freePort);
server.listen((_) {
throw 'Unexpected connection from address $sourceAddress';
}, onDone: () => asyncEnd());
@@ -38,52 +38,55 @@ Future testArguments(connectFunction) async {
asyncStart();
// Illegal type for sourceAddress.
for (sourceAddress in ['www.google.com', 'abc']) {
- await throws(() => connectFunction('127.0.0.1',
- server.port,
- sourceAddress: sourceAddress),
- (e) => e is ArgumentError);
+ await throws(
+ () => connectFunction('127.0.0.1', server.port,
+ sourceAddress: sourceAddress),
+ (e) => e is ArgumentError);
}
// Unsupported local address.
for (sourceAddress in ['8.8.8.8', new InternetAddress('8.8.8.8')]) {
- await throws(() => connectFunction('127.0.0.1',
- server.port,
- sourceAddress: sourceAddress),
- (e) => e is SocketException &&
- e.address == new InternetAddress('8.8.8.8'));
+ await throws(
+ () => connectFunction('127.0.0.1', server.port,
+ sourceAddress: sourceAddress),
+ (e) =>
+ e is SocketException &&
+ e.address == new InternetAddress('8.8.8.8'));
}
// Address family mismatch.
for (sourceAddress in ['::1', InternetAddress.LOOPBACK_IP_V6]) {
- await throws(() => connectFunction('127.0.0.1',
- server.port,
- sourceAddress: sourceAddress),
- (e) => e is SocketException);
+ await throws(
+ () => connectFunction('127.0.0.1', server.port,
+ sourceAddress: sourceAddress),
+ (e) => e is SocketException);
}
asyncEnd();
server.close();
}
// IPv4 addresses to use as source address when connecting locally.
-var ipV4SourceAddresses = [InternetAddress.LOOPBACK_IP_V4,
- InternetAddress.ANY_IP_V4,
- '127.0.0.1',
- '0.0.0.0'];
+var ipV4SourceAddresses = [
+ InternetAddress.LOOPBACK_IP_V4,
+ InternetAddress.ANY_IP_V4,
+ '127.0.0.1',
+ '0.0.0.0'
+];
// IPv6 addresses to use as source address when connecting locally.
-var ipV6SourceAddresses = [InternetAddress.LOOPBACK_IP_V6,
- InternetAddress.ANY_IP_V6,
- '::1',
- '::'];
-
-Future testConnect(InternetAddress bindAddress,
- bool v6Only,
- Function connectFunction,
- Function closeDestroyFunction) async {
+var ipV6SourceAddresses = [
+ InternetAddress.LOOPBACK_IP_V6,
+ InternetAddress.ANY_IP_V6,
+ '::1',
+ '::'
+];
+
+Future testConnect(InternetAddress bindAddress, bool v6Only,
+ Function connectFunction, Function closeDestroyFunction) async {
int freePort = await freeIPv4AndIPv6Port();
var successCount = 0;
if (!v6Only) successCount += ipV4SourceAddresses.length;
if (bindAddress.type == InternetAddressType.IP_V6) {
- successCount += ipV6SourceAddresses.length;
+ successCount += ipV6SourceAddresses.length;
}
var count = 0;
var allConnected = new Completer();
@@ -102,33 +105,31 @@ Future testConnect(InternetAddress bindAddress,
// Connect with IPv4 source addesses.
for (var sourceAddress in ipV4SourceAddresses) {
if (!v6Only) {
- var s = await connectFunction(InternetAddress.LOOPBACK_IP_V4,
- server.port,
- sourceAddress: sourceAddress);
+ var s = await connectFunction(InternetAddress.LOOPBACK_IP_V4, server.port,
+ sourceAddress: sourceAddress);
closeDestroyFunction(s);
} else {
// Cannot use an IPv4 source address to connect to IPv6 if
// v6Only is specified.
- await throws(() => connectFunction(InternetAddress.LOOPBACK_IP_V6,
- server.port,
- sourceAddress: sourceAddress),
- (e) => e is SocketException);
+ await throws(
+ () => connectFunction(InternetAddress.LOOPBACK_IP_V6, server.port,
+ sourceAddress: sourceAddress),
+ (e) => e is SocketException);
}
}
// Connect with IPv6 source addesses.
for (var sourceAddress in ipV6SourceAddresses) {
if (bindAddress.type == InternetAddressType.IP_V6) {
- var s = await connectFunction(InternetAddress.LOOPBACK_IP_V6,
- server.port,
- sourceAddress: sourceAddress);
+ var s = await connectFunction(InternetAddress.LOOPBACK_IP_V6, server.port,
+ sourceAddress: sourceAddress);
closeDestroyFunction(s);
} else {
// Cannot use an IPv6 source address to connect to IPv4.
- await throws(() => connectFunction(InternetAddress.LOOPBACK_IP_V4,
- server.port,
- sourceAddress: sourceAddress),
- (e) => e is SocketException);
+ await throws(
+ () => connectFunction(InternetAddress.LOOPBACK_IP_V4, server.port,
+ sourceAddress: sourceAddress),
+ (e) => e is SocketException);
}
}

Powered by Google App Engine
This is Rietveld 408576698