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

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

Issue 1273663002: Echo the WebSocket close reason as well as the close code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/web_socket_test.dart
diff --git a/tests/standalone/io/web_socket_test.dart b/tests/standalone/io/web_socket_test.dart
index 9ae175815ac65e4cf21560906f2598529e5b2207..ae383078ac65438245cc8227fdf09b390a5a2727 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -42,6 +42,13 @@ class SecurityConfiguration {
Future<WebSocket> createClient(int port) =>
WebSocket.connect('${secure ? "wss" : "ws"}://$HOST_NAME:$port/');
+ checkCloseStatus(webSocket, closeStatus, closeReason) {
+ Expect.equals(closeStatus == null ? WebSocketStatus.NO_STATUS_RECEIVED
+ : closeStatus, webSocket.closeCode);
+ Expect.equals(closeReason == null ? ""
+ : closeReason, webSocket.closeReason);
+ }
+
void testRequestResponseClientCloses(int totalConnections,
int closeStatus,
String closeReason,
@@ -55,12 +62,7 @@ class SecurityConfiguration {
webSocket.listen(
webSocket.add,
onDone: () {
- Expect.equals(closeStatus == null
- ? WebSocketStatus.NO_STATUS_RECEIVED
- : closeStatus, webSocket.closeCode);
- Expect.equals(
- closeReason == null ? ""
- : closeReason, webSocket.closeReason);
+ checkCloseStatus(webSocket, closeStatus, closeReason);
asyncEnd();
});
}, onDone: () {
@@ -85,10 +87,7 @@ class SecurityConfiguration {
}
},
onDone: () {
- Expect.equals(closeStatus == null
- ? WebSocketStatus.NO_STATUS_RECEIVED
- : closeStatus, webSocket.closeCode);
- Expect.equals("", webSocket.closeReason);
+ checkCloseStatus(webSocket, closeStatus, closeReason);
closeCount++;
if (closeCount == totalConnections) {
server.close();
@@ -119,10 +118,7 @@ class SecurityConfiguration {
}
},
onDone: () {
- Expect.equals(closeStatus == null
- ? WebSocketStatus.NO_STATUS_RECEIVED
- : closeStatus, webSocket.closeCode);
- Expect.equals("", webSocket.closeReason);
+ checkCloseStatus(webSocket, closeStatus, closeReason);
closeCount++;
if (closeCount == totalConnections) {
server.close();
@@ -136,12 +132,7 @@ class SecurityConfiguration {
webSocket.listen(
webSocket.add,
onDone: () {
- Expect.equals(closeStatus == null
- ? WebSocketStatus.NO_STATUS_RECEIVED
- : closeStatus, webSocket.closeCode);
- Expect.equals(closeReason == null
- ? ""
- : closeReason, webSocket.closeReason);
+ checkCloseStatus(webSocket, closeStatus, closeReason);
});
});
}
@@ -363,8 +354,7 @@ class SecurityConfiguration {
}
},
onDone: () {
- Expect.equals(closeStatus, webSocket.closeCode);
- Expect.equals("", webSocket.closeReason);
+ checkCloseStatus(webSocket, closeStatus, closeReason);
closeCount++;
if (closeCount == totalConnections) {
server.close();
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698