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:async'; | 7 import 'dart:async'; |
8 import '../../pkg/unittest/lib/unittest.dart'; | 8 import '../../pkg/unittest/lib/unittest.dart'; |
9 | 9 |
10 const Duration TIMEOUT1 = const Duration(seconds: 1); | 10 const Duration TIMEOUT1 = const Duration(seconds: 1); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 void timeoutHandler4() { | 51 void timeoutHandler4() { |
52 // The stopwatch is more precise than the Timer. It can happen that | 52 // The stopwatch is more precise than the Timer. It can happen that |
53 // the TIMEOUT triggers *slightly* too early. | 53 // the TIMEOUT triggers *slightly* too early. |
54 expect(_stopwatch4.elapsedMilliseconds + 1, | 54 expect(_stopwatch4.elapsedMilliseconds + 1, |
55 greaterThanOrEqualTo(TIMEOUT4.inMilliseconds)); | 55 greaterThanOrEqualTo(TIMEOUT4.inMilliseconds)); |
56 expect(_order[_message], 3); | 56 expect(_order[_message], 3); |
57 _message++; | 57 _message++; |
58 } | 58 } |
59 | 59 |
60 _order = new List<int>.fixedLength(4); | 60 _order = new List<int>(4); |
61 _order[0] = 2; | 61 _order[0] = 2; |
62 _order[1] = 0; | 62 _order[1] = 0; |
63 _order[2] = 3; | 63 _order[2] = 3; |
64 _order[3] = 1; | 64 _order[3] = 1; |
65 _message = 0; | 65 _message = 0; |
66 | 66 |
67 _stopwatch1.start(); | 67 _stopwatch1.start(); |
68 new Timer(TIMEOUT1, expectAsync0(timeoutHandler1)); | 68 new Timer(TIMEOUT1, expectAsync0(timeoutHandler1)); |
69 _stopwatch2.start(); | 69 _stopwatch2.start(); |
70 new Timer(TIMEOUT2, expectAsync0(timeoutHandler2)); | 70 new Timer(TIMEOUT2, expectAsync0(timeoutHandler2)); |
71 _stopwatch3.start(); | 71 _stopwatch3.start(); |
72 new Timer(TIMEOUT3, expectAsync0(timeoutHandler3)); | 72 new Timer(TIMEOUT3, expectAsync0(timeoutHandler3)); |
73 _stopwatch4.start(); | 73 _stopwatch4.start(); |
74 new Timer(TIMEOUT4, expectAsync0(timeoutHandler4)); | 74 new Timer(TIMEOUT4, expectAsync0(timeoutHandler4)); |
75 }); | 75 }); |
76 } | 76 } |
OLD | NEW |