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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 library dart.io; 10 library dart.io;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 closeCount++; 87 closeCount++;
88 if (closeCount == totalConnections) { 88 if (closeCount == totalConnections) {
89 server.close(); 89 server.close();
90 } 90 }
91 }); 91 });
92 }); 92 });
93 } 93 }
94 }); 94 });
95 } 95 }
96 96
97 void testAddErrorServer() {
98 asyncStart();
99 asyncStart();
100 asyncStart();
101 asyncStart();
102 createServer().then((server) {
103 server.transform(new WebSocketTransformer()).listen((webSocket) {
104 webSocket.listen(
105 (message) {
106 webSocket.addError("ERROR");
107 },
108 onDone: () {
109 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
110 webSocket.closeCode);
111 server.close();
112 },
113 onError: (e) {
114 Expect.equals("ERROR", e);
115 asyncEnd();
116 });
117
118 webSocket.done.then((_) {
119 Expect.fail("unexpected done completion");
120 }).catchError((e) {
121 Expect.equals("ERROR", e);
122 asyncEnd();
123 });
124 }, onDone: () {
125 asyncEnd();
126 });
127
128 createClient(server.port).then((webSocket) {
129 webSocket.add("message");
130 webSocket.listen(
131 (message) {
132 Expect.fail("unexpected message");
133 },
134 onDone: () {
135 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
136 webSocket.closeCode);
137 server.close();
138 asyncEnd();
139 },
140 onError: (e) {
141 Expect.fail("unexpected onError");
142 });
143
144 });
145 });
146 }
147
148 void testAddErrorClient() {
149 asyncStart();
150 asyncStart();
151 asyncStart();
152 asyncStart();
153 createServer().then((server) {
154 server.transform(new WebSocketTransformer()).listen((webSocket) {
155 webSocket.listen(
156 (message) {
157 Expect.fail("unexpected message");
158 },
159 onDone: () {
160 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
161 webSocket.closeCode);
162 asyncEnd();
163 });
164 }, onDone: () {
165 asyncEnd();
166 });
167
168 createClient(server.port).then((webSocket) {
169 webSocket.addError("ERROR");
170 webSocket.listen(
171 (message) {
172 Expect.fail("unexpected message");
173 },
174 onDone: () {
175 Expect.equals(WebSocketStatus.ABNORMAL_CLOSURE,
176 webSocket.closeCode);
177 server.close();
178 },
179 onError: (e) {
180 Expect.equals("ERROR", e);
181 asyncEnd();
182 });
183
184 webSocket.done.then((_) {
185 Expect.fail("unexpected done completion");
186 }).catchError((e) {
187 Expect.equals("ERROR", e);
188 asyncEnd();
189 });
190 });
191 });
192 }
193
97 void runTests() { 194 void runTests() {
98 testForceCloseServerEnd(10); 195 testForceCloseServerEnd(10);
196 testAddErrorServer();
197 testAddErrorClient();
99 } 198 }
100 } 199 }
101 200
102 201
103 main() { 202 main() {
104 asyncStart(); 203 asyncStart();
105 new SecurityConfiguration(secure: false).runTests(); 204 new SecurityConfiguration(secure: false).runTests();
106 // TODO(whesse): WebSocket.connect needs an optional context: parameter 205 // TODO(whesse): WebSocket.connect needs an optional context: parameter
107 // new SecurityConfiguration(secure: true).runTests(); 206 // new SecurityConfiguration(secure: true).runTests();
108 asyncEnd(); 207 asyncEnd();
109 } 208 }
110 209
OLDNEW
« 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