| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library timer_repeat_test; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 import '../../pkg/unittest/lib/unittest.dart'; | |
| 9 | |
| 10 const Duration TIMEOUT = const Duration(milliseconds: 500); | |
| 11 const int ITERATIONS = 5; | |
| 12 | |
| 13 Timer timer; | |
| 14 int startTime; | |
| 15 int iteration; | |
| 16 | |
| 17 void timeoutHandler(Timer timer) { | |
| 18 int endTime = (new DateTime.now()).millisecondsSinceEpoch; | |
| 19 iteration++; | |
| 20 if (iteration < ITERATIONS) { | |
| 21 startTime = (new DateTime.now()).millisecondsSinceEpoch; | |
| 22 } else { | |
| 23 expect(iteration, ITERATIONS); | |
| 24 timer.cancel(); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 main() { | |
| 29 test("timer_repeat", () { | |
| 30 iteration = 0; | |
| 31 startTime = new DateTime.now().millisecondsSinceEpoch; | |
| 32 timer = new Timer.periodic(TIMEOUT, | |
| 33 expectAsync1(timeoutHandler, count: ITERATIONS)); | |
| 34 }); | |
| 35 } | |
| OLD | NEW |