From 34b36cedba645aa6cdae3205678530ac344218e6 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 12 Dec 2022 10:25:34 -0500 Subject: [PATCH] [camera] Attempt to fix flaky new Android test The recently added "recording with image stream" test is very flaky, often throwing on `stop`. This is a speculative fix for that flake based on the documentation of `stop` indicating that it will throw if nothing has been recorded. --- .../camera_android/example/integration_test/camera_test.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/camera/camera_android/example/integration_test/camera_test.dart b/packages/camera/camera_android/example/integration_test/camera_test.dart index 4e75fdc9ef57..0ddb66388456 100644 --- a/packages/camera/camera_android/example/integration_test/camera_test.dart +++ b/packages/camera/camera_android/example/integration_test/camera_test.dart @@ -277,7 +277,10 @@ void main() { expect(controller.value.isStreamingImages, true); - sleep(const Duration(milliseconds: 500)); + // Stopping recording before anything is recorded will throw, per + // https://developer.android.com/reference/android/media/MediaRecorder.html#stop() + // so delay long enough to ensure that some data is recorded. + await Future.delayed(const Duration(seconds: 2)); await controller.stopVideoRecording(); await controller.dispose();