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

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

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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/io/string_stream_test.dart ('k') | tests/standalone/io/url_encoding_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) 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 part of ServerTest; 5 part of ServerTest;
6 6
7 abstract class TestingServer { 7 abstract class TestingServer {
8 8
9 static const HOST = "127.0.0.1"; 9 static const HOST = "127.0.0.1";
10 static const INIT = 0; 10 static const INIT = 0;
11 static const SHUTDOWN = -1; 11 static const SHUTDOWN = -1;
12 12
13 void onConnection(Socket connection); // Abstract. 13 void onConnection(Socket connection); // Abstract.
14 14
15 void errorHandlerServer(Exception e) { 15 void errorHandlerServer(e) {
16 Expect.fail("Server socket error $e"); 16 Expect.fail("Server socket error $e");
17 } 17 }
18 18
19 void dispatch(message, SendPort replyTo) { 19 void dispatch(message, SendPort replyTo) {
20 if (message == INIT) { 20 if (message == INIT) {
21 _server = new ServerSocket(HOST, 0, 10); 21 ServerSocket.bind(HOST, 0, 10).then((server) {
22 Expect.equals(true, _server != null); 22 _server = server;
23 _server.onConnection = onConnection; 23 _server.listen(
24 _server.onError = errorHandlerServer; 24 onConnection,
25 replyTo.send(_server.port, null); 25 onError: errorHandlerServer);
26 replyTo.send(_server.port, null);
27 });
26 } else if (message == SHUTDOWN) { 28 } else if (message == SHUTDOWN) {
27 _server.close(); 29 _server.close();
28 port.close(); 30 port.close();
29 } 31 }
30 } 32 }
31 33
32 ServerSocket _server; 34 ServerSocket _server;
33 } 35 }
34 36
35 abstract class TestingServerTest { 37 abstract class TestingServerTest {
(...skipping 16 matching lines...) Expand all
52 54
53 void shutdown() { 55 void shutdown() {
54 _sendPort.send(TestingServer.SHUTDOWN, _receivePort.toSendPort()); 56 _sendPort.send(TestingServer.SHUTDOWN, _receivePort.toSendPort());
55 _receivePort.close(); 57 _receivePort.close();
56 } 58 }
57 59
58 int _port; 60 int _port;
59 ReceivePort _receivePort; 61 ReceivePort _receivePort;
60 SendPort _sendPort; 62 SendPort _sendPort;
61 } 63 }
OLDNEW
« no previous file with comments | « tests/standalone/io/string_stream_test.dart ('k') | tests/standalone/io/url_encoding_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698