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

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

Issue 19596008: Implement correct back-throttleing for web-sockets. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment 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
index 29fec923d550e218b1352ca17c626536d6d060d8..248facf1fb78adda60bda01c12d4f385a71982c9 100644
--- a/tests/standalone/io/web_socket_ping_test.dart
+++ b/tests/standalone/io/web_socket_ping_test.dart
@@ -14,24 +14,37 @@ import "dart:io";
void testPing(int totalConnections) {
HttpServer.bind('localhost', 0).then((server) {
+ // The completers will be completed when the pingInterval have terminated
+ // the webSockets.
+ var completers = new List.generate(
+ totalConnections, (_) => new Completer());
+
+ int conns = 0;
server.transform(new WebSocketTransformer()).listen((webSocket) {
- webSocket.pingInterval = const Duration(milliseconds: 500);
+ int i = conns++;
+ webSocket.pingInterval = const Duration(milliseconds: 100);
webSocket.drain();
+ var timer = new Timer.periodic(const Duration(milliseconds: 10), (_) {
+ webSocket.add(new List.filled(10 * 1024, 0));
+ });
+ webSocket.done.then((_) {
+ completers[i].complete();
+ timer.cancel();
+ Expect.equals(WebSocketStatus.GOING_AWAY, webSocket.closeCode);
+ webSocket.close();
+ });
});
var futures = [];
for (int i = 0; i < totalConnections; i++) {
futures.add(
- WebSocket.connect('ws://localhost:${server.port}').then((webSocket) {
- webSocket.pingInterval = const Duration(milliseconds: 500);
- webSocket.drain();
- new Timer(const Duration(seconds: 2), () {
- // Should not be closed yet.
- Expect.equals(null, webSocket.closeCode);
- webSocket.close();
- });
- return webSocket.done;
- }));
+ WebSocket.connect('ws://localhost:${server.port}')
+ .then((webSocket) {
+ // Don't drain yet, to block data.
+ // Once the server is done, drain the peers.
+ return Future.wait(completers.map((c) => c.future))
+ .then((_) => webSocket.drain());
+ }));
}
Future.wait(futures).then((_) => server.close());
});
« 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