From bd61b8811506fa4b2ff05c036826d1452b81766f Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 7 Oct 2024 12:24:07 -0400 Subject: [PATCH] And in camera tests --- .../java/io/flutter/plugins/camerax/PreviewTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java index 0b475b7a1dc6..83ccb1edd9c5 100644 --- a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java +++ b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/PreviewTest.java @@ -134,7 +134,7 @@ public void createSurfaceProducer_setsExpectedSurfaceProducerCallback() { reset(mockSurfaceRequest); // Verify callback's onSurfaceCreated does not interact with the SurfaceRequest. - callback.onSurfaceCreated(); + simulateSurfaceCreation(callback); verifyNoMoreInteractions(mockSurfaceRequest); } @@ -262,4 +262,12 @@ public void setTargetRotation_makesCallToSetTargetRotation() { verify(mockPreview).setTargetRotation(targetRotation); } + + // TODO(matanlurey): Replace with inline calls to onSurfaceAvailable once + // available on stable; see https://github.com/flutter/flutter/issues/155131. + // This seperate method only exists to scope the suppression. + @SuppressWarnings({"deprecation", "removal"}) + void simulateSurfaceCreation(TextureRegistry.SurfaceProducer.Callback producerLifecycle) { + producerLifecycle.onSurfaceCreated(); + } }