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

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

Issue 10837070: Remove old isolate API and update all code in the repository to use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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/language/typed_message_test.dart ('k') | tests/standalone/io/echo_server_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
11 11
12 #import("dart:io"); 12 #import("dart:io");
13 #import("dart:isolate"); 13 #import("dart:isolate");
14 #source("testing_server.dart"); 14 #source("testing_server.dart");
15 15
16 class EchoServerGame { 16 class EchoServerGame {
17 17
18 static final MSGSIZE = 10; 18 static final MSGSIZE = 10;
19 static final MESSAGES = 100; 19 static final MESSAGES = 100;
20 static final FIRSTCHAR = 65; 20 static final FIRSTCHAR = 65;
21 21
22 EchoServerGame.start() 22 EchoServerGame.start()
23 : _receivePort = new ReceivePort(), 23 : _receivePort = new ReceivePort(),
24 _sendPort = null, 24 _sendPort = null,
25 _buffer = new List<int>(MSGSIZE), 25 _buffer = new List<int>(MSGSIZE),
26 _messages = 0 { 26 _messages = 0 {
27 for (int i = 0; i < MSGSIZE; i++) { 27 for (int i = 0; i < MSGSIZE; i++) {
28 _buffer[i] = FIRSTCHAR + i; 28 _buffer[i] = FIRSTCHAR + i;
29 } 29 }
30 new EchoServer().spawn().then((SendPort port) { 30 _sendPort = spawnFunction(startEchoServer);
31 _sendPort = port; 31 start();
32 start();
33 });
34 } 32 }
35 33
36 void sendData() { 34 void sendData() {
37 35
38 void errorHandler(Exception e) { 36 void errorHandler(Exception e) {
39 Expect.fail("Socket error $e"); 37 Expect.fail("Socket error $e");
40 } 38 }
41 39
42 void connectHandler() { 40 void connectHandler() {
43 41
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 126
129 int _port; 127 int _port;
130 ReceivePort _receivePort; 128 ReceivePort _receivePort;
131 SendPort _sendPort; 129 SendPort _sendPort;
132 Socket _socket; 130 Socket _socket;
133 List<int> _buffer; 131 List<int> _buffer;
134 int _messages; 132 int _messages;
135 } 133 }
136 134
137 135
136 void startEchoServer() {
137 var server = new EchoServer();
138 port.receive(server.dispatch);
139 }
140
141
138 class EchoServer extends TestingServer { 142 class EchoServer extends TestingServer {
139 143
140 static final int MSGSIZE = EchoServerGame.MSGSIZE; 144 static final int MSGSIZE = EchoServerGame.MSGSIZE;
141 145
142 void onConnection(Socket connection) { 146 void onConnection(Socket connection) {
143 InputStream inputStream; 147 InputStream inputStream;
144 List<int> buffer = new List<int>(MSGSIZE); 148 List<int> buffer = new List<int>(MSGSIZE);
145 int offset = 0; 149 int offset = 0;
146 150
147 void dataReceived() { 151 void dataReceived() {
(...skipping 19 matching lines...) Expand all
167 171
168 inputStream = connection.inputStream; 172 inputStream = connection.inputStream;
169 inputStream.onData = dataReceived; 173 inputStream.onData = dataReceived;
170 connection.onError = errorHandler; 174 connection.onError = errorHandler;
171 } 175 }
172 } 176 }
173 177
174 main() { 178 main() {
175 EchoServerGame echoServerGame = new EchoServerGame.start(); 179 EchoServerGame echoServerGame = new EchoServerGame.start();
176 } 180 }
OLDNEW
« no previous file with comments | « tests/language/typed_message_test.dart ('k') | tests/standalone/io/echo_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698