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

Side by Side Diff: tests/standalone/src/io/SocketCloseTest.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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 Expect.equals(ITERATIONS, _closeEvents); 323 Expect.equals(ITERATIONS, _closeEvents);
324 break; 324 break;
325 default: 325 default:
326 Expect.fail("Unknown test mode"); 326 Expect.fail("Unknown test mode");
327 } 327 }
328 Expect.equals(0, _errorEvents); 328 Expect.equals(0, _errorEvents);
329 _server.close(); 329 _server.close();
330 this.port.close(); 330 this.port.close();
331 _donePort.send(null); 331 _donePort.send(null);
332 } else { 332 } else {
333 new Timer(waitForResult, 100); 333 new Timer(100, waitForResult);
334 } 334 }
335 } 335 }
336 336
337 this.port.receive((message, SendPort replyTo) { 337 this.port.receive((message, SendPort replyTo) {
338 _donePort = replyTo; 338 _donePort = replyTo;
339 if (message != SERVERSHUTDOWN) { 339 if (message != SERVERSHUTDOWN) {
340 _readBytes = 0; 340 _readBytes = 0;
341 _errorEvents = 0; 341 _errorEvents = 0;
342 _dataEvents = 0; 342 _dataEvents = 0;
343 _closeEvents = 0; 343 _closeEvents = 0;
344 _iterations = 0; 344 _iterations = 0;
345 _mode = message; 345 _mode = message;
346 _server = new ServerSocket(HOST, 0, 10); 346 _server = new ServerSocket(HOST, 0, 10);
347 Expect.equals(true, _server !== null); 347 Expect.equals(true, _server !== null);
348 _server.onConnection = (connection) { 348 _server.onConnection = (connection) {
349 var data = new ConnectionData(connection); 349 var data = new ConnectionData(connection);
350 connectionHandler(data); 350 connectionHandler(data);
351 }; 351 };
352 _server.onError = errorHandlerServer; 352 _server.onError = errorHandlerServer;
353 replyTo.send(_server.port, null); 353 replyTo.send(_server.port, null);
354 } else { 354 } else {
355 new Timer(waitForResult, 0); 355 new Timer(0, waitForResult);
356 } 356 }
357 }); 357 });
358 } 358 }
359 359
360 ServerSocket _server; 360 ServerSocket _server;
361 SendPort _donePort; 361 SendPort _donePort;
362 int _readBytes; 362 int _readBytes;
363 int _errorEvents; 363 int _errorEvents;
364 int _dataEvents; 364 int _dataEvents;
365 int _closeEvents; 365 int _closeEvents;
(...skipping 14 matching lines...) Expand all
380 var tests = 7; 380 var tests = 7;
381 var port = new ReceivePort(); 381 var port = new ReceivePort();
382 var completed = 0; 382 var completed = 0;
383 port.receive((message, ignore) { 383 port.receive((message, ignore) {
384 if (++completed == tests) port.close(); 384 if (++completed == tests) port.close();
385 }); 385 });
386 for (var i = 0; i < tests; i++) { 386 for (var i = 0; i < tests; i++) {
387 new SocketClose.start(i, port.toSendPort()); 387 new SocketClose.start(i, port.toSendPort());
388 } 388 }
389 } 389 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/MultipleTimerTest.dart ('k') | tests/standalone/src/io/SocketStreamCloseTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698