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

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

Issue 10377124: Add a hash code to client and server web socket connections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 8 years, 7 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 | « runtime/bin/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 7f2017c8f5023559dec8caf888338d1f5d020ffc..907cf977fc0a7351059b0ab9c5422b37520aed3e 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -150,6 +150,60 @@ void testUsePOST() {
}
+class WebSocketInfo {
+ int messageCount = 0;
+}
+
+
+void testHashCode(int totalConnections) {
+ HttpServer server = new HttpServer();
+ HttpClient client = new HttpClient();
+ Map connections = new Map();
+
+ server.listen("127.0.0.1", 0, totalConnections);
+
+ void handleMessage(conn, message) {
+ var info = connections[conn];
+ Expect.isNotNull(info);
+ info.messageCount++;
+ if (info.messageCount < 10) {
+ conn.send(message);
+ } else {
+ conn.close();
+ }
+ }
+
+ // Create a web socket handler and set is as the HTTP server default
+ // handler.
+ int closeCount = 0;
+ WebSocketHandler wsHandler = new WebSocketHandler();
+ wsHandler.onOpen = (WebSocketConnection conn) {
+ connections[conn] = new WebSocketInfo();
+ String messageText = "Hello, world!";
+ conn.onMessage = (Object message) {
+ handleMessage(conn, message);
+ };
+ conn.onClosed = (status, reason) {
+ closeCount++;
+ var info = connections[conn];
+ Expect.equals(10, info.messageCount);
+ if (closeCount == totalConnections) {
+ client.shutdown();
+ server.close();
+ }
+ };
+ conn.send(messageText);
+ };
+ server.defaultRequestHandler = wsHandler.onRequest;
+
+ for (int i = 0; i < totalConnections; i++) {
+ HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
+ WebSocketClientConnection wsconn = new WebSocketClientConnection(conn);
+ wsconn.onMessage = (message) => wsconn.send(message);
+ }
+}
+
+
void testW3CInterface(
int totalConnections, int closeStatus, String closeReason) {
HttpServer server = new HttpServer();
@@ -232,6 +286,7 @@ main() {
testRequestResponseServerCloses(2, 3002, "Got tired");
testNoUpgrade();
testUsePOST();
+ testHashCode(2);
testW3CInterface(2, 3002, "Got tired");
}
« no previous file with comments | « runtime/bin/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698