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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: tests/isolate/timer_repeat_test.dart
diff --git a/tests/isolate/timer_repeat_test.dart b/tests/isolate/timer_repeat_test.dart
index f65b1e18f9e723e3c32215c99abbe74011181fcb..53a83ce1efa11c548b970b50e5696190783242c1 100644
--- a/tests/isolate/timer_repeat_test.dart
+++ b/tests/isolate/timer_repeat_test.dart
@@ -5,39 +5,30 @@
#library('timer_repeat_test');
#import("dart:isolate");
-
-class TimerRepeatTest {
-
- static const int _TIMEOUT = 500;
- static const int _ITERATIONS = 5;
-
- static void testRepeatTimer() {
-
- void timeoutHandler(Timer timer) {
- int endTime = (new Date.now()).millisecondsSinceEpoch;
- _iteration++;
- if (_iteration < _ITERATIONS) {
- _startTime = (new Date.now()).millisecondsSinceEpoch;
- } else {
- Expect.equals(_iteration, _ITERATIONS);
- timer.cancel();
- }
+#import('../../pkg/unittest/unittest.dart');
+
+ const int _TIMEOUT = 500;
+ const int _ITERATIONS = 5;
+
+ Timer timer;
+ int _startTime;
+ int _iteration;
+
+ void timeoutHandler(Timer timer) {
+ int endTime = (new Date.now()).millisecondsSinceEpoch;
+ _iteration++;
+ if (_iteration < _ITERATIONS) {
+ _startTime = (new Date.now()).millisecondsSinceEpoch;
+ } else {
+ expect(_iteration, _ITERATIONS);
+ timer.cancel();
}
-
- _iteration = 0;
- _startTime = (new Date.now()).millisecondsSinceEpoch;
- timer = new Timer.repeating(_TIMEOUT, timeoutHandler);
}
- static void testMain() {
- testRepeatTimer();
- }
-
- static Timer timer;
- static int _startTime;
- static int _iteration;
-}
-
main() {
- TimerRepeatTest.testMain();
+ test("timer_repeat", () {
+ _iteration = 0;
+ _startTime = (new Date.now()).millisecondsSinceEpoch;
+ timer = new Timer.repeating(_TIMEOUT, expectAsync1(timeoutHandler, count: _ITERATIONS));
Siggi Cherem (dart-lang) 2012/10/08 21:50:07 80 col
justinfagnani 2012/10/08 22:12:48 Done.
+ });
}

Powered by Google App Engine
This is Rietveld 408576698