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

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

Issue 23886004: Update dart:io tests to use asyncStart/asyncEnd (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 "dart:async";
11 import "dart:io";
12
13 import "package:async_helper/async_helper.dart";
10 import "package:expect/expect.dart"; 14 import "package:expect/expect.dart";
11 import "package:path/path.dart"; 15 import "package:path/path.dart";
12 import "dart:async";
13 import "dart:io";
14 import "dart:isolate";
15 16
16 const HOST_NAME = "localhost"; 17 const HOST_NAME = "localhost";
17 const CERTIFICATE = "localhost_cert"; 18 const CERTIFICATE = "localhost_cert";
18 19
19 // This test creates a server and a client connects. After connecting 20 // This test creates a server and a client connects. After connecting
20 // and an optional initial handshake the connection is secured by 21 // and an optional initial handshake the connection is secured by
21 // upgrading to a secure connection The client then writes and the 22 // upgrading to a secure connection The client then writes and the
22 // server echos. When the server has finished its echo it 23 // server echos. When the server has finished its echo it
23 // half-closes. When the client gets the close event is closes fully. 24 // half-closes. When the client gets the close event is closes fully.
24 // 25 //
25 // The test can be run in different configurations based on 26 // The test can be run in different configurations based on
26 // the boolean arguments: 27 // the boolean arguments:
27 // 28 //
28 // handshakeBeforeSecure 29 // handshakeBeforeSecure
29 // When this argument is true some initial clear text handshake is done 30 // When this argument is true some initial clear text handshake is done
30 // between client and server before the connection is secured. This argument 31 // between client and server before the connection is secured. This argument
31 // only makes sense when both listenSecure and connectSecure are false. 32 // only makes sense when both listenSecure and connectSecure are false.
32 // 33 //
33 // postponeSecure 34 // postponeSecure
34 // When this argument is false the securing of the server end will 35 // When this argument is false the securing of the server end will
35 // happen as soon as the last byte of the handshake before securing 36 // happen as soon as the last byte of the handshake before securing
36 // has been written. When this argument is true the securing of the 37 // has been written. When this argument is true the securing of the
37 // server will not happen until the first TLS handshake data has been 38 // server will not happen until the first TLS handshake data has been
38 // received from the client. This argument only takes effect when 39 // received from the client. This argument only takes effect when
39 // handshakeBeforeSecure is true. 40 // handshakeBeforeSecure is true.
40 void test(bool hostnameInConnect, 41 void test(bool hostnameInConnect,
41 bool handshakeBeforeSecure, 42 bool handshakeBeforeSecure,
42 [bool postponeSecure = false]) { 43 [bool postponeSecure = false]) {
43 ReceivePort port = new ReceivePort(); 44 asyncStart();
44 45
45 const messageSize = 1000; 46 const messageSize = 1000;
46 const handshakeMessageSize = 100; 47 const handshakeMessageSize = 100;
47 48
48 List<int> createTestData() { 49 List<int> createTestData() {
49 List<int> data = new List<int>(messageSize); 50 List<int> data = new List<int>(messageSize);
50 for (int i = 0; i < messageSize; i++) { 51 for (int i = 0; i < messageSize; i++) {
51 data[i] = i & 0xff; 52 data[i] = i & 0xff;
52 } 53 }
53 return data; 54 return data;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 CERTIFICATE, 198 CERTIFICATE,
198 bufferedData: carryOverData).then((secureClient) { 199 bufferedData: carryOverData).then((secureClient) {
199 client.add([0]); 200 client.add([0]);
200 runServer(secureClient).then((_) => server.close()); 201 runServer(secureClient).then((_) => server.close());
201 }); 202 });
202 }); 203 });
203 } 204 }
204 }); 205 });
205 206
206 connectClient(server.port).then(runClient).then((socket) { 207 connectClient(server.port).then(runClient).then((socket) {
207 port.close(); 208 asyncEnd();
208 }); 209 });
209 } 210 }
210 211
211 ServerSocket.bind(HOST_NAME, 0).then(serverReady); 212 ServerSocket.bind(HOST_NAME, 0).then(serverReady);
212 } 213 }
213 214
214 main() { 215 main() {
215 var certificateDatabase = join(dirname(Platform.script), 'pkcert'); 216 var certificateDatabase = join(dirname(Platform.script), 'pkcert');
216 SecureSocket.initialize(database: certificateDatabase, 217 SecureSocket.initialize(database: certificateDatabase,
217 password: 'dartdart', 218 password: 'dartdart',
218 useBuiltinRoots: false); 219 useBuiltinRoots: false);
219 test(false, false); 220 test(false, false);
220 test(true, false); 221 test(true, false);
221 test(false, true); 222 test(false, true);
222 test(true, true); 223 test(true, true);
223 test(false, true, true); 224 test(false, true, true);
224 test(true, true, true); 225 test(true, true, true);
225 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698