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

Unified Diff: tests/isolate/timer_cancel_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_cancel2_test.dart ('k') | tests/isolate/timer_repeat_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/timer_cancel_test.dart
diff --git a/tests/isolate/timer_cancel_test.dart b/tests/isolate/timer_cancel_test.dart
index 408b2ac7bd902cf60cc643e8f2b3abec597ea1bc..7e350622d0b35119732f27ea4e044814eafcb6d6 100644
--- a/tests/isolate/timer_cancel_test.dart
+++ b/tests/isolate/timer_cancel_test.dart
@@ -5,40 +5,38 @@
#library('timer_cancel_test');
#import("dart:isolate");
+#import('../../pkg/unittest/unittest.dart');
-void testSimpleTimer() {
- Timer cancelTimer;
- int repeatTimer;
-
- void timeoutHandlerUnreachable(Timer timer) {
- Expect.equals(true, false);
- }
-
- void timeoutHandler(Timer timer) {
- cancelTimer.cancel();
- }
+main() {
+ test("simple timer", () {
+ Timer cancelTimer;
+ int repeatTimer;
- void timeoutHandlerRepeat(Timer timer) {
- repeatTimer++;
- timer.cancel();
- Expect.equals(true, repeatTimer == 1);
- }
+ void unreachable(Timer timer) {
+ fail("should not be reached");
+ }
- cancelTimer = new Timer(1000, timeoutHandlerUnreachable);
- cancelTimer.cancel();
- new Timer(1000, timeoutHandler);
- cancelTimer = new Timer(2000, timeoutHandlerUnreachable);
- repeatTimer = 0;
- new Timer.repeating(1500, timeoutHandlerRepeat);
-}
+ void handler(Timer timer) {
+ cancelTimer.cancel();
+ }
-void testCancelTimerWithSameTime() {
- var t2;
- var t1 = new Timer(0, (t) => t2.cancel());
- t2 = new Timer(0, (t) => t1.cancel());
-}
+ void repeatHandler(Timer timer) {
+ repeatTimer++;
+ timer.cancel();
+ expect(repeatTimer == 1);
+ }
-main() {
- testSimpleTimer();
- testCancelTimerWithSameTime();
+ cancelTimer = new Timer(1000, expectAsync1(unreachable, count: 0));
+ cancelTimer.cancel();
+ new Timer(1000, expectAsync1(handler));
+ cancelTimer = new Timer(2000, expectAsync1(unreachable, count: 0));
+ repeatTimer = 0;
+ new Timer.repeating(1500, expectAsync1(repeatHandler));
+ });
+
+ test("cancel timer with same time", () {
+ var t2;
+ var t1 = new Timer(0, expectAsync1((t) => t2.cancel()));
+ t2 = new Timer(0, expectAsync1((t) => t1.cancel(), count: 0));
+ });
}
« no previous file with comments | « tests/isolate/timer_cancel2_test.dart ('k') | tests/isolate/timer_repeat_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698