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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/isolate/timer_cancel2_test.dart ('k') | tests/isolate/timer_repeat_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_cancel_test'); 5 #library('timer_cancel_test');
6 6
7 #import("dart:isolate"); 7 #import("dart:isolate");
8 8 #import('../../pkg/unittest/unittest.dart');
9 void testSimpleTimer() {
10 Timer cancelTimer;
11 int repeatTimer;
12
13 void timeoutHandlerUnreachable(Timer timer) {
14 Expect.equals(true, false);
15 }
16
17 void timeoutHandler(Timer timer) {
18 cancelTimer.cancel();
19 }
20
21 void timeoutHandlerRepeat(Timer timer) {
22 repeatTimer++;
23 timer.cancel();
24 Expect.equals(true, repeatTimer == 1);
25 }
26
27 cancelTimer = new Timer(1000, timeoutHandlerUnreachable);
28 cancelTimer.cancel();
29 new Timer(1000, timeoutHandler);
30 cancelTimer = new Timer(2000, timeoutHandlerUnreachable);
31 repeatTimer = 0;
32 new Timer.repeating(1500, timeoutHandlerRepeat);
33 }
34
35 void testCancelTimerWithSameTime() {
36 var t2;
37 var t1 = new Timer(0, (t) => t2.cancel());
38 t2 = new Timer(0, (t) => t1.cancel());
39 }
40 9
41 main() { 10 main() {
42 testSimpleTimer(); 11 test("simple timer", () {
43 testCancelTimerWithSameTime(); 12 Timer cancelTimer;
13 int repeatTimer;
14
15 void unreachable(Timer timer) {
16 fail("should not be reached");
17 }
18
19 void handler(Timer timer) {
20 cancelTimer.cancel();
21 }
22
23 void repeatHandler(Timer timer) {
24 repeatTimer++;
25 timer.cancel();
26 expect(repeatTimer == 1);
27 }
28
29 cancelTimer = new Timer(1000, expectAsync1(unreachable, count: 0));
30 cancelTimer.cancel();
31 new Timer(1000, expectAsync1(handler));
32 cancelTimer = new Timer(2000, expectAsync1(unreachable, count: 0));
33 repeatTimer = 0;
34 new Timer.repeating(1500, expectAsync1(repeatHandler));
35 });
36
37 test("cancel timer with same time", () {
38 var t2;
39 var t1 = new Timer(0, expectAsync1((t) => t2.cancel()));
40 t2 = new Timer(0, expectAsync1((t) => t1.cancel(), count: 0));
41 });
44 } 42 }
OLDNEW
« 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