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

Unified Diff: tests/standalone/io/web_socket_protocol_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/web_socket_protocol_test.dart
diff --git a/tests/standalone/io/web_socket_protocol_test.dart b/tests/standalone/io/web_socket_protocol_test.dart
index e81cc27a2bf4186d4b8801c72305eac7c86e08ad..edbb1b211e6c7f2b7fd3d30075bd9ec859c0b011 100644
--- a/tests/standalone/io/web_socket_protocol_test.dart
+++ b/tests/standalone/io/web_socket_protocol_test.dart
@@ -11,7 +11,6 @@ import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
-
testEmptyProtocol() {
HttpServer.bind("127.0.0.1", 0).then((server) {
server.listen((request) {
@@ -19,8 +18,8 @@ testEmptyProtocol() {
websocket.close();
});
});
- WebSocket.connect("ws://127.0.0.1:${server.port}/",
- protocols: []).then((client) {
+ WebSocket.connect("ws://127.0.0.1:${server.port}/", protocols: []).then(
+ (client) {
Expect.isNull(client.protocol);
client.close();
server.close();
@@ -28,23 +27,24 @@ testEmptyProtocol() {
});
}
-
testProtocol(List<String> protocols, String used) {
selector(List<String> receivedProtocols) {
Expect.listEquals(protocols, receivedProtocols);
return used;
}
+
HttpServer.bind("127.0.0.1", 0).then((server) {
server.listen((request) {
- WebSocketTransformer.upgrade(request,
- protocolSelector: selector)
- .then((websocket) {
- Expect.equals(used, websocket.protocol);
- websocket.close();
- });
+ WebSocketTransformer
+ .upgrade(request, protocolSelector: selector)
+ .then((websocket) {
+ Expect.equals(used, websocket.protocol);
+ websocket.close();
+ });
});
- WebSocket.connect("ws://127.0.0.1:${server.port}/",
- protocols: protocols).then((client) {
+ WebSocket
+ .connect("ws://127.0.0.1:${server.port}/", protocols: protocols)
+ .then((client) {
Expect.equals(used, client.protocol);
client.close();
server.close();
@@ -52,7 +52,6 @@ testProtocol(List<String> protocols, String used) {
});
}
-
testProtocolHandler() {
// Test throwing an error.
HttpServer.bind("127.0.0.1", 0).then((server) {
@@ -60,50 +59,45 @@ testProtocolHandler() {
selector(List<String> receivedProtocols) {
throw "error";
}
- WebSocketTransformer.upgrade(request,
- protocolSelector: selector)
- .then((websocket) {
- Expect.fail('error expected');
- }, onError: (error) {
- Expect.equals('error', error);
- });
- });
- WebSocket.connect("ws://127.0.0.1:${server.port}/",
- protocols: ["v1.example.com"])
- .then((client) {
+
+ WebSocketTransformer.upgrade(request, protocolSelector: selector).then(
+ (websocket) {
Expect.fail('error expected');
}, onError: (error) {
- server.close();
+ Expect.equals('error', error);
});
+ });
+ WebSocket.connect("ws://127.0.0.1:${server.port}/",
+ protocols: ["v1.example.com"]).then((client) {
+ Expect.fail('error expected');
+ }, onError: (error) {
+ server.close();
+ });
});
// Test returning another protocol.
HttpServer.bind("127.0.0.1", 0).then((server) {
server.listen((request) {
selector(List<String> receivedProtocols) => "v2.example.com";
- WebSocketTransformer.upgrade(request,
- protocolSelector: selector)
- .then((websocket) {
- Expect.fail('error expected');
- }, onError: (error) {
- Expect.isTrue(error is WebSocketException);
- });
- });
- WebSocket.connect("ws://127.0.0.1:${server.port}/",
- protocols: ["v1.example.com"])
- .then((client) {
+ WebSocketTransformer.upgrade(request, protocolSelector: selector).then(
+ (websocket) {
Expect.fail('error expected');
}, onError: (error) {
- server.close();
+ Expect.isTrue(error is WebSocketException);
});
+ });
+ WebSocket.connect("ws://127.0.0.1:${server.port}/",
+ protocols: ["v1.example.com"]).then((client) {
+ Expect.fail('error expected');
+ }, onError: (error) {
+ server.close();
+ });
});
}
-
void main() {
testEmptyProtocol();
testProtocol(["v1.example.com", "v2.example.com"], "v1.example.com");
testProtocol(["v1.example.com", "v2.example.com"], "v2.example.com");
testProtocolHandler();
}
-

Powered by Google App Engine
This is Rietveld 408576698