| Index: tests/standalone/io/web_socket_no_secure_test.dart
|
| diff --git a/tests/standalone/io/web_socket_no_secure_test.dart b/tests/standalone/io/web_socket_no_secure_test.dart
|
| index efb02b9b178a3484d7b3d507dc67700bb281b288..d48b7097320ca6baad2754dc7c21ccc99b6bb672 100644
|
| --- a/tests/standalone/io/web_socket_no_secure_test.dart
|
| +++ b/tests/standalone/io/web_socket_no_secure_test.dart
|
| @@ -18,9 +18,9 @@ const HOST_NAME = "localhost";
|
| // We will run the tests once over HTTP and once over HTTPS.
|
| bool secure = false;
|
|
|
| -Future testRequestResponseClientCloses(
|
| +void testRequestResponseClientCloses(
|
| int totalConnections, int closeStatus, String closeReason) {
|
| - Completer done = new Completer();
|
| + ReceivePort keepAlive = new ReceivePort();
|
| HttpServer server = secure ? new HttpsServer() : new HttpServer();
|
| HttpClient client = new HttpClient();
|
|
|
| @@ -69,17 +69,16 @@ Future testRequestResponseClientCloses(
|
| if (closeCount == totalConnections) {
|
| client.shutdown();
|
| server.close();
|
| - done.complete(null);
|
| + keepAlive.close();
|
| }
|
| };
|
| }
|
| - return done.future;
|
| }
|
|
|
|
|
| -Future testRequestResponseServerCloses(
|
| +void testRequestResponseServerCloses(
|
| int totalConnections, int closeStatus, String closeReason) {
|
| - Completer done = new Completer();
|
| + ReceivePort keepAlive = new ReceivePort();
|
| HttpServer server = secure ? new HttpsServer() : new HttpServer();
|
| HttpClient client = new HttpClient();
|
|
|
| @@ -113,7 +112,7 @@ Future testRequestResponseServerCloses(
|
| if (closeCount == totalConnections) {
|
| client.shutdown();
|
| server.close();
|
| - done.complete(null);
|
| + keepAlive.close();
|
| }
|
| };
|
| conn.send(messageText);
|
| @@ -132,12 +131,11 @@ Future testRequestResponseServerCloses(
|
| Expect.equals(closeReason == null ? "" : closeReason, reason);
|
| };
|
| }
|
| - return done.future;
|
| }
|
|
|
|
|
| -Future testMessageLength(int messageLength) {
|
| - Completer done = new Completer();
|
| +void testMessageLength(int messageLength) {
|
| + ReceivePort keepAlive = new ReceivePort();
|
| HttpServer server = secure ? new HttpsServer() : new HttpServer();
|
| HttpClient client = new HttpClient();
|
| bool serverReceivedMessage = false;
|
| @@ -176,17 +174,16 @@ Future testMessageLength(int messageLength) {
|
| Expect.isTrue(clientReceivedMessage);
|
| client.shutdown();
|
| server.close();
|
| - done.complete(null);
|
| + keepAlive.close();
|
| };
|
| wsconn.onOpen = () {
|
| wsconn.send(originalMessage);
|
| };
|
| - return done.future;
|
| }
|
|
|
|
|
| -Future testNoUpgrade() {
|
| - Completer done = new Completer();
|
| +void testNoUpgrade() {
|
| + ReceivePort keepAlive = new ReceivePort();
|
| HttpServer server = secure ? new HttpsServer() : new HttpServer();
|
| HttpClient client = new HttpClient();
|
|
|
| @@ -209,14 +206,13 @@ Future testNoUpgrade() {
|
| Expect.equals(HttpStatus.MOVED_PERMANENTLY, response.statusCode);
|
| client.shutdown();
|
| server.close();
|
| - done.complete(null);
|
| + keepAlive.close();
|
| };
|
| - return done.future;
|
| }
|
|
|
|
|
| -Future testUsePOST() {
|
| - Completer done = new Completer();
|
| +void testUsePOST() {
|
| + ReceivePort keepAlive = new ReceivePort();
|
| HttpServer server = secure ? new HttpsServer() : new HttpServer();
|
| HttpClient client = new HttpClient();
|
|
|
| @@ -241,9 +237,8 @@ Future testUsePOST() {
|
| Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode);
|
| client.shutdown();
|
| server.close();
|
| - done.complete(null);
|
| + keepAlive.close();
|
| };
|
| - return done.future;
|
| }
|
|
|
|
|
| @@ -252,8 +247,8 @@ class WebSocketInfo {
|
| }
|
|
|
|
|
| -Future testHashCode(int totalConnections) {
|
| - Completer done = new Completer();
|
| +void testHashCode(int totalConnections) {
|
| + ReceivePort keepAlive = new ReceivePort();
|
| HttpServer server = secure ? new HttpsServer() : new HttpServer();
|
| HttpClient client = new HttpClient();
|
| Map connections = new Map();
|
| @@ -291,7 +286,7 @@ Future testHashCode(int totalConnections) {
|
| if (closeCount == totalConnections) {
|
| client.shutdown();
|
| server.close();
|
| - done.complete();
|
| + keepAlive.close();
|
| }
|
| };
|
| conn.send(messageText);
|
| @@ -304,12 +299,12 @@ Future testHashCode(int totalConnections) {
|
| WebSocketClientConnection wsconn = new WebSocketClientConnection(conn);
|
| wsconn.onMessage = (message) => wsconn.send(message);
|
| }
|
| - return done.future;
|
| }
|
|
|
|
|
| -Future testW3CInterface(
|
| +void testW3CInterface(
|
| int totalConnections, int closeStatus, String closeReason) {
|
| + ReceivePort keepAlive = new ReceivePort();
|
| List<Future> tasks = [];
|
| HttpServer server = secure ? new HttpsServer() : new HttpServer();
|
|
|
| @@ -389,7 +384,9 @@ Future testW3CInterface(
|
| for (int i = 0; i < totalConnections; i++) {
|
| webSocketConnection();
|
| }
|
| - return Future.wait(tasks);
|
| + Future.wait(tasks).then((_) {
|
| + keepAlive.close();
|
| + });
|
| }
|
|
|
|
|
| @@ -401,27 +398,28 @@ void InitializeSSL() {
|
| }
|
|
|
|
|
| -Future runTests() =>
|
| - testRequestResponseClientCloses(2, null, null).then((_) =>
|
| - testRequestResponseClientCloses(2, 3001, null)).then((_) =>
|
| - testRequestResponseClientCloses(2, 3002, "Got tired")).then((_) =>
|
| - testRequestResponseServerCloses(2, null, null)).then((_) =>
|
| - testRequestResponseServerCloses(2, 3001, null)).then((_) =>
|
| - testRequestResponseServerCloses(2, 3002, "Got tired")).then((_) =>
|
| - testMessageLength(125)).then((_) =>
|
| - testMessageLength(126)).then((_) =>
|
| - testMessageLength(127)).then((_) =>
|
| - testMessageLength(65535)).then((_) =>
|
| - testMessageLength(65536)).then((_) =>
|
| - testNoUpgrade()).then((_) =>
|
| - testUsePOST()).then((_) =>
|
| - testHashCode(2)).then((_) =>
|
| - testW3CInterface(2, 3002, "Got tired"));
|
| +/**
|
| + * Run all the tests in parallel, complete when the last one finishes.
|
| + */
|
| +runTests() {
|
| + testRequestResponseClientCloses(2, null, null);
|
| + testRequestResponseClientCloses(2, 3001, null);
|
| + testRequestResponseClientCloses(2, 3002, "Got tired");
|
| + testRequestResponseServerCloses(2, null, null);
|
| + testRequestResponseServerCloses(2, 3001, null);
|
| + testRequestResponseServerCloses(2, 3002, "Got tired");
|
| + testMessageLength(125);
|
| + testMessageLength(126);
|
| + testMessageLength(127);
|
| + testMessageLength(65535);
|
| + testMessageLength(65536);
|
| + testNoUpgrade();
|
| + testUsePOST();
|
| + testHashCode(2);
|
| + testW3CInterface(2, 3002, "Got tired");
|
| +}
|
|
|
|
|
| main() {
|
| - ReceivePort keepAlive = new ReceivePort();
|
| - runTests().then((_) {
|
| - keepAlive.close();
|
| - });
|
| + runTests();
|
| }
|
|
|