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

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

Powered by Google App Engine
This is Rietveld 408576698