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

Side by Side Diff: tests/isolate/multiple_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/isolate/isolate.status ('k') | tests/isolate/spawn_function_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('multiple_timer_test'); 5 #library('multiple_timer_test');
6 6
7 #import("dart:isolate"); 7 #import("dart:isolate");
8 #import('../../pkg/unittest/unittest.dart');
8 9
9 class MultipleTimerTest { 10 const int TIMEOUT1 = 1000;
11 const int TIMEOUT2 = 2000;
12 const int TIMEOUT3 = 500;
13 const int TIMEOUT4 = 1500;
10 14
11 static const int TIMEOUT1 = 1000; 15 main() {
12 static const int TIMEOUT2 = 2000; 16 test("multiple timer test", () {
13 static const int TIMEOUT3 = 500; 17 int _startTime1;
14 static const int TIMEOUT4 = 1500; 18 int _startTime2;
15 19 int _startTime3;
16 static void testMultipleTimer() { 20 int _startTime4;
21 List<int> _order;
22 int _message;
17 23
18 void timeoutHandler1(Timer timer) { 24 void timeoutHandler1(Timer timer) {
19 int endTime = (new Date.now()).millisecondsSinceEpoch; 25 int endTime = (new Date.now()).millisecondsSinceEpoch;
20 Expect.equals(true, (endTime - _startTime1) >= TIMEOUT1); 26 expect((endTime - _startTime1) >= TIMEOUT1);
21 Expect.equals(true, _order[_message] == 0); 27 expect(_order[_message] == 0);
22 _message++; 28 _message++;
23 } 29 }
24 30
25 void timeoutHandler2(Timer timer) { 31 void timeoutHandler2(Timer timer) {
26 int endTime = (new Date.now()).millisecondsSinceEpoch; 32 int endTime = (new Date.now()).millisecondsSinceEpoch;
27 Expect.equals(true, (endTime - _startTime2) >= TIMEOUT2); 33 expect((endTime - _startTime2) >= TIMEOUT2);
28 Expect.equals(true, _order[_message] == 1); 34 expect(_order[_message] == 1);
29 _message++; 35 _message++;
30 } 36 }
31 37
32 void timeoutHandler3(Timer timer) { 38 void timeoutHandler3(Timer timer) {
33 int endTime = (new Date.now()).millisecondsSinceEpoch; 39 int endTime = (new Date.now()).millisecondsSinceEpoch;
34 Expect.equals(true, (endTime - _startTime3) >= TIMEOUT3); 40 expect((endTime - _startTime3) >= TIMEOUT3);
35 Expect.equals(true, _order[_message] == 2); 41 expect(_order[_message] == 2);
36 _message++; 42 _message++;
37 } 43 }
38 44
39 void timeoutHandler4(Timer timer) { 45 void timeoutHandler4(Timer timer) {
40 int endTime = (new Date.now()).millisecondsSinceEpoch; 46 int endTime = (new Date.now()).millisecondsSinceEpoch;
41 Expect.equals(true, (endTime - _startTime4) >= TIMEOUT4); 47 expect((endTime - _startTime4) >= TIMEOUT4);
42 Expect.equals(true, _order[_message] == 3); 48 expect(_order[_message] == 3);
43 _message++; 49 _message++;
44 } 50 }
45 51
46 _order = new List<int>(4); 52 _order = new List<int>(4);
47 _order[0] = 2; 53 _order[0] = 2;
48 _order[1] = 0; 54 _order[1] = 0;
49 _order[2] = 3; 55 _order[2] = 3;
50 _order[3] = 1; 56 _order[3] = 1;
51 _message = 0; 57 _message = 0;
52 58
53 _startTime1 = (new Date.now()).millisecondsSinceEpoch; 59 _startTime1 = (new Date.now()).millisecondsSinceEpoch;
54 new Timer(TIMEOUT1, timeoutHandler1); 60 new Timer(TIMEOUT1, expectAsync1(timeoutHandler1));
55 _startTime2 = (new Date.now()).millisecondsSinceEpoch; 61 _startTime2 = (new Date.now()).millisecondsSinceEpoch;
56 new Timer(TIMEOUT2, timeoutHandler2); 62 new Timer(TIMEOUT2, expectAsync1(timeoutHandler2));
57 _startTime3 = (new Date.now()).millisecondsSinceEpoch; 63 _startTime3 = (new Date.now()).millisecondsSinceEpoch;
58 new Timer(TIMEOUT3, timeoutHandler3); 64 new Timer(TIMEOUT3, expectAsync1(timeoutHandler3));
59 _startTime4 = (new Date.now()).millisecondsSinceEpoch; 65 _startTime4 = (new Date.now()).millisecondsSinceEpoch;
60 new Timer(TIMEOUT4, timeoutHandler4); 66 new Timer(TIMEOUT4, expectAsync1(timeoutHandler4));
61 } 67 });
62
63 static void testMain() {
64 testMultipleTimer();
65 }
66
67 static int _startTime1;
68 static int _startTime2;
69 static int _startTime3;
70 static int _startTime4;
71 static List<int> _order;
72 static int _message;
73 } 68 }
74
75 main() {
76 MultipleTimerTest.testMain();
77 }
OLDNEW
« no previous file with comments | « tests/isolate/isolate.status ('k') | tests/isolate/spawn_function_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698