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

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

Issue 1304243005: Handle addError on a WebSocket (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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_error_test.dart
diff --git a/tests/standalone/io/web_socket_error_test.dart b/tests/standalone/io/web_socket_error_test.dart
index cc16bde50f693029fad0be59ab9905b8448ca57b..69c7855e68a30d1827c184ba07c964aca10f11be 100644
--- a/tests/standalone/io/web_socket_error_test.dart
+++ b/tests/standalone/io/web_socket_error_test.dart
@@ -94,8 +94,107 @@ class SecurityConfiguration {
});
}
+ void testAddErrorServer() {
+ asyncStart();
+ asyncStart();
+ asyncStart();
+ asyncStart();
+ createServer().then((server) {
+ server.transform(new WebSocketTransformer()).listen((webSocket) {
+ webSocket.listen(
+ (message) {
+ webSocket.addError("ERROR");
+ },
+ onDone: () {
+ Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
+ webSocket.closeCode);
+ server.close();
+ },
+ onError: (e) {
+ Expect.equals("ERROR", e);
+ asyncEnd();
+ });
+
+ webSocket.done.then((_) {
+ Expect.fail("unexpected done completion");
+ }).catchError((e) {
+ Expect.equals("ERROR", e);
+ asyncEnd();
+ });
+ }, onDone: () {
+ asyncEnd();
+ });
+
+ createClient(server.port).then((webSocket) {
+ webSocket.add("message");
+ webSocket.listen(
+ (message) {
+ Expect.fail("unexpected message");
+ },
+ onDone: () {
+ Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
+ webSocket.closeCode);
+ server.close();
+ asyncEnd();
+ },
+ onError: (e) {
+ Expect.fail("unexpected onError");
+ });
+
+ });
+ });
+ }
+
+ void testAddErrorClient() {
+ asyncStart();
+ asyncStart();
+ asyncStart();
+ asyncStart();
+ createServer().then((server) {
+ server.transform(new WebSocketTransformer()).listen((webSocket) {
+ webSocket.listen(
+ (message) {
+ Expect.fail("unexpected message");
+ },
+ onDone: () {
+ Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
+ webSocket.closeCode);
+ asyncEnd();
+ });
+ }, onDone: () {
+ asyncEnd();
+ });
+
+ createClient(server.port).then((webSocket) {
+ webSocket.addError("ERROR");
+ webSocket.listen(
+ (message) {
+ Expect.fail("unexpected message");
+ },
+ onDone: () {
+ Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
+ webSocket.closeCode);
+ server.close();
+ },
+ onError: (e) {
+ Expect.equals("ERROR", e);
+ asyncEnd();
+ });
+
+ webSocket.done.then((_) {
+ Expect.fail("unexpected done completion");
+ }).catchError((e) {
+ Expect.equals("ERROR", e);
+ asyncEnd();
+ });
+ });
+ });
+ }
+
void runTests() {
testForceCloseServerEnd(10);
+ testAddErrorServer();
+ testAddErrorClient();
}
}
« 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