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

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

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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
« no previous file with comments | « tests/standalone/io/https_client_test.dart ('k') | tests/standalone/io/list_input_stream_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/https_server_test.dart
diff --git a/tests/standalone/io/https_server_test.dart b/tests/standalone/io/https_server_test.dart
index 1da88543520bad45e6e666ac41d9f556f14db554..e4e86e8043725e76174db6989549d1c67f530f48 100644
--- a/tests/standalone/io/https_server_test.dart
+++ b/tests/standalone/io/https_server_test.dart
@@ -11,52 +11,46 @@ const HOST_NAME = "localhost";
void testListenOn() {
void test(void onDone()) {
- HttpsServer server = new HttpsServer();
- Expect.throws(() => server.port);
-
- ReceivePort serverPort = new ReceivePort();
- server.defaultRequestHandler =
- (HttpRequest request, HttpResponse response) {
- request.inputStream.onClosed = () {
- response.outputStream.close();
+ HttpServer.bindSecure(SERVER_ADDRESS,
+ 0,
+ backlog: 5,
+ certificateName: 'localhost_cert').then((server) {
+ ReceivePort serverPort = new ReceivePort();
+ server.listen((HttpRequest request) {
+ request.listen(
+ (_) { },
+ onDone: () {
+ request.response.close();
serverPort.close();
- };
- };
-
- server.onError = (Exception e) {
- Expect.fail("Unexpected error in Https Server: $e");
- };
-
- server.listen(SERVER_ADDRESS,
- 0,
- backlog: 5,
- certificate_name: 'CN=$HOST_NAME');
+ });
+ });
- HttpClient client = new HttpClient();
- HttpClientConnection conn =
- client.getUrl(Uri.parse("https://$HOST_NAME:${server.port}/"));
- conn.onRequest = (HttpClientRequest request) {
- request.outputStream.close();
- };
- ReceivePort clientPort = new ReceivePort();
- conn.onResponse = (HttpClientResponse response) {
- response.inputStream.onClosed = () {
- client.shutdown();
- clientPort.close();
- server.close();
- Expect.throws(() => server.port);
- onDone();
- };
- };
- conn.onError = (Exception e) {
- Expect.fail("Unexpected error in Https Client: $e");
- };
- };
+ HttpClient client = new HttpClient();
+ ReceivePort clientPort = new ReceivePort();
+ client.getUrl(Uri.parse("https://$HOST_NAME:${server.port}/"))
+ .then((HttpClientRequest request) {
+ return request.close();
+ })
+ .then((HttpClientResponse response) {
+ response.listen(
+ (_) { },
+ onDone: () {
+ client.close();
+ clientPort.close();
+ server.close();
+ Expect.throws(() => server.port);
+ onDone();
+ });
+ })
+ .catchError((error) {
+ Expect.fail("Unexpected error in Https client: $error");
+ });
+ });
+ }
- // Test two connection after each other.
+ // Test two servers in succession.
test(() {
- test(() {
- });
+ test(() { });
});
}
« no previous file with comments | « tests/standalone/io/https_client_test.dart ('k') | tests/standalone/io/list_input_stream_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698