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

Unified Diff: tests/standalone/io/secure_client_raw_server_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_client_raw_server_test.dart
diff --git a/tests/standalone/io/secure_client_raw_server_test.dart b/tests/standalone/io/secure_client_raw_server_test.dart
index 9d40baf72981d7a74ca01a7b01ed94c0a2595bd9..e380f753d0494c74ccdb5aed1277549a097d146a 100644
--- a/tests/standalone/io/secure_client_raw_server_test.dart
+++ b/tests/standalone/io/secure_client_raw_server_test.dart
@@ -7,16 +7,16 @@
// 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:async_helper/async_helper.dart";
+import "package:expect/expect.dart";
+
+InternetAddress HOST;
const CERTIFICATE = "localhost_cert";
Future<RawSecureServerSocket> startEchoServer() {
- return RawSecureServerSocket.bind(HOST_NAME,
+ return RawSecureServerSocket.bind(HOST,
0,
CERTIFICATE).then((server) {
server.listen((RawSecureSocket client) {
@@ -60,7 +60,7 @@ Future<RawSecureServerSocket> startEchoServer() {
Future testClient(server) {
Completer success = new Completer();
List<String> chunks = <String>[];
- SecureSocket.connect(HOST_NAME, server.port).then((socket) {
+ SecureSocket.connect(HOST, server.port).then((socket) {
socket.write("Hello server.");
socket.close();
socket.listen(
@@ -78,13 +78,13 @@ Future testClient(server) {
}
void main() {
+ asyncStart();
String certificateDatabase = Platform.script.resolve('pkcert').toFilePath();
SecureSocket.initialize(database: certificateDatabase,
password: 'dartdart');
-
- startEchoServer()
+ InternetAddress.lookup("localhost").then((hosts) => HOST = hosts.first)
+ .then((_) => startEchoServer())
.then(testClient)
- .then((server) {
- server.close();
- });
+ .then((server) => server.close())
+ .then((_) => asyncEnd());
}
« no previous file with comments | « tests/standalone/io/raw_secure_server_socket_test.dart ('k') | tests/standalone/io/secure_client_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698