Chromium Code Reviews| 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..37896e1b7dc3b899b60d8127f737aee3b341ef83 |
| --- /dev/null |
| +++ b/tests/standalone/io/web_socket_ping_test.dart |
| @@ -0,0 +1,42 @@ |
| +// 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) { |
|
Søren Gjesse
2013/07/24 12:31:28
Set a pingInterval on the server side as well.
Anders Johnsen
2013/07/24 12:51:02
Done.
|
| + 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: 200); |
| + 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); |
| +} |