| Index: tests/isolate/timer_test.dart
|
| diff --git a/tests/isolate/timer_test.dart b/tests/isolate/timer_test.dart
|
| index 85399842e4e8dd4eaf785e5108210bc2ba05249a..fd679d35863c99e9d3d9d006cb93ac1f5b75861b 100644
|
| --- a/tests/isolate/timer_test.dart
|
| +++ b/tests/isolate/timer_test.dart
|
| @@ -5,41 +5,32 @@
|
| #library('timer_test');
|
|
|
| #import("dart:isolate");
|
| -
|
| -class TimerTest {
|
| -
|
| - static const int _STARTTIMEOUT = 1050;
|
| - static const int _DECREASE = 200;
|
| - static const int _ITERATIONS = 5;
|
| -
|
| - static void testSimpleTimer() {
|
| -
|
| - void timeoutHandler(Timer timer) {
|
| - int endTime = (new Date.now()).millisecondsSinceEpoch;
|
| - Expect.equals(true, (endTime - _startTime) >= _timeout);
|
| - if (_iteration < _ITERATIONS) {
|
| - _iteration++;
|
| - _timeout = _timeout - _DECREASE;
|
| - _startTime = (new Date.now()).millisecondsSinceEpoch;
|
| - new Timer(_timeout, timeoutHandler);
|
| - }
|
| - }
|
| -
|
| - _iteration = 0;
|
| - _timeout = _STARTTIMEOUT;
|
| - _startTime = (new Date.now()).millisecondsSinceEpoch;
|
| - new Timer(_timeout, timeoutHandler);
|
| - }
|
| -
|
| - static void testMain() {
|
| - testSimpleTimer();
|
| +#import('../../pkg/unittest/unittest.dart');
|
| +
|
| +const int STARTTIMEOUT = 1050;
|
| +const int DECREASE = 200;
|
| +const int ITERATIONS = 5;
|
| +
|
| +int startTime;
|
| +int timeout;
|
| +int iteration;
|
| +
|
| +void timeoutHandler(Timer timer) {
|
| + int endTime = (new Date.now()).millisecondsSinceEpoch;
|
| + expect((endTime - startTime) >= timeout);
|
| + if (iteration < ITERATIONS) {
|
| + iteration++;
|
| + timeout = timeout - DECREASE;
|
| + startTime = (new Date.now()).millisecondsSinceEpoch;
|
| + new Timer(timeout, expectAsync1(timeoutHandler));
|
| }
|
| -
|
| - static int _startTime;
|
| - static int _timeout;
|
| - static int _iteration;
|
| }
|
|
|
| main() {
|
| - TimerTest.testMain();
|
| + test("timeout test", () {
|
| + iteration = 0;
|
| + timeout = STARTTIMEOUT;
|
| + startTime = (new Date.now()).millisecondsSinceEpoch;
|
| + new Timer(timeout, expectAsync1(timeoutHandler));
|
| + });
|
| }
|
|
|