OLD | NEW |
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:async'; |
8 import '../../pkg/unittest/lib/unittest.dart'; | 8 import '../../pkg/unittest/lib/unittest.dart'; |
9 | 9 |
10 const int TIMEOUT1 = 1000; | 10 const int TIMEOUT1 = 1000; |
11 const int TIMEOUT2 = 2000; | 11 const int TIMEOUT2 = 2000; |
12 const int TIMEOUT3 = 500; | 12 const int TIMEOUT3 = 500; |
13 const int TIMEOUT4 = 1500; | 13 const int TIMEOUT4 = 1500; |
14 | 14 |
15 main() { | 15 main() { |
16 test("multiple timer test", () { | 16 test("multiple timer test", () { |
17 int _startTime1; | 17 int _startTime1; |
(...skipping 24 matching lines...) Expand all Loading... |
42 _message++; | 42 _message++; |
43 } | 43 } |
44 | 44 |
45 void timeoutHandler4(Timer timer) { | 45 void timeoutHandler4(Timer timer) { |
46 int endTime = (new Date.now()).millisecondsSinceEpoch; | 46 int endTime = (new Date.now()).millisecondsSinceEpoch; |
47 expect(endTime - _startTime4, greaterThanOrEqualTo(TIMEOUT4)); | 47 expect(endTime - _startTime4, greaterThanOrEqualTo(TIMEOUT4)); |
48 expect(_order[_message], 3); | 48 expect(_order[_message], 3); |
49 _message++; | 49 _message++; |
50 } | 50 } |
51 | 51 |
52 _order = new List<int>(4); | 52 _order = new List<int>.fixedLength(4); |
53 _order[0] = 2; | 53 _order[0] = 2; |
54 _order[1] = 0; | 54 _order[1] = 0; |
55 _order[2] = 3; | 55 _order[2] = 3; |
56 _order[3] = 1; | 56 _order[3] = 1; |
57 _message = 0; | 57 _message = 0; |
58 | 58 |
59 _startTime1 = (new Date.now()).millisecondsSinceEpoch; | 59 _startTime1 = (new Date.now()).millisecondsSinceEpoch; |
60 new Timer(TIMEOUT1, expectAsync1(timeoutHandler1)); | 60 new Timer(TIMEOUT1, expectAsync1(timeoutHandler1)); |
61 _startTime2 = (new Date.now()).millisecondsSinceEpoch; | 61 _startTime2 = (new Date.now()).millisecondsSinceEpoch; |
62 new Timer(TIMEOUT2, expectAsync1(timeoutHandler2)); | 62 new Timer(TIMEOUT2, expectAsync1(timeoutHandler2)); |
63 _startTime3 = (new Date.now()).millisecondsSinceEpoch; | 63 _startTime3 = (new Date.now()).millisecondsSinceEpoch; |
64 new Timer(TIMEOUT3, expectAsync1(timeoutHandler3)); | 64 new Timer(TIMEOUT3, expectAsync1(timeoutHandler3)); |
65 _startTime4 = (new Date.now()).millisecondsSinceEpoch; | 65 _startTime4 = (new Date.now()).millisecondsSinceEpoch; |
66 new Timer(TIMEOUT4, expectAsync1(timeoutHandler4)); | 66 new Timer(TIMEOUT4, expectAsync1(timeoutHandler4)); |
67 }); | 67 }); |
68 } | 68 } |
OLD | NEW |