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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
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 part of ServerTest; 5 part of ServerTest;
6 6
7 abstract class TestingServer { 7 abstract class TestingServer {
8
9 static const HOST = "127.0.0.1"; 8 static const HOST = "127.0.0.1";
10 static const INIT = 0; 9 static const INIT = 0;
11 static const SHUTDOWN = -1; 10 static const SHUTDOWN = -1;
12 11
13 void onConnection(Socket connection); // Abstract. 12 void onConnection(Socket connection); // Abstract.
14 13
15 void errorHandlerServer(e, trace) { 14 void errorHandlerServer(e, trace) {
16 String msg = "Server socket error $e"; 15 String msg = "Server socket error $e";
17 if (trace != null) msg += "\nStackTrace: $trace"; 16 if (trace != null) msg += "\nStackTrace: $trace";
18 Expect.fail(msg); 17 Expect.fail(msg);
19 } 18 }
20 19
21 SendPort get closeSendPort => _closePort.sendPort; 20 SendPort get closeSendPort => _closePort.sendPort;
22 21
23 Future<int> init() { 22 Future<int> init() {
24 _closePort = new ReceivePort(); 23 _closePort = new ReceivePort();
25 _closePort.first.then((_) { close(); }); 24 _closePort.first.then((_) {
25 close();
26 });
26 return ServerSocket.bind(HOST, 0).then((server) { 27 return ServerSocket.bind(HOST, 0).then((server) {
27 _server = server; 28 _server = server;
28 _server.listen( 29 _server.listen(onConnection, onError: errorHandlerServer);
29 onConnection,
30 onError: errorHandlerServer);
31 return _server.port; 30 return _server.port;
32 }); 31 });
33 } 32 }
34 33
35 void close() { 34 void close() {
36 _server.close(); 35 _server.close();
37 } 36 }
38 37
39 ServerSocket _server; 38 ServerSocket _server;
40 ReceivePort _closePort; 39 ReceivePort _closePort;
41 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698