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

Unified Diff: tests/standalone/io/secure_session_resume_test.dart

Issue 201993002: Fix SecureSocket tests to look up localhost only once, where possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove useless change to https_client_certificate_test.dart Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/secure_session_resume_test.dart
diff --git a/tests/standalone/io/secure_session_resume_test.dart b/tests/standalone/io/secure_session_resume_test.dart
index 83acd3e1fff4de9d2450a4501d0095c27176e4ed..5b8a3a3761468a9323b5e19b751037431b1639b5 100644
--- a/tests/standalone/io/secure_session_resume_test.dart
+++ b/tests/standalone/io/secure_session_resume_test.dart
@@ -16,16 +16,17 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
-import "package:expect/expect.dart";
-import "package:path/path.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
-const HOST_NAME = "localhost";
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+InternetAddress HOST;
const CERTIFICATE = "localhost_cert";
Future<SecureServerSocket> startServer() {
- return SecureServerSocket.bind(HOST_NAME,
+ return SecureServerSocket.bind(HOST,
0,
CERTIFICATE).then((server) {
server.listen((SecureSocket client) {
@@ -43,7 +44,7 @@ Future<SecureServerSocket> startServer() {
}
Future testClient(server, name) {
- return SecureSocket.connect(HOST_NAME, server.port).then((socket) {
+ return SecureSocket.connect(HOST, server.port).then((socket) {
socket.write("Hello from client $name");
socket.close();
return socket.fold(<int>[], (message, data) => message..addAll(data))
@@ -55,14 +56,20 @@ Future testClient(server, name) {
}
void main() {
+ asyncStart();
String certificateDatabase = Platform.script.resolve('pkcert').toFilePath();
SecureSocket.initialize(database: certificateDatabase,
password: 'dartdart');
+ InternetAddress.lookup("localhost").then((hosts) {
+ HOST = hosts.first;
+ runTests().then((_) => asyncEnd());
+ });
+}
+Future runTests() {
Duration delay = const Duration(milliseconds: 0);
Duration delay_between_connections = const Duration(milliseconds: 300);
-
- startServer()
+ return startServer()
.then((server) => Future.wait(
['able', 'baker', 'charlie', 'dozen', 'elapse']
.map((name) {
« no previous file with comments | « tests/standalone/io/secure_server_socket_test.dart ('k') | tests/standalone/io/secure_socket_bad_data_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698