Files
sdk/tests/html/async_window_test.dart
T
gram@google.com 9248731b39 Change asyncTest/callbackDone style tests to use the new expectAsync/
guardAsync form, and fix a couple of issues in the unit test library
related to these.
Note: this CL covers the changes in the tests directory. There are a few
changes in utils and samples; these will de done in a separate CL.
Review URL: https://chromiumcodereview.appspot.com//10412015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7877 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-22 20:37:25 +00:00

29 lines
811 B
Dart

#library('AsyncWindowTest');
#import('../../lib/unittest/unittest.dart');
#import('../../lib/unittest/html_config.dart');
#import('dart:html');
main() {
useHtmlConfiguration();
test('Window.setTimeout', () {
window.setTimeout(expectAsync0((){}), 10);
});
test('Window.setInterval', () {
int counter = 0;
int id = null;
id = window.setInterval(expectAsync0(() {
if (counter == 3) {
counter = 1024;
window.clearInterval(id);
// Wait some more time to be sure callback won't be invoked any more.
window.setTimeout(expectAsync0((){}), 50);
return;
}
// As callback should have been cleared on 4th invocation, counter
// should never be greater than 3.
assert(counter < 3);
counter++;
}, count:3), 10);
});
}