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

Side by Side Diff: tests/standalone/src/SocketCloseTest.dart

Issue 8992007: Make the repeating argument to timers optional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 9 years 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 | « tests/standalone/src/MultipleTimerTest.dart ('k') | tests/standalone/src/TimerCancel1Test.dart » ('j') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Test socket close events. 5 // Test socket close events.
6 6
7 7
8 final SERVERSHUTDOWN = -1; 8 final SERVERSHUTDOWN = -1;
9 final ITERATIONS = 10; 9 final ITERATIONS = 10;
10 10
(...skipping 30 matching lines...) Expand all
41 _iterations = 0, 41 _iterations = 0,
42 _mode = mode { 42 _mode = mode {
43 new SocketCloseServer().spawn().then((SendPort port) { 43 new SocketCloseServer().spawn().then((SendPort port) {
44 _sendPort = port; 44 _sendPort = port;
45 start(); 45 start();
46 }); 46 });
47 } 47 }
48 48
49 void proceed() { 49 void proceed() {
50 if (_iterations < ITERATIONS) { 50 if (_iterations < ITERATIONS) {
51 new Timer(sendData, 0, false); 51 new Timer(sendData, 0);
52 } else { 52 } else {
53 shutdown(); 53 shutdown();
54 } 54 }
55 } 55 }
56 56
57 void sendData(Timer timer) { 57 void sendData(Timer timer) {
58 58
59 void dataHandler() { 59 void dataHandler() {
60 switch (_mode) { 60 switch (_mode) {
61 case 0: 61 case 0:
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 Expect.equals(ITERATIONS, _dataEvents); 298 Expect.equals(ITERATIONS, _dataEvents);
299 Expect.equals(ITERATIONS, _closeEvents); 299 Expect.equals(ITERATIONS, _closeEvents);
300 break; 300 break;
301 default: 301 default:
302 Expect.fail("Unknown test mode"); 302 Expect.fail("Unknown test mode");
303 } 303 }
304 Expect.equals(0, _errorEvents); 304 Expect.equals(0, _errorEvents);
305 _server.close(); 305 _server.close();
306 this.port.close(); 306 this.port.close();
307 } else { 307 } else {
308 new Timer(waitForResult, 100, false); 308 new Timer(waitForResult, 100);
309 } 309 }
310 } 310 }
311 311
312 this.port.receive((message, SendPort replyTo) { 312 this.port.receive((message, SendPort replyTo) {
313 if (message != SERVERSHUTDOWN) { 313 if (message != SERVERSHUTDOWN) {
314 _errorEvents = 0; 314 _errorEvents = 0;
315 _dataEvents = 0; 315 _dataEvents = 0;
316 _closeEvents = 0; 316 _closeEvents = 0;
317 _iterations = 0; 317 _iterations = 0;
318 _mode = message; 318 _mode = message;
319 _server = new ServerSocket(HOST, 0, 10); 319 _server = new ServerSocket(HOST, 0, 10);
320 Expect.equals(true, _server !== null); 320 Expect.equals(true, _server !== null);
321 _server.connectionHandler = connectionHandler; 321 _server.connectionHandler = connectionHandler;
322 _server.errorHandler = errorHandlerServer; 322 _server.errorHandler = errorHandlerServer;
323 replyTo.send(_server.port, null); 323 replyTo.send(_server.port, null);
324 } else { 324 } else {
325 new Timer(waitForResult, 0, false); 325 new Timer(waitForResult, 0);
326 } 326 }
327 }); 327 });
328 } 328 }
329 329
330 ServerSocket _server; 330 ServerSocket _server;
331 int _errorEvents; 331 int _errorEvents;
332 int _dataEvents; 332 int _dataEvents;
333 int _closeEvents; 333 int _closeEvents;
334 int _iterations; 334 int _iterations;
335 int _mode; 335 int _mode;
336 } 336 }
337 337
338 338
339 main() { 339 main() {
340 SocketCloseTest.testMain(); 340 SocketCloseTest.testMain();
341 } 341 }
OLDNEW
« no previous file with comments | « tests/standalone/src/MultipleTimerTest.dart ('k') | tests/standalone/src/TimerCancel1Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698