[web] fix race in the image_loading_integration.dart test (#92303)

This commit is contained in:
Yegor
2021-10-26 19:03:03 -07:00
committed by GitHub
parent a24d55660b
commit 11e83e7c18
2 changed files with 51 additions and 2 deletions

View File

@@ -15,6 +15,17 @@ void main() {
(WidgetTester tester) async {
await app.main();
await tester.pumpAndSettle();
// `pumpAndSettle` only waits until no more frames are scheduled, but the
// test must wait for the image network requests to finish.
await app.whenAssetImageLoads;
await app.whenNetworkImageLoads;
// At the time the network requests are finished the engine may not have
// updated the DOM yet. Delay checking the DOM until the next event, which
// will guarantee that the current frame is done rendering.
await Future<void>.delayed(Duration.zero);
final List<html.ImageElement> imageElements = findElements('img').cast<html.ImageElement>();
expect(imageElements.length, 2);
expect(imageElements[0].naturalWidth, 1.5 * 64);