Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
| 6 #import("dart:io"); | 6 #import("dart:io"); |
| 7 | 7 |
| 8 void testRequestResponseClientCloses( | 8 void testRequestResponseClientCloses( |
| 9 int totalConnections, int closeStatus, String closeReason) { | 9 int totalConnections, int closeStatus, String closeReason) { |
| 10 HttpServer server = new HttpServer(); | 10 HttpServer server = new HttpServer(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 HttpClientConnection conn = client.post("127.0.0.1", server.port, "/"); | 143 HttpClientConnection conn = client.post("127.0.0.1", server.port, "/"); |
| 144 WebSocketClientConnection wsconn = new WebSocketClientConnection(conn); | 144 WebSocketClientConnection wsconn = new WebSocketClientConnection(conn); |
| 145 wsconn.onNoUpgrade = (response) { | 145 wsconn.onNoUpgrade = (response) { |
| 146 Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode); | 146 Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode); |
| 147 client.shutdown(); | 147 client.shutdown(); |
| 148 server.close(); | 148 server.close(); |
| 149 }; | 149 }; |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 void testHashCode() { | |
|
Mads Ager (google)
2012/05/14 09:19:39
How about extending this with a case where you put
Søren Gjesse
2012/05/14 15:52:41
Done.
| |
| 154 HttpServer server = new HttpServer(); | |
| 155 HttpClient client = new HttpClient(); | |
| 156 | |
| 157 server.listen("127.0.0.1", 0, 5); | |
| 158 | |
| 159 // Create a web socket handler and set is as the HTTP server default | |
| 160 // handler. | |
| 161 WebSocketHandler wsHandler = new WebSocketHandler(); | |
| 162 wsHandler.onOpen = (WebSocketConnection conn) { | |
| 163 Expect.isNotNull(conn.hashCode()); | |
| 164 conn.close(); | |
| 165 }; | |
| 166 server.defaultRequestHandler = wsHandler.onRequest; | |
| 167 | |
| 168 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); | |
| 169 WebSocketClientConnection wsconn = new WebSocketClientConnection(conn); | |
| 170 Expect.isNotNull(wsconn.hashCode()); | |
| 171 wsconn.onClosed = (status, reason) { | |
| 172 client.shutdown(); | |
| 173 server.close(); | |
| 174 }; | |
| 175 } | |
| 176 | |
| 177 | |
| 153 void testW3CInterface( | 178 void testW3CInterface( |
| 154 int totalConnections, int closeStatus, String closeReason) { | 179 int totalConnections, int closeStatus, String closeReason) { |
| 155 HttpServer server = new HttpServer(); | 180 HttpServer server = new HttpServer(); |
| 156 | 181 |
| 157 server.listen("127.0.0.1", 0, totalConnections); | 182 server.listen("127.0.0.1", 0, totalConnections); |
| 158 | 183 |
| 159 // Create a web socket handler and set is as the HTTP server default | 184 // Create a web socket handler and set is as the HTTP server default |
| 160 // handler. | 185 // handler. |
| 161 int closeCount = 0; | 186 int closeCount = 0; |
| 162 WebSocketHandler wsHandler = new WebSocketHandler(); | 187 WebSocketHandler wsHandler = new WebSocketHandler(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 | 250 |
| 226 main() { | 251 main() { |
| 227 testRequestResponseClientCloses(2, null, null); | 252 testRequestResponseClientCloses(2, null, null); |
| 228 testRequestResponseClientCloses(2, 3001, null); | 253 testRequestResponseClientCloses(2, 3001, null); |
| 229 testRequestResponseClientCloses(2, 3002, "Got tired"); | 254 testRequestResponseClientCloses(2, 3002, "Got tired"); |
| 230 testRequestResponseServerCloses(2, null, null); | 255 testRequestResponseServerCloses(2, null, null); |
| 231 testRequestResponseServerCloses(2, 3001, null); | 256 testRequestResponseServerCloses(2, 3001, null); |
| 232 testRequestResponseServerCloses(2, 3002, "Got tired"); | 257 testRequestResponseServerCloses(2, 3002, "Got tired"); |
| 233 testNoUpgrade(); | 258 testNoUpgrade(); |
| 234 testUsePOST(); | 259 testUsePOST(); |
| 260 testHashCode(); | |
| 235 | 261 |
| 236 testW3CInterface(2, 3002, "Got tired"); | 262 testW3CInterface(2, 3002, "Got tired"); |
| 237 } | 263 } |
| OLD | NEW |