Files
sdk/tests/html/async_window_test.dart
T
efortuna@google.com d7057b2d8c Reapply setTimeout change.
This CL is identical to 18555. The reason it will  work now is the corresponding
dartium change has been checked in.

TBR-blois

BUG=

Review URL: https://codereview.chromium.org//12254046

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18562 260f80e4-7a28-3924-810f-c04153c831b5
2013-02-15 07:40:51 +00:00

34 lines
984 B
Dart

library AsyncWindowTest;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
import 'dart:async';
main() {
useHtmlConfiguration();
test('Timer', () {
new Timer(const Duration(milliseconds: 10), expectAsync0((){}));
});
test('Timer.repeating', () {
int counter = 0;
int id = null;
new Timer.repeating(const Duration(milliseconds: 10),
expectAsyncUntil1(
(timer) {
if (counter == 3) {
counter = 1024;
timer.cancel();
// Wait some more time to be sure callback won't be invoked any
// more.
new Timer(const Duration(milliseconds: 50), expectAsync0((){}));
return;
}
// As callback should have been cleared on 4th invocation, counter
// should never be greater than 3.
assert(counter < 3);
counter++;
},
() => counter == 3));
});
}