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

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

Issue 14036017: Revert "Add new InternetAddress class with a static lookup function (including IPv6 results)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:async"; 11 import "dart:async";
12 import "dart:io"; 12 import "dart:io";
13 import "dart:isolate"; 13 import "dart:isolate";
14 14
15 const SERVER_ADDRESS = "127.0.0.1";
15 const HOST_NAME = "localhost"; 16 const HOST_NAME = "localhost";
16 const CERTIFICATE = "localhost_cert"; 17 const CERTIFICATE = "localhost_cert";
17 18
18 void testCloseOneEnd(String toClose) { 19 void testCloseOneEnd(String toClose) {
19 ReceivePort port = new ReceivePort(); 20 ReceivePort port = new ReceivePort();
20 Completer serverDone = new Completer(); 21 Completer serverDone = new Completer();
21 Completer serverEndDone = new Completer(); 22 Completer serverEndDone = new Completer();
22 Completer clientEndDone = new Completer(); 23 Completer clientEndDone = new Completer();
23 Future.wait([serverDone.future, serverEndDone.future, clientEndDone.future]) 24 Future.wait([serverDone.future, serverEndDone.future, clientEndDone.future])
24 .then((_) { 25 .then((_) {
25 port.close(); 26 port.close();
26 }); 27 });
27 SecureServerSocket.bind(HOST_NAME, 0, 5, CERTIFICATE).then((server) { 28 SecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) {
28 server.listen((serverConnection) { 29 server.listen((serverConnection) {
29 serverConnection.listen( 30 serverConnection.listen(
30 (data) { 31 (data) {
31 Expect.fail("No data should be received by server"); 32 Expect.fail("No data should be received by server");
32 }, 33 },
33 onDone: () { 34 onDone: () {
34 serverConnection.close(); 35 serverConnection.close();
35 serverEndDone.complete(null); 36 serverEndDone.complete(null);
36 server.close(); 37 server.close();
37 }); 38 });
(...skipping 15 matching lines...) Expand all
53 }); 54 });
54 if (toClose == "client") { 55 if (toClose == "client") {
55 clientConnection.close(); 56 clientConnection.close();
56 } 57 }
57 }); 58 });
58 }); 59 });
59 } 60 }
60 61
61 void testCloseBothEnds() { 62 void testCloseBothEnds() {
62 ReceivePort port = new ReceivePort(); 63 ReceivePort port = new ReceivePort();
63 SecureServerSocket.bind(HOST_NAME, 0, 5, CERTIFICATE).then((server) { 64 SecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) {
64 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port); 65 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port);
65 server.listen((serverEnd) { 66 server.listen((serverEnd) {
66 clientEndFuture.then((clientEnd) { 67 clientEndFuture.then((clientEnd) {
67 clientEnd.destroy(); 68 clientEnd.destroy();
68 serverEnd.destroy(); 69 serverEnd.destroy();
69 server.close(); 70 server.close();
70 port.close(); 71 port.close();
71 }); 72 });
72 }); 73 });
73 }); 74 });
74 } 75 }
75 76
76 testPauseServerSocket() { 77 testPauseServerSocket() {
77 const int socketCount = 10; 78 const int socketCount = 10;
78 var acceptCount = 0; 79 var acceptCount = 0;
79 var resumed = false; 80 var resumed = false;
80 81
81 ReceivePort port = new ReceivePort(); 82 ReceivePort port = new ReceivePort();
82 83
83 SecureServerSocket.bind(HOST_NAME, 84 SecureServerSocket.bind(SERVER_ADDRESS,
84 0, 85 0,
85 2 * socketCount, 86 2 * socketCount,
86 CERTIFICATE).then((server) { 87 CERTIFICATE).then((server) {
87 Expect.isTrue(server.port > 0); 88 Expect.isTrue(server.port > 0);
88 var subscription; 89 var subscription;
89 subscription = server.listen((connection) { 90 subscription = server.listen((connection) {
90 Expect.isTrue(resumed); 91 Expect.isTrue(resumed);
91 connection.close(); 92 connection.close();
92 if (++acceptCount == 2 * socketCount) { 93 if (++acceptCount == 2 * socketCount) {
93 server.close(); 94 server.close();
(...skipping 23 matching lines...) Expand all
117 }); 118 });
118 } 119 }
119 120
120 121
121 testCloseServer() { 122 testCloseServer() {
122 const int socketCount = 3; 123 const int socketCount = 3;
123 var endCount = 0; 124 var endCount = 0;
124 ReceivePort port = new ReceivePort(); 125 ReceivePort port = new ReceivePort();
125 List ends = []; 126 List ends = [];
126 127
127 SecureServerSocket.bind(HOST_NAME, 0, 15, CERTIFICATE).then((server) { 128 SecureServerSocket.bind(SERVER_ADDRESS, 0, 15, CERTIFICATE).then((server) {
128 Expect.isTrue(server.port > 0); 129 Expect.isTrue(server.port > 0);
129 void checkDone() { 130 void checkDone() {
130 if (ends.length < 2 * socketCount) return; 131 if (ends.length < 2 * socketCount) return;
131 for (var end in ends) { 132 for (var end in ends) {
132 end.destroy(); 133 end.destroy();
133 } 134 }
134 server.close(); 135 server.close();
135 port.close(); 136 port.close();
136 } 137 }
137 138
(...skipping 20 matching lines...) Expand all
158 useBuiltinRoots: false); 159 useBuiltinRoots: false);
159 160
160 testCloseOneEnd("client"); 161 testCloseOneEnd("client");
161 testCloseOneEnd("server"); 162 testCloseOneEnd("server");
162 testCloseBothEnds(); 163 testCloseBothEnds();
163 testPauseServerSocket(); 164 testPauseServerSocket();
164 testCloseServer(); 165 testCloseServer();
165 // TODO(whesse): Add testPauseSocket from raw_socket_test.dart. 166 // TODO(whesse): Add testPauseSocket from raw_socket_test.dart.
166 // TODO(whesse): Add testCancelResubscribeSocket from raw_socket_test.dart. 167 // TODO(whesse): Add testCancelResubscribeSocket from raw_socket_test.dart.
167 } 168 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_server_client_certificate_test.dart ('k') | tests/standalone/io/secure_server_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698