| Index: tests/standalone/io/web_socket_ping_test.dart
|
| diff --git a/tests/standalone/io/web_socket_ping_test.dart b/tests/standalone/io/web_socket_ping_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b760644747f15a7f447e5eed5b7687872026da7f
|
| --- /dev/null
|
| +++ b/tests/standalone/io/web_socket_ping_test.dart
|
| @@ -0,0 +1,43 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +//
|
| +// VMOptions=
|
| +// VMOptions=--short_socket_read
|
| +// VMOptions=--short_socket_write
|
| +// VMOptions=--short_socket_read --short_socket_write
|
| +
|
| +import "package:expect/expect.dart";
|
| +import "dart:async";
|
| +import "dart:io";
|
| +
|
| +
|
| +void testPing(int totalConnections) {
|
| + HttpServer.bind('localhost', 0).then((server) {
|
| + server.transform(new WebSocketTransformer()).listen((webSocket) {
|
| + webSocket.pingInterval = const Duration(milliseconds: 100);
|
| + webSocket.drain();
|
| + });
|
| +
|
| + var futures = [];
|
| + for (int i = 0; i < totalConnections; i++) {
|
| + futures.add(
|
| + WebSocket.connect('ws://localhost:${server.port}').then((webSocket) {
|
| + webSocket.pingInterval = const Duration(milliseconds: 100);
|
| + webSocket.drain();
|
| + new Timer(const Duration(seconds: 1), () {
|
| + // Should not be closed yet.
|
| + Expect.equals(null, webSocket.closeCode);
|
| + webSocket.close();
|
| + });
|
| + return webSocket.done;
|
| + }));
|
| + }
|
| + Future.wait(futures).then((_) => server.close());
|
| + });
|
| +}
|
| +
|
| +
|
| +void main() {
|
| + testPing(10);
|
| +}
|
|
|