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

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

Issue 11336012: Remove public SocketInputStream and SocketOutputStream clases (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | « runtime/bin/socket_stream_impl.dart ('k') | tests/standalone/io/stream_pipe_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) 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 // 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 21 matching lines...) Expand all
32 } 32 }
33 33
34 void sendData() { 34 void sendData() {
35 35
36 void errorHandler(Exception e) { 36 void errorHandler(Exception e) {
37 Expect.fail("Socket error $e"); 37 Expect.fail("Socket error $e");
38 } 38 }
39 39
40 void connectHandler() { 40 void connectHandler() {
41 41
42 SocketOutputStream stream = _socket.outputStream; 42 OutputStream stream = _socket.outputStream;
43 43
44 void dataSent() { 44 void dataSent() {
45 InputStream inputStream = _socket.inputStream; 45 InputStream inputStream = _socket.inputStream;
46 int offset = 0; 46 int offset = 0;
47 List<int> data; 47 List<int> data;
48 48
49 void onClosed() { 49 void onClosed() {
50 Expect.equals(MSGSIZE, offset); 50 Expect.equals(MSGSIZE, offset);
51 _messages++; 51 _messages++;
52 if (_messages < MESSAGES) { 52 if (_messages < MESSAGES) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 class EchoServer extends TestingServer { 142 class EchoServer extends TestingServer {
143 143
144 static const int MSGSIZE = EchoServerGame.MSGSIZE; 144 static const int MSGSIZE = EchoServerGame.MSGSIZE;
145 145
146 void onConnection(Socket connection) { 146 void onConnection(Socket connection) {
147 InputStream inputStream; 147 InputStream inputStream;
148 List<int> buffer = new List<int>(MSGSIZE); 148 List<int> buffer = new List<int>(MSGSIZE);
149 int offset = 0; 149 int offset = 0;
150 150
151 void dataReceived() { 151 void dataReceived() {
152 SocketOutputStream outputStream;
153 int bytesRead; 152 int bytesRead;
154 outputStream = connection.outputStream; 153 OutputStream outputStream = connection.outputStream;
155 bytesRead = inputStream.readInto(buffer, offset, MSGSIZE - offset); 154 bytesRead = inputStream.readInto(buffer, offset, MSGSIZE - offset);
156 if (bytesRead > 0) { 155 if (bytesRead > 0) {
157 offset += bytesRead; 156 offset += bytesRead;
158 for (int i = 0; i < offset; i++) { 157 for (int i = 0; i < offset; i++) {
159 Expect.equals(EchoServerGame.FIRSTCHAR + i, buffer[i]); 158 Expect.equals(EchoServerGame.FIRSTCHAR + i, buffer[i]);
160 } 159 }
161 if (offset == MSGSIZE) { 160 if (offset == MSGSIZE) {
162 outputStream.write(buffer); 161 outputStream.write(buffer);
163 outputStream.close(); 162 outputStream.close();
164 } 163 }
165 } 164 }
166 } 165 }
167 166
168 void errorHandler(Exception e) { 167 void errorHandler(Exception e) {
169 Expect.fail("Socket error $e"); 168 Expect.fail("Socket error $e");
170 } 169 }
171 170
172 inputStream = connection.inputStream; 171 inputStream = connection.inputStream;
173 inputStream.onData = dataReceived; 172 inputStream.onData = dataReceived;
174 connection.onError = errorHandler; 173 connection.onError = errorHandler;
175 } 174 }
176 } 175 }
177 176
178 main() { 177 main() {
179 EchoServerGame echoServerGame = new EchoServerGame.start(); 178 EchoServerGame echoServerGame = new EchoServerGame.start();
180 } 179 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_stream_impl.dart ('k') | tests/standalone/io/stream_pipe_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698