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

Side by Side Diff: tests/standalone/io/http_connection_info_test.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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "dart:io"; 6 import "dart:io";
7 7
8 void testHttpConnectionInfo() { 8 void testHttpConnectionInfo() {
9 HttpServer.bind("0.0.0.0", 0).then((server) { 9 HttpServer.bind("0.0.0.0", 0).then((server) {
10 int clientPort; 10 int clientPort;
11 11
12 server.listen((request) { 12 server.listen((request) {
13 var response = request.response; 13 var response = request.response;
14 Expect.isTrue(request.connectionInfo.remoteAddress is InternetAddress); 14 Expect.isTrue(request.connectionInfo.remoteAddress is InternetAddress);
15 Expect.isTrue(response.connectionInfo.remoteAddress is InternetAddress); 15 Expect.isTrue(response.connectionInfo.remoteAddress is InternetAddress);
16 Expect.equals(request.connectionInfo.localPort, server.port); 16 Expect.equals(request.connectionInfo.localPort, server.port);
17 Expect.equals(response.connectionInfo.localPort, server.port); 17 Expect.equals(response.connectionInfo.localPort, server.port);
18 Expect.isNotNull(clientPort); 18 Expect.isNotNull(clientPort);
19 Expect.equals(request.connectionInfo.remotePort, clientPort); 19 Expect.equals(request.connectionInfo.remotePort, clientPort);
20 Expect.equals(response.connectionInfo.remotePort, clientPort); 20 Expect.equals(response.connectionInfo.remotePort, clientPort);
21 request.listen( 21 request.listen((_) {}, onDone: () {
22 (_) { }, 22 request.response.close();
23 onDone: () { request.response.close(); }); 23 });
24 }); 24 });
25 25
26 HttpClient client = new HttpClient(); 26 HttpClient client = new HttpClient();
27 client.get("127.0.0.1", server.port, "/") 27 client.get("127.0.0.1", server.port, "/").then((request) {
28 .then((request) { 28 Expect.isTrue(request.connectionInfo.remoteAddress is InternetAddress);
29 Expect.isTrue( 29 Expect.equals(request.connectionInfo.remotePort, server.port);
30 request.connectionInfo.remoteAddress is InternetAddress); 30 clientPort = request.connectionInfo.localPort;
31 Expect.equals(request.connectionInfo.remotePort, server.port); 31 return request.close();
32 clientPort = request.connectionInfo.localPort; 32 }).then((response) {
33 return request.close(); 33 Expect.equals(server.port, response.connectionInfo.remotePort);
34 }) 34 Expect.equals(clientPort, response.connectionInfo.localPort);
35 .then((response) { 35 response.listen((_) {}, onDone: () {
36 Expect.equals(server.port, response.connectionInfo.remotePort); 36 client.close();
37 Expect.equals(clientPort, response.connectionInfo.localPort); 37 server.close();
38 response.listen( 38 });
39 (_) { },
40 onDone: () {
41 client.close();
42 server.close();
43 });
44 });
45 }); 39 });
40 });
46 } 41 }
47 42
48 void main() { 43 void main() {
49 testHttpConnectionInfo(); 44 testHttpConnectionInfo();
50 } 45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698