Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: tests/html/async_window_test.dart

Issue 10412015: aChange all asyncTest/callbackDone style tests to use the new expectAsync/ (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #library('AsyncWindowTest'); 1 #library('AsyncWindowTest');
2 #import('../../lib/unittest/unittest.dart'); 2 #import('../../lib/unittest/unittest.dart');
3 #import('../../lib/unittest/html_config.dart'); 3 #import('../../lib/unittest/html_config.dart');
4 #import('dart:html'); 4 #import('dart:html');
5 5
6 main() { 6 main() {
7 useHtmlConfiguration(); 7 useHtmlConfiguration();
8 asyncTest('Window.setTimeout', 1, () { 8 test('Window.setTimeout', () {
9 window.setTimeout(callbackDone, 10); 9 window.setTimeout(expectAsync0((){}), 10);
10 }); 10 });
11 asyncTest('Window.setInterval', 1, () { 11 test('Window.setInterval', () {
12 int counter = 0; 12 int counter = 0;
13 int id = null; 13 int id = null;
14 var callback = expectAsync0((){});
14 id = window.setInterval(() { 15 id = window.setInterval(() {
Siggi Cherem (dart-lang) 2012/05/21 22:20:47 here also: count:3, get rid of 'callback'
gram 2012/05/22 17:36:36 Done.
16 guardAsync(() {
15 if (counter == 3) { 17 if (counter == 3) {
16 counter = 1024; 18 counter = 1024;
17 window.clearInterval(id); 19 window.clearInterval(id);
18 // Wait some more time to be sure callback won't be invoked any more. 20 // Wait some more time to be sure callback won't be invoked any more.
19 window.setTimeout(callbackDone, 50); 21 window.setTimeout(callback, 50);
20 return; 22 return;
21 } 23 }
22 // As callback should have been cleared on 4th invocation, counter 24 // As callback should have been cleared on 4th invocation, counter
23 // should never be greater than 3. 25 // should never be greater than 3.
24 assert(counter < 3); 26 assert(counter < 3);
25 counter++; 27 counter++;
26 }, 10); 28 });}, 10);
Siggi Cherem (dart-lang) 2012/05/21 22:20:47 wrap after ;?
Siggi Cherem (dart-lang) 2012/05/21 22:20:47 wrap after ;?
gram 2012/05/22 17:36:36 Done.
gram 2012/05/22 17:36:36 Done.
27 }); 29 });
28 } 30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698