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

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

Issue 11570005: Remove old #import, #source, and #library syntax from tests/standalone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
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 class TestingServer { 5 part of ServerTest;
6
7 abstract class TestingServer {
6 8
7 static const HOST = "127.0.0.1"; 9 static const HOST = "127.0.0.1";
8 static const INIT = 0; 10 static const INIT = 0;
9 static const SHUTDOWN = -1; 11 static const SHUTDOWN = -1;
10 12
11 void onConnection(Socket connection); // Abstract. 13 void onConnection(Socket connection); // Abstract.
12 14
13 void errorHandlerServer(Exception e) { 15 void errorHandlerServer(Exception e) {
14 Expect.fail("Server socket error $e"); 16 Expect.fail("Server socket error $e");
15 } 17 }
16 18
17 void dispatch(message, SendPort replyTo) { 19 void dispatch(message, SendPort replyTo) {
18 if (message == INIT) { 20 if (message == INIT) {
19 _server = new ServerSocket(HOST, 0, 10); 21 _server = new ServerSocket(HOST, 0, 10);
20 Expect.equals(true, _server != null); 22 Expect.equals(true, _server != null);
21 _server.onConnection = onConnection; 23 _server.onConnection = onConnection;
22 _server.onError = errorHandlerServer; 24 _server.onError = errorHandlerServer;
23 replyTo.send(_server.port, null); 25 replyTo.send(_server.port, null);
24 } else if (message == SHUTDOWN) { 26 } else if (message == SHUTDOWN) {
25 _server.close(); 27 _server.close();
26 port.close(); 28 port.close();
27 } 29 }
28 } 30 }
29 31
30 ServerSocket _server; 32 ServerSocket _server;
31 } 33 }
32 34
33 class TestingServerTest { 35 abstract class TestingServerTest {
34 36
35 TestingServerTest.start(SendPort port) 37 TestingServerTest.start(SendPort port)
36 : _receivePort = new ReceivePort(), 38 : _receivePort = new ReceivePort(),
37 _sendPort = port { 39 _sendPort = port {
38 initialize(); 40 initialize();
39 } 41 }
40 42
41 void run(); // Abstract. 43 void run(); // Abstract.
42 44
43 void initialize() { 45 void initialize() {
44 _receivePort.receive((var message, SendPort replyTo) { 46 _receivePort.receive((var message, SendPort replyTo) {
45 _port = message; 47 _port = message;
46 run(); 48 run();
47 }); 49 });
48 _sendPort.send(TestingServer.INIT, _receivePort.toSendPort()); 50 _sendPort.send(TestingServer.INIT, _receivePort.toSendPort());
49 } 51 }
50 52
51 void shutdown() { 53 void shutdown() {
52 _sendPort.send(TestingServer.SHUTDOWN, _receivePort.toSendPort()); 54 _sendPort.send(TestingServer.SHUTDOWN, _receivePort.toSendPort());
53 _receivePort.close(); 55 _receivePort.close();
54 } 56 }
55 57
56 int _port; 58 int _port;
57 ReceivePort _receivePort; 59 ReceivePort _receivePort;
58 SendPort _sendPort; 60 SendPort _sendPort;
59 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698