Chromium Code Reviews| Index: tests/compiler/dart2js/http_test.dart |
| diff --git a/tests/compiler/dart2js/http_test.dart b/tests/compiler/dart2js/http_test.dart |
| index 29c22007829ca0653e60eb756711e0c189f2577a..2478980c4e28e4a15406d10ec7b118e4546c79f5 100644 |
| --- a/tests/compiler/dart2js/http_test.dart |
| +++ b/tests/compiler/dart2js/http_test.dart |
| @@ -16,9 +16,11 @@ import 'package:expect/expect.dart'; |
| import 'package:path/path.dart' as path; |
| Uri pathOfData = Platform.script.resolve('http_launch_data/'); |
| +Uri pathOfPkcert = pathOfData.resolve('pkcert'); |
| int port; |
| Directory tempDir; |
| String outFilePath; |
| +String scheme; |
| _sendNotFound(HttpResponse response) { |
| response.statusCode = HttpStatus.NOT_FOUND; |
| @@ -77,8 +79,8 @@ Future testNonHttp() { |
| .then((_) { cleanup(); }); |
| } |
| -Future testHttp() { |
| - String inFilePath = 'http://127.0.0.1:$port/http_launch_main.dart'; |
| +Future testHttpMain() { |
| + String inFilePath = '$scheme://127.0.0.1:$port/http_launch_main.dart'; |
|
Bill Hesse
2014/09/11 08:08:40
The only uses of scheme and port are in the expres
floitsch
2014/09/11 13:37:40
Done.
|
| List<String> args = [inFilePath, "--out=" + outFilePath]; |
| return launchDart2Js(args) |
| .then(check) |
| @@ -88,7 +90,7 @@ Future testHttp() { |
| Future testHttpLib() { |
| File file = new File(path.join(tempDir.path, "in.dart")); |
| file.writeAsStringSync(""" |
| - import 'http://127.0.0.1:$port/lib1.dart'; |
| + import '$scheme://127.0.0.1:$port/lib1.dart'; |
| main() { print(foo()); } |
| """); |
| String inFilePath = file.path; |
| @@ -102,7 +104,7 @@ Future testHttpLib() { |
| Future testHttpPackage() { |
| String inFilePath = |
| pathOfData.resolve('http_launch_main_package.dart').toFilePath(); |
| - String packageRoot = 'http://127.0.0.1:$port/packages/'; |
| + String packageRoot = '$scheme://127.0.0.1:$port/packages/'; |
| List<String> args = [inFilePath, |
| "--out=" + outFilePath, |
| "--package-root=" + packageRoot]; |
| @@ -114,7 +116,7 @@ Future testHttpPackage() { |
| Future testBadHttp() { |
| File file = new File(path.join(tempDir.path, "in_bad.dart")); |
| file.writeAsStringSync(""" |
| - import 'http://127.0.0.1:$port/not_existing.dart'; |
| + import '$scheme://127.0.0.1:$port/not_existing.dart'; |
| main() { print(foo()); } |
| """); |
| String inFilePath = file.path; |
| @@ -126,7 +128,7 @@ Future testBadHttp() { |
| } |
| Future testBadHttp2() { |
| - String inFilePath = 'http://127.0.0.1:$port/not_found.dart'; |
| + String inFilePath = '$scheme://127.0.0.1:$port/not_found.dart'; |
| List<String> args = [inFilePath, "--out=" + outFilePath]; |
| return launchDart2Js(args) |
| .then((processResult) => checkNotFound(processResult, "not_found.dart")) |
| @@ -140,10 +142,10 @@ serverRunning(HttpServer server) { |
| asyncStart(); |
| server.listen(handleRequest); |
| - new Future.value() |
| + return new Future.value() |
|
Bill Hesse
2014/09/11 08:08:40
You could make the tests return their input, and s
floitsch
2014/09/11 13:37:40
I don't like to return things that don't make sens
|
| .then((_) => cleanup()) // Make sure we start fresh. |
| .then((_) => testNonHttp()) |
| - .then((_) => testHttp()) |
| + .then((_) => testHttpMain()) |
| .then((_) => testHttpLib()) |
| .then((_) => testHttpPackage()) |
| .then((_) => testBadHttp()) |
| @@ -153,6 +155,29 @@ serverRunning(HttpServer server) { |
| .then((_) => asyncEnd()); |
| } |
| +Future testHttp() { |
| + scheme = "http"; |
| + return HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0).then(serverRunning); |
| +} |
| + |
| +void initializeSSL() { |
| + String testPkcertDatabase = pathOfPkcert.toFilePath(); |
| + SecureSocket.initialize(database: testPkcertDatabase, |
| + password: 'dartdart'); |
| +} |
| + |
| +Future testHttps() { |
| + initializeSSL(); |
| + scheme = "https"; |
| + return HttpServer.bindSecure(InternetAddress.LOOPBACK_IP_V4, |
| + 0, |
| + certificateName: 'localhost_cert') |
| + .then(serverRunning); |
| +} |
| + |
| main() { |
| - HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0).then(serverRunning); |
| + asyncStart(); |
| + testHttp() |
| + .then((_) => testHttps) |
| + .whenComplete(asyncEnd); |
| } |