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

Side by Side Diff: tests/standalone/src/TimerRepeatTest.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/TimerCancelTest.dart ('k') | tests/standalone/src/TimerTest.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 class TimerRepeatTest { 5 class TimerRepeatTest {
6 6
7 static final int _TIMEOUT = 500; 7 static final int _TIMEOUT = 500;
8 static final int _ITERATIONS = 5; 8 static final int _ITERATIONS = 5;
9 9
10 static void testRepeatTimer() { 10 static void testRepeatTimer() {
11 11
12 void timeoutHandler(Timer timer) { 12 void timeoutHandler(Timer timer) {
13 int endTime = (new Date.now()).value; 13 int endTime = (new Date.now()).value;
14 _iteration++; 14 _iteration++;
15 if (_iteration < _ITERATIONS) { 15 if (_iteration < _ITERATIONS) {
16 _startTime = (new Date.now()).value; 16 _startTime = (new Date.now()).value;
17 } else { 17 } else {
18 Expect.equals(_iteration, _ITERATIONS); 18 Expect.equals(_iteration, _ITERATIONS);
19 timer.cancel(); 19 timer.cancel();
20 } 20 }
21 } 21 }
22 22
23 _iteration = 0; 23 _iteration = 0;
24 _startTime = (new Date.now()).value; 24 _startTime = (new Date.now()).value;
25 timer = new Timer(timeoutHandler, _TIMEOUT, true); 25 timer = new Timer.repeating(timeoutHandler, _TIMEOUT);
26 } 26 }
27 27
28 static void testMain() { 28 static void testMain() {
29 testRepeatTimer(); 29 testRepeatTimer();
30 } 30 }
31 31
32 static Timer timer; 32 static Timer timer;
33 static int _startTime; 33 static int _startTime;
34 static int _iteration; 34 static int _iteration;
35 } 35 }
36 36
37 main() { 37 main() {
38 TimerRepeatTest.testMain(); 38 TimerRepeatTest.testMain();
39 } 39 }
OLDNEW
« no previous file with comments | « tests/standalone/src/TimerCancelTest.dart ('k') | tests/standalone/src/TimerTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698