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

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

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed second round of review comments Created 7 years, 9 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 | « tests/standalone/debugger/debug_lib.dart ('k') | tests/standalone/io/file_fuzz_test.dart » ('j') | 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 // Echo server test program to test socket streams. 5 // Echo server test program to test socket streams.
6 // 6 //
7 // VMOptions= 7 // VMOptions=
8 // VMOptions=--short_socket_read 8 // VMOptions=--short_socket_read
9 // VMOptions=--short_socket_write 9 // VMOptions=--short_socket_write
10 // VMOptions=--short_socket_read --short_socket_write 10 // VMOptions=--short_socket_read --short_socket_write
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 void errorHandler(e) { 58 void errorHandler(e) {
59 Expect.fail("Socket error $e"); 59 Expect.fail("Socket error $e");
60 } 60 }
61 61
62 void connectHandler() { 62 void connectHandler() {
63 _socket.listen(onData, 63 _socket.listen(onData,
64 onError: errorHandler, 64 onError: errorHandler,
65 onDone: onClosed); 65 onDone: onClosed);
66 _socket.add(_buffer); 66 _socket.writeBytes(_buffer);
67 _socket.close(); 67 _socket.close();
68 data = new List<int>(MSGSIZE); 68 data = new List<int>(MSGSIZE);
69 } 69 }
70 70
71 Socket.connect(TestingServer.HOST, _port).then((s) { 71 Socket.connect(TestingServer.HOST, _port).then((s) {
72 _socket = s; 72 _socket = s;
73 connectHandler(); 73 connectHandler();
74 }); 74 });
75 } 75 }
76 76
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void dataReceived(List<int> data) { 113 void dataReceived(List<int> data) {
114 int bytesRead; 114 int bytesRead;
115 bytesRead = data.length; 115 bytesRead = data.length;
116 if (bytesRead > 0) { 116 if (bytesRead > 0) {
117 buffer.setRange(offset, data.length, data); 117 buffer.setRange(offset, data.length, data);
118 offset += bytesRead; 118 offset += bytesRead;
119 for (int i = 0; i < offset; i++) { 119 for (int i = 0; i < offset; i++) {
120 Expect.equals(EchoServerGame.FIRSTCHAR + i, buffer[i]); 120 Expect.equals(EchoServerGame.FIRSTCHAR + i, buffer[i]);
121 } 121 }
122 if (offset == MSGSIZE) { 122 if (offset == MSGSIZE) {
123 connection.add(buffer); 123 connection.writeBytes(buffer);
124 connection.close(); 124 connection.close();
125 } 125 }
126 } 126 }
127 } 127 }
128 128
129 void errorHandler(e) { 129 void errorHandler(e) {
130 Expect.fail("Socket error $e"); 130 Expect.fail("Socket error $e");
131 } 131 }
132 132
133 connection.listen(dataReceived, onError: errorHandler); 133 connection.listen(dataReceived, onError: errorHandler);
134 } 134 }
135 } 135 }
136 136
137 main() { 137 main() {
138 EchoServerGame echoServerGame = new EchoServerGame.start(); 138 EchoServerGame echoServerGame = new EchoServerGame.start();
139 } 139 }
OLDNEW
« no previous file with comments | « tests/standalone/debugger/debug_lib.dart ('k') | tests/standalone/io/file_fuzz_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698