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

Side by Side Diff: tests/standalone/src/io/SocketStreamCloseTest.dart

Issue 9597015: Update Timer API to take the callback as the last parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Test socket close events. 10 // Test socket close events.
(...skipping 16 matching lines...) Expand all
27 _errorEvents = 0, 27 _errorEvents = 0,
28 _iterations = 0 { 28 _iterations = 0 {
29 new SocketCloseServer().spawn().then((SendPort port) { 29 new SocketCloseServer().spawn().then((SendPort port) {
30 _sendPort = port; 30 _sendPort = port;
31 start(); 31 start();
32 }); 32 });
33 } 33 }
34 34
35 void proceed() { 35 void proceed() {
36 if (_iterations < ITERATIONS) { 36 if (_iterations < ITERATIONS) {
37 new Timer(sendData, 0); 37 new Timer(0, sendData);
38 } else { 38 } else {
39 shutdown(); 39 shutdown();
40 } 40 }
41 } 41 }
42 42
43 void sendData(Timer timer) { 43 void sendData(Timer timer) {
44 44
45 void dataHandler() { 45 void dataHandler() {
46 switch (_mode) { 46 switch (_mode) {
47 case 0: 47 case 0:
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 Expect.equals(ITERATIONS, _closeEvents); 346 Expect.equals(ITERATIONS, _closeEvents);
347 break; 347 break;
348 default: 348 default:
349 Expect.fail("Unknown test mode"); 349 Expect.fail("Unknown test mode");
350 } 350 }
351 Expect.equals(0, _errorEvents); 351 Expect.equals(0, _errorEvents);
352 _server.close(); 352 _server.close();
353 this.port.close(); 353 this.port.close();
354 _donePort.send(null); 354 _donePort.send(null);
355 } else { 355 } else {
356 new Timer(waitForResult, 100); 356 new Timer(100, waitForResult);
357 } 357 }
358 } 358 }
359 359
360 this.port.receive((message, SendPort replyTo) { 360 this.port.receive((message, SendPort replyTo) {
361 _donePort = replyTo; 361 _donePort = replyTo;
362 if (message != SERVERSHUTDOWN) { 362 if (message != SERVERSHUTDOWN) {
363 _readBytes = 0; 363 _readBytes = 0;
364 _errorEvents = 0; 364 _errorEvents = 0;
365 _dataEvents = 0; 365 _dataEvents = 0;
366 _closeEvents = 0; 366 _closeEvents = 0;
367 _iterations = 0; 367 _iterations = 0;
368 _mode = message; 368 _mode = message;
369 _server = new ServerSocket(HOST, 0, 10); 369 _server = new ServerSocket(HOST, 0, 10);
370 Expect.equals(true, _server !== null); 370 Expect.equals(true, _server !== null);
371 _server.onConnection = (connection) { 371 _server.onConnection = (connection) {
372 var data = new ConnectionData(connection); 372 var data = new ConnectionData(connection);
373 connectionHandler(data); 373 connectionHandler(data);
374 }; 374 };
375 _server.onError = errorHandlerServer; 375 _server.onError = errorHandlerServer;
376 replyTo.send(_server.port, null); 376 replyTo.send(_server.port, null);
377 } else { 377 } else {
378 new Timer(waitForResult, 0); 378 new Timer(0, waitForResult);
379 } 379 }
380 }); 380 });
381 } 381 }
382 382
383 ServerSocket _server; 383 ServerSocket _server;
384 SendPort _donePort; 384 SendPort _donePort;
385 int _readBytes; 385 int _readBytes;
386 int _errorEvents; 386 int _errorEvents;
387 int _dataEvents; 387 int _dataEvents;
388 int _closeEvents; 388 int _closeEvents;
(...skipping 18 matching lines...) Expand all
407 var tests = 9; 407 var tests = 9;
408 var port = new ReceivePort(); 408 var port = new ReceivePort();
409 var completed = 0; 409 var completed = 0;
410 port.receive((message, ignore) { 410 port.receive((message, ignore) {
411 if (++completed == tests) port.close(); 411 if (++completed == tests) port.close();
412 }); 412 });
413 for (var i = 0; i < tests; i++) { 413 for (var i = 0; i < tests; i++) {
414 new SocketClose.start(i, port.toSendPort()); 414 new SocketClose.start(i, port.toSendPort());
415 } 415 }
416 } 416 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/SocketCloseTest.dart ('k') | tests/standalone/src/io/TimerCancel1Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698