OLD | NEW |
1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 10 matching lines...) Expand all Loading... |
21 import 'package:quiver/testing/time.dart'; | 21 import 'package:quiver/testing/time.dart'; |
22 | 22 |
23 main() { | 23 main() { |
24 group('CountdownTimer', () { | 24 group('CountdownTimer', () { |
25 test('should countdown', () { | 25 test('should countdown', () { |
26 new FakeAsync().run((FakeAsync async) { | 26 new FakeAsync().run((FakeAsync async) { |
27 var clock = async.getClock(new DateTime.fromMillisecondsSinceEpoch(0)); | 27 var clock = async.getClock(new DateTime.fromMillisecondsSinceEpoch(0)); |
28 var stopwatch = new FakeStopwatch( | 28 var stopwatch = new FakeStopwatch( |
29 () => 1000 * clock.now().millisecondsSinceEpoch, 1000000); | 29 () => 1000 * clock.now().millisecondsSinceEpoch, 1000000); |
30 | 30 |
31 var timings = new CountdownTimer( | 31 var timings = new CountdownTimer(const Duration(milliseconds: 500), |
32 new Duration(milliseconds: 500), new Duration(milliseconds: 100), | 32 const Duration(milliseconds: 100), |
33 stopwatch: stopwatch).map((c) => c.remaining.inMilliseconds); | 33 stopwatch: stopwatch) |
| 34 .map((c) => c.remaining.inMilliseconds); |
34 | 35 |
35 List<int> result; | 36 List<int> result; |
36 timings.toList().then((list) { | 37 timings.toList().then((list) { |
37 result = list; | 38 result = list; |
38 }); | 39 }); |
39 | 40 |
40 async.elapse(aMillisecond * 500); | 41 async.elapse(aMillisecond * 500); |
41 expect(result, [400, 300, 200, 100, 0]); | 42 expect(result, [400, 300, 200, 100, 0]); |
42 }); | 43 }); |
43 }); | 44 }); |
| 45 |
| 46 test('should set increment to the initialized value', () { |
| 47 var timer = new CountdownTimer( |
| 48 const Duration(milliseconds: 321), const Duration(milliseconds: 123)); |
| 49 expect(timer.increment, const Duration(milliseconds: 123)); |
| 50 }); |
44 }); | 51 }); |
45 } | 52 } |
OLD | NEW |