[web] improve requestanimationframe test.
This test is flaky and causes timeouts 70% of the time in DDC.
The reasons are not clear at the moment, but I noticed that the
test was not properly using async-helper. This change may help
improve our investigation in the near future.
Change-Id: I834265dd6b898098ee7d5210ffe68ef0a6db74a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332280
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
diff --git a/tests/lib/html/request_animation_frame_test.dart b/tests/lib/html/request_animation_frame_test.dart
index d0c0447..4e330d9 100644
--- a/tests/lib/html/request_animation_frame_test.dart
+++ b/tests/lib/html/request_animation_frame_test.dart
@@ -7,7 +7,8 @@
import 'dart:async';
import 'dart:html';
-import 'package:expect/minitest.dart';
+import 'package:async_helper/async_helper.dart';
+import 'package:expect/expect.dart';
Future testOneShot() async {
final done = new Completer();
@@ -34,9 +35,9 @@
Future testCancel1() async {
final done = new Completer();
var frame1 = window.requestAnimationFrame((timestamp1) {
- fail('Should have been cancelled');
+ Expect.fail('Should have been cancelled');
});
- var frame2 = window.requestAnimationFrame(done.complete);
+ window.requestAnimationFrame(done.complete);
window.cancelAnimationFrame(frame1);
await done.future;
}
@@ -44,18 +45,20 @@
Future testCancel2() async {
final done1 = new Completer();
final done2 = new Completer();
- var frame1 = window.requestAnimationFrame(done1.complete);
+ window.requestAnimationFrame(done1.complete);
var frame2 = window.requestAnimationFrame((timestamp2) {
- fail('Should have been cancelled');
+ Expect.fail('Should have been cancelled');
});
- var frame3 = window.requestAnimationFrame(done2.complete);
+ window.requestAnimationFrame(done2.complete);
window.cancelAnimationFrame(frame2);
await Future.wait([done1.future, done2.future]);
}
-main() async {
- await testOneShot();
- await testTwoShot();
- await testCancel1();
- await testCancel2();
+main() {
+ asyncTest(() async {
+ await testOneShot();
+ await testTwoShot();
+ await testCancel1();
+ await testCancel2();
+ });
}
diff --git a/tests/lib_2/html/request_animation_frame_test.dart b/tests/lib_2/html/request_animation_frame_test.dart
index fc6f6e9..ccde046 100644
--- a/tests/lib_2/html/request_animation_frame_test.dart
+++ b/tests/lib_2/html/request_animation_frame_test.dart
@@ -9,7 +9,8 @@
import 'dart:async';
import 'dart:html';
-import 'package:expect/minitest.dart';
+import 'package:async_helper/async_helper.dart';
+import 'package:expect/expect.dart';
Future testOneShot() async {
final done = new Completer();
@@ -36,9 +37,9 @@
Future testCancel1() async {
final done = new Completer();
var frame1 = window.requestAnimationFrame((timestamp1) {
- fail('Should have been cancelled');
+ Expect.fail('Should have been cancelled');
});
- var frame2 = window.requestAnimationFrame(done.complete);
+ window.requestAnimationFrame(done.complete);
window.cancelAnimationFrame(frame1);
await done.future;
}
@@ -46,18 +47,20 @@
Future testCancel2() async {
final done1 = new Completer();
final done2 = new Completer();
- var frame1 = window.requestAnimationFrame(done1.complete);
+ window.requestAnimationFrame(done1.complete);
var frame2 = window.requestAnimationFrame((timestamp2) {
- fail('Should have been cancelled');
+ Expect.fail('Should have been cancelled');
});
- var frame3 = window.requestAnimationFrame(done2.complete);
+ window.requestAnimationFrame(done2.complete);
window.cancelAnimationFrame(frame2);
await Future.wait([done1.future, done2.future]);
}
-main() async {
- await testOneShot();
- await testTwoShot();
- await testCancel1();
- await testCancel2();
+main() {
+ asyncTest(() async {
+ await testOneShot();
+ await testTwoShot();
+ await testCancel1();
+ await testCancel2();
+ });
}