From ff546d2bdb9a6e4ec9efa79515223b37cbf2ce02 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 13 Dec 2021 15:58:26 -0500 Subject: [PATCH 1/3] [video_player] Adjust a flaky test This test is flaking in a way that doesn't seem like it should be possible, since the bool whose value is incorrect is only set in one place, and its the same place where the future being awaited just before is completed. While the cause of the flake isn't understood, it's odd to have duplicate ways of expressing the same thing in the test in the first place, so this removes the booleans entirely and uses the completers directly. This may or may not fix the flake (since we don't understand how it's possible to flake), but it simplifies the test, and if it still fails we may get a less confusing failure mode. Part of https://github.com/flutter/flutter/issues/94775 --- packages/video_player/video_player/CHANGELOG.md | 1 + .../integration_test/video_player_test.dart | 17 +++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index f9031685b583..ea7949aea3a5 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -2,6 +2,7 @@ * Fixes integration tests. * Updates Android compileSdkVersion to 31. +* Minor test changes. ## 2.2.7 diff --git a/packages/video_player/video_player/example/integration_test/video_player_test.dart b/packages/video_player/video_player/example/integration_test/video_player_test.dart index 866b5bce0a8d..e139a61ab3e7 100644 --- a/packages/video_player/video_player/example/integration_test/video_player_test.dart +++ b/packages/video_player/video_player/example/integration_test/video_player_test.dart @@ -48,17 +48,13 @@ void main() { await networkController.setVolume(0); final Completer started = Completer(); final Completer ended = Completer(); - bool startedBuffering = false; - bool endedBuffering = false; networkController.addListener(() { - if (networkController.value.isBuffering && !startedBuffering) { - startedBuffering = true; + if (!started.isCompleted && networkController.value.isBuffering) { started.complete(); } - if (startedBuffering && + if (started.isCompleted && !networkController.value.isBuffering && - !endedBuffering) { - endedBuffering = true; + !ended.isCompleted) { ended.complete(); } }); @@ -72,11 +68,8 @@ void main() { expect(networkController.value.position, (Duration position) => position > const Duration(seconds: 0)); - await started; - expect(startedBuffering, true); - - await ended; - expect(endedBuffering, true); + await expectLater(started, completes); + await expectLater(ended, completes); }, skip: !(kIsWeb || defaultTargetPlatform == TargetPlatform.android), ); From 3e26db49825da3af42a960829e526f72cfbd8970 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 13 Dec 2021 16:13:12 -0500 Subject: [PATCH 2/3] Fix the test --- .../example/integration_test/video_player_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player/example/integration_test/video_player_test.dart b/packages/video_player/video_player/example/integration_test/video_player_test.dart index e139a61ab3e7..63a38290a613 100644 --- a/packages/video_player/video_player/example/integration_test/video_player_test.dart +++ b/packages/video_player/video_player/example/integration_test/video_player_test.dart @@ -68,8 +68,8 @@ void main() { expect(networkController.value.position, (Duration position) => position > const Duration(seconds: 0)); - await expectLater(started, completes); - await expectLater(ended, completes); + await expectLater(started.future, completes); + await expectLater(ended.future, completes); }, skip: !(kIsWeb || defaultTargetPlatform == TargetPlatform.android), ); From 3d16b08eb24d1c31cb946d821966188bc442577b Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 13 Dec 2021 13:26:55 -0800 Subject: [PATCH 3/3] Update CHANGELOG message --- packages/video_player/video_player/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index ea7949aea3a5..9d4e36d72017 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -2,7 +2,7 @@ * Fixes integration tests. * Updates Android compileSdkVersion to 31. -* Minor test changes. +* Fixes a flaky integration test. ## 2.2.7