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

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

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