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

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

Issue 14083007: 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: Fix new test. 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";
16 const HOST_NAME = "localhost"; 15 const HOST_NAME = "localhost";
17 const CERTIFICATE = "localhost_cert"; 16 const CERTIFICATE = "localhost_cert";
18 17
19 void testCloseOneEnd(String toClose) { 18 void testCloseOneEnd(String toClose) {
20 ReceivePort port = new ReceivePort(); 19 ReceivePort port = new ReceivePort();
21 Completer serverDone = new Completer(); 20 Completer serverDone = new Completer();
22 Completer serverEndDone = new Completer(); 21 Completer serverEndDone = new Completer();
23 Completer clientEndDone = new Completer(); 22 Completer clientEndDone = new Completer();
24 Future.wait([serverDone.future, serverEndDone.future, clientEndDone.future]) 23 Future.wait([serverDone.future, serverEndDone.future, clientEndDone.future])
25 .then((_) { 24 .then((_) {
26 port.close(); 25 port.close();
27 }); 26 });
28 SecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) { 27 SecureServerSocket.bind(HOST_NAME, 0, 5, CERTIFICATE).then((server) {
29 server.listen((serverConnection) { 28 server.listen((serverConnection) {
30 serverConnection.listen( 29 serverConnection.listen(
31 (data) { 30 (data) {
32 Expect.fail("No data should be received by server"); 31 Expect.fail("No data should be received by server");
33 }, 32 },
34 onDone: () { 33 onDone: () {
35 serverConnection.close(); 34 serverConnection.close();
36 serverEndDone.complete(null); 35 serverEndDone.complete(null);
37 server.close(); 36 server.close();
38 }); 37 });
(...skipping 15 matching lines...) Expand all
54 }); 53 });
55 if (toClose == "client") { 54 if (toClose == "client") {
56 clientConnection.close(); 55 clientConnection.close();
57 } 56 }
58 }); 57 });
59 }); 58 });
60 } 59 }
61 60
62 void testCloseBothEnds() { 61 void testCloseBothEnds() {
63 ReceivePort port = new ReceivePort(); 62 ReceivePort port = new ReceivePort();
64 SecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) { 63 SecureServerSocket.bind(HOST_NAME, 0, 5, CERTIFICATE).then((server) {
65 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port); 64 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port);
66 server.listen((serverEnd) { 65 server.listen((serverEnd) {
67 clientEndFuture.then((clientEnd) { 66 clientEndFuture.then((clientEnd) {
68 clientEnd.destroy(); 67 clientEnd.destroy();
69 serverEnd.destroy(); 68 serverEnd.destroy();
70 server.close(); 69 server.close();
71 port.close(); 70 port.close();
72 }); 71 });
73 }); 72 });
74 }); 73 });
75 } 74 }
76 75
77 testPauseServerSocket() { 76 testPauseServerSocket() {
78 const int socketCount = 10; 77 const int socketCount = 10;
79 var acceptCount = 0; 78 var acceptCount = 0;
80 var resumed = false; 79 var resumed = false;
81 80
82 ReceivePort port = new ReceivePort(); 81 ReceivePort port = new ReceivePort();
83 82
84 SecureServerSocket.bind(SERVER_ADDRESS, 83 SecureServerSocket.bind(HOST_NAME,
85 0, 84 0,
86 2 * socketCount, 85 2 * socketCount,
87 CERTIFICATE).then((server) { 86 CERTIFICATE).then((server) {
88 Expect.isTrue(server.port > 0); 87 Expect.isTrue(server.port > 0);
89 var subscription; 88 var subscription;
90 subscription = server.listen((connection) { 89 subscription = server.listen((connection) {
91 Expect.isTrue(resumed); 90 Expect.isTrue(resumed);
92 connection.close(); 91 connection.close();
93 if (++acceptCount == 2 * socketCount) { 92 if (++acceptCount == 2 * socketCount) {
94 server.close(); 93 server.close();
(...skipping 23 matching lines...) Expand all
118 }); 117 });
119 } 118 }
120 119
121 120
122 testCloseServer() { 121 testCloseServer() {
123 const int socketCount = 3; 122 const int socketCount = 3;
124 var endCount = 0; 123 var endCount = 0;
125 ReceivePort port = new ReceivePort(); 124 ReceivePort port = new ReceivePort();
126 List ends = []; 125 List ends = [];
127 126
128 SecureServerSocket.bind(SERVER_ADDRESS, 0, 15, CERTIFICATE).then((server) { 127 SecureServerSocket.bind(HOST_NAME, 0, 15, CERTIFICATE).then((server) {
129 Expect.isTrue(server.port > 0); 128 Expect.isTrue(server.port > 0);
130 void checkDone() { 129 void checkDone() {
131 if (ends.length < 2 * socketCount) return; 130 if (ends.length < 2 * socketCount) return;
132 for (var end in ends) { 131 for (var end in ends) {
133 end.destroy(); 132 end.destroy();
134 } 133 }
135 server.close(); 134 server.close();
136 port.close(); 135 port.close();
137 } 136 }
138 137
(...skipping 20 matching lines...) Expand all
159 useBuiltinRoots: false); 158 useBuiltinRoots: false);
160 159
161 testCloseOneEnd("client"); 160 testCloseOneEnd("client");
162 testCloseOneEnd("server"); 161 testCloseOneEnd("server");
163 testCloseBothEnds(); 162 testCloseBothEnds();
164 testPauseServerSocket(); 163 testPauseServerSocket();
165 testCloseServer(); 164 testCloseServer();
166 // TODO(whesse): Add testPauseSocket from raw_socket_test.dart. 165 // TODO(whesse): Add testPauseSocket from raw_socket_test.dart.
167 // TODO(whesse): Add testCancelResubscribeSocket from raw_socket_test.dart. 166 // TODO(whesse): Add testCancelResubscribeSocket from raw_socket_test.dart.
168 } 167 }
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