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

Side by Side Diff: tests/standalone/io/web_socket_ping_test.dart

Issue 20088002: Make web_socket_ping_test pass on simulators, where it takes > 100ms to send data between sockets(!… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:async"; 11 import "dart:async";
12 import "dart:io"; 12 import "dart:io";
13 13
14 14
15 void testPing(int totalConnections) { 15 void testPing(int totalConnections) {
16 HttpServer.bind('localhost', 0).then((server) { 16 HttpServer.bind('localhost', 0).then((server) {
17 server.transform(new WebSocketTransformer()).listen((webSocket) { 17 server.transform(new WebSocketTransformer()).listen((webSocket) {
18 webSocket.pingInterval = const Duration(milliseconds: 100); 18 webSocket.pingInterval = const Duration(milliseconds: 500);
19 webSocket.drain(); 19 webSocket.drain();
20 }); 20 });
21 21
22 var futures = []; 22 var futures = [];
23 for (int i = 0; i < totalConnections; i++) { 23 for (int i = 0; i < totalConnections; i++) {
24 futures.add( 24 futures.add(
25 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) { 25 WebSocket.connect('ws://localhost:${server.port}').then((webSocket) {
26 webSocket.pingInterval = const Duration(milliseconds: 100); 26 webSocket.pingInterval = const Duration(milliseconds: 500);
27 webSocket.drain(); 27 webSocket.drain();
28 new Timer(const Duration(seconds: 1), () { 28 new Timer(const Duration(seconds: 2), () {
29 // Should not be closed yet. 29 // Should not be closed yet.
30 Expect.equals(null, webSocket.closeCode); 30 Expect.equals(null, webSocket.closeCode);
31 webSocket.close(); 31 webSocket.close();
32 }); 32 });
33 return webSocket.done; 33 return webSocket.done;
34 })); 34 }));
35 } 35 }
36 Future.wait(futures).then((_) => server.close()); 36 Future.wait(futures).then((_) => server.close());
37 }); 37 });
38 } 38 }
39 39
40 40
41 void main() { 41 void main() {
42 testPing(10); 42 testPing(10);
43 } 43 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698