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

Unified Diff: tests/isolate/timer_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_repeat_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/timer_test.dart
diff --git a/tests/isolate/timer_test.dart b/tests/isolate/timer_test.dart
index 85399842e4e8dd4eaf785e5108210bc2ba05249a..fd679d35863c99e9d3d9d006cb93ac1f5b75861b 100644
--- a/tests/isolate/timer_test.dart
+++ b/tests/isolate/timer_test.dart
@@ -5,41 +5,32 @@
#library('timer_test');
#import("dart:isolate");
-
-class TimerTest {
-
- static const int _STARTTIMEOUT = 1050;
- static const int _DECREASE = 200;
- static const int _ITERATIONS = 5;
-
- static void testSimpleTimer() {
-
- void timeoutHandler(Timer timer) {
- int endTime = (new Date.now()).millisecondsSinceEpoch;
- Expect.equals(true, (endTime - _startTime) >= _timeout);
- if (_iteration < _ITERATIONS) {
- _iteration++;
- _timeout = _timeout - _DECREASE;
- _startTime = (new Date.now()).millisecondsSinceEpoch;
- new Timer(_timeout, timeoutHandler);
- }
- }
-
- _iteration = 0;
- _timeout = _STARTTIMEOUT;
- _startTime = (new Date.now()).millisecondsSinceEpoch;
- new Timer(_timeout, timeoutHandler);
- }
-
- static void testMain() {
- testSimpleTimer();
+#import('../../pkg/unittest/unittest.dart');
+
+const int STARTTIMEOUT = 1050;
+const int DECREASE = 200;
+const int ITERATIONS = 5;
+
+int startTime;
+int timeout;
+int iteration;
+
+void timeoutHandler(Timer timer) {
+ int endTime = (new Date.now()).millisecondsSinceEpoch;
+ expect((endTime - startTime) >= timeout);
+ if (iteration < ITERATIONS) {
+ iteration++;
+ timeout = timeout - DECREASE;
+ startTime = (new Date.now()).millisecondsSinceEpoch;
+ new Timer(timeout, expectAsync1(timeoutHandler));
}
-
- static int _startTime;
- static int _timeout;
- static int _iteration;
}
main() {
- TimerTest.testMain();
+ test("timeout test", () {
+ iteration = 0;
+ timeout = STARTTIMEOUT;
+ startTime = (new Date.now()).millisecondsSinceEpoch;
+ new Timer(timeout, expectAsync1(timeoutHandler));
+ });
}
« no previous file with comments | « tests/isolate/timer_repeat_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698