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

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

Issue 12258020: Reverting setTimeout removal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 '../../pkg/unittest/lib/unittest.dart'; 2 import '../../pkg/unittest/lib/unittest.dart';
3 import '../../pkg/unittest/lib/html_config.dart'; 3 import '../../pkg/unittest/lib/html_config.dart';
4 import 'dart:html'; 4 import 'dart:html';
5 import 'dart:async';
6 5
7 main() { 6 main() {
8 useHtmlConfiguration(); 7 useHtmlConfiguration();
9 test('Timer', () { 8 test('Window.setTimeout', () {
10 new Timer(const Duration(milliseconds: 10), expectAsync0((){})); 9 window.setTimeout(expectAsync0((){}), 10);
11 }); 10 });
12 test('Timer.repeating', () { 11 test('Window.setInterval', () {
13 int counter = 0; 12 int counter = 0;
14 int id = null; 13 int id = null;
15 new Timer.repeating(const Duration(milliseconds: 10), 14 id = window.setInterval(expectAsyncUntil0(
16 expectAsyncUntil1( 15 () {
17 (timer) { 16 if (counter == 3) {
18 if (counter == 3) { 17 counter = 1024;
19 counter = 1024; 18 window.clearInterval(id);
20 timer.cancel(); 19 // Wait some more time to be sure callback won't be invoked any more.
21 // Wait some more time to be sure callback won't be invoked any 20 window.setTimeout(expectAsync0((){}), 50);
22 // more. 21 return;
23 new Timer(const Duration(milliseconds: 50), expectAsync0((){})); 22 }
24 return; 23 // As callback should have been cleared on 4th invocation, counter
25 } 24 // should never be greater than 3.
26 // As callback should have been cleared on 4th invocation, counter 25 assert(counter < 3);
27 // should never be greater than 3. 26 counter++;
28 assert(counter < 3); 27 },
29 counter++; 28 () => counter == 3), 10);
30 },
31 () => counter == 3));
32 }); 29 });
33 } 30 }
OLDNEW
« no previous file with comments | « tests/benchmark_smoke/benchmark_smoke_test.dart ('k') | tests/html/cssstyledeclaration_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698