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

Side by Side Diff: tests/standalone/io/web_socket_test.dart

Issue 10392125: Use Uint8List instead of String when sending messages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 104
105 void testMessageLength(int messageLength) { 105 void testMessageLength(int messageLength) {
106 HttpServer server = new HttpServer(); 106 HttpServer server = new HttpServer();
107 HttpClient client = new HttpClient(); 107 HttpClient client = new HttpClient();
108 108
109 server.listen("127.0.0.1", 0, 1); 109 server.listen("127.0.0.1", 0, 1);
110 110
111 // Create a web socket handler and set is as the HTTP server default 111 // Create a web socket handler and set is as the HTTP server default
112 // handler. 112 // handler.
113 String originalMessage = ""; 113 Uint8List originalMessage = new Uint8List(messageLength);
114 for (int i = 0; i < messageLength; i++) originalMessage += "${i % 10}";
115 WebSocketHandler wsHandler = new WebSocketHandler(); 114 WebSocketHandler wsHandler = new WebSocketHandler();
116 wsHandler.onOpen = (WebSocketConnection conn) { 115 wsHandler.onOpen = (WebSocketConnection conn) {
117 conn.onMessage = (Object message) { 116 conn.onMessage = (Object message) {
118 Expect.equals(originalMessage, message); 117 Expect.listEquals(originalMessage, message);
119 conn.send(message); 118 conn.send(message);
120 }; 119 };
121 conn.onClosed = (status, reason) { 120 conn.onClosed = (status, reason) {
122 }; 121 };
123 }; 122 };
124 server.defaultRequestHandler = wsHandler.onRequest; 123 server.defaultRequestHandler = wsHandler.onRequest;
125 124
126 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/"); 125 HttpClientConnection conn = client.get("127.0.0.1", server.port, "/");
127 WebSocketClientConnection wsconn = new WebSocketClientConnection(conn); 126 WebSocketClientConnection wsconn = new WebSocketClientConnection(conn);
128 wsconn.onMessage = (message) { 127 wsconn.onMessage = (message) {
129 Expect.equals(originalMessage, message); 128 Expect.listEquals(originalMessage, message);
130 wsconn.close(); 129 wsconn.close();
131 }; 130 };
132 wsconn.onClosed = (status, reason) { 131 wsconn.onClosed = (status, reason) {
133 server.close(); 132 server.close();
134 }; 133 };
135 wsconn.onOpen = () { 134 wsconn.onOpen = () {
136 wsconn.send(originalMessage); 135 wsconn.send(originalMessage);
137 }; 136 };
138 } 137 }
139 138
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 testMessageLength(126); 323 testMessageLength(126);
325 testMessageLength(127); 324 testMessageLength(127);
326 testMessageLength(65535); 325 testMessageLength(65535);
327 testMessageLength(65536); 326 testMessageLength(65536);
328 testNoUpgrade(); 327 testNoUpgrade();
329 testUsePOST(); 328 testUsePOST();
330 testHashCode(2); 329 testHashCode(2);
331 330
332 testW3CInterface(2, 3002, "Got tired"); 331 testW3CInterface(2, 3002, "Got tired");
333 } 332 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698