From 16f986ab37d9d28b91b54413dcee30b5d02d7383 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 13 May 2026 18:24:59 +0300 Subject: [PATCH] camera tests: cover async previewSize updates via PreviewSizeChanged New controller test exercises the Android path where create returns with the iOS-style synchronous previewSize and the event then revises it once CameraX's SurfaceRequest fires with the negotiated resolution. Asserts that previewRotationQuarterTurns stays untouched (events don't carry rotation; rotation is fixed per camera). 33/33 tests in test/camera/ now green. --- test/camera/camera_controller_test.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/camera/camera_controller_test.dart b/test/camera/camera_controller_test.dart index 242c822..49f6699 100644 --- a/test/camera/camera_controller_test.dart +++ b/test/camera/camera_controller_test.dart @@ -153,6 +153,22 @@ void main() { expect(fake.stopVideoRecordingCalls.single, 1); }); + test('previewSizeChanged events update value.previewSize without losing rotation', + () async { + final ctrl = UxCameraController(_back, UxResolutionPreset.high, enableAudio: false); + addTearDown(ctrl.dispose); + await ctrl.initialize(); + + // Fake create returns Size(1920, 1080); simulate Android's async + // first-SurfaceRequest landing with a revised resolution. + expect(ctrl.value.previewSize, const Size(1920, 1080)); + fake.emitPreviewSizeChanged(1, const Size(1280, 720)); + await Future.delayed(Duration.zero); + + expect(ctrl.value.previewSize, const Size(1280, 720)); + expect(ctrl.value.previewRotationQuarterTurns, 0); + }); + test('setDescription updates value.description and previewSize', () async { final ctrl = UxCameraController(_front, UxResolutionPreset.high, enableAudio: false); addTearDown(ctrl.dispose);