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

Side by Side Diff: tests/isolate/timer_repeat_test.dart

Issue 11028076: Fix timer tests: timer tests were not using expectAsync to wait for (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mark some tests as flaky in FF Created 8 years, 2 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
« no previous file with comments | « tests/isolate/timer_cancel_test.dart ('k') | tests/isolate/timer_test.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) 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 #library('timer_repeat_test'); 5 #library('timer_repeat_test');
6 6
7 #import("dart:isolate"); 7 #import("dart:isolate");
8 #import('../../pkg/unittest/unittest.dart');
8 9
9 class TimerRepeatTest { 10 const int TIMEOUT = 500;
11 const int ITERATIONS = 5;
10 12
11 static const int _TIMEOUT = 500; 13 Timer timer;
12 static const int _ITERATIONS = 5; 14 int startTime;
13 15 int iteration;
14 static void testRepeatTimer() { 16
15 17 void timeoutHandler(Timer timer) {
16 void timeoutHandler(Timer timer) { 18 int endTime = (new Date.now()).millisecondsSinceEpoch;
17 int endTime = (new Date.now()).millisecondsSinceEpoch; 19 iteration++;
18 _iteration++; 20 if (iteration < ITERATIONS) {
19 if (_iteration < _ITERATIONS) { 21 startTime = (new Date.now()).millisecondsSinceEpoch;
20 _startTime = (new Date.now()).millisecondsSinceEpoch; 22 } else {
21 } else { 23 expect(iteration, ITERATIONS);
22 Expect.equals(_iteration, _ITERATIONS); 24 timer.cancel();
23 timer.cancel();
24 }
25 } 25 }
26
27 _iteration = 0;
28 _startTime = (new Date.now()).millisecondsSinceEpoch;
29 timer = new Timer.repeating(_TIMEOUT, timeoutHandler);
30 } 26 }
31 27
32 static void testMain() { 28 main() {
33 testRepeatTimer(); 29 test("timer_repeat", () {
34 } 30 iteration = 0;
35 31 startTime = new Date.now().millisecondsSinceEpoch;
36 static Timer timer; 32 timer = new Timer.repeating(TIMEOUT,
37 static int _startTime; 33 expectAsync1(timeoutHandler, count: ITERATIONS));
38 static int _iteration; 34 });
39 } 35 }
40
41 main() {
42 TimerRepeatTest.testMain();
43 }
OLDNEW
« no previous file with comments | « tests/isolate/timer_cancel_test.dart ('k') | tests/isolate/timer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698