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

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

Issue 19970004: Add ability to send a ping interval on a WebSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment and add missing test. Created 7 years, 5 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 | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « sdk/lib/io/websocket_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698