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

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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/isolate/timer_cancel_test.dart ('k') | tests/isolate/timer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..96be94d0877f0129101269e48c7db72605f9a340 100644
--- a/tests/isolate/timer_repeat_test.dart
+++ b/tests/isolate/timer_repeat_test.dart
@@ -5,39 +5,31 @@
#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));
+ });
}
« 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