| OLD | NEW |
| 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 | 5 |
| 6 main() { | 6 main() { |
| 7 useHtmlConfiguration(); | 7 useHtmlConfiguration(); |
| 8 test('Window.setTimeout', () { | 8 test('Window.setTimeout', () { |
| 9 window.setTimeout(expectAsync0((){}), 10); | 9 window.setTimeout(expectAsync0((){}), 10); |
| 10 }); | 10 }); |
| 11 test('Window.setInterval', () { | 11 test('Window.setInterval', () { |
| 12 int counter = 0; | 12 int counter = 0; |
| 13 int id = null; | 13 int id = null; |
| 14 id = window.setInterval(expectAsync0(() { | 14 id = window.setInterval(expectAsyncUntil0( |
| 15 if (counter == 3) { | 15 () { |
| 16 counter = 1024; | 16 if (counter == 3) { |
| 17 window.clearInterval(id); | 17 counter = 1024; |
| 18 // Wait some more time to be sure callback won't be invoked any more. | 18 window.clearInterval(id); |
| 19 window.setTimeout(expectAsync0((){}), 50); | 19 // Wait some more time to be sure callback won't be invoked any more. |
| 20 return; | 20 window.setTimeout(expectAsync0((){}), 50); |
| 21 } | 21 return; |
| 22 // As callback should have been cleared on 4th invocation, counter | 22 } |
| 23 // should never be greater than 3. | 23 // As callback should have been cleared on 4th invocation, counter |
| 24 assert(counter < 3); | 24 // should never be greater than 3. |
| 25 counter++; | 25 assert(counter < 3); |
| 26 }, 3), 10); | 26 counter++; |
| 27 }, |
| 28 () => counter == 3), 10); |
| 27 }); | 29 }); |
| 28 } | 30 } |
| OLD | NEW |