From f21a0d37a7209ad0ad8466d5d8dccdb3ec40ad7e Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Mon, 9 Dec 2024 11:16:33 -0800 Subject: [PATCH 1/9] Remove rotation correction logic --- .../lib/src/android_camera_camerax.dart | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 1d068eb24f1..2a9b7591ce0 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -865,68 +865,68 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - final Widget cameraPreview = Texture(textureId: cameraId); - final Map degreesForDeviceOrientation = - { - DeviceOrientation.portraitUp: 0, - DeviceOrientation.landscapeRight: 90, - DeviceOrientation.portraitDown: 180, - DeviceOrientation.landscapeLeft: 270, - }; - int naturalDeviceOrientationDegrees = - degreesForDeviceOrientation[naturalOrientation]!; - - if (isPreviewPreTransformed) { - // If the camera preview is backed by a SurfaceTexture, the transformation - // needed to correctly rotate the preview has already been applied. - // However, we may need to correct the camera preview rotation if the - // device is naturally landscape-oriented. - if (naturalOrientation == DeviceOrientation.landscapeLeft || - naturalOrientation == DeviceOrientation.landscapeRight) { - final int quarterTurnsToCorrectForLandscape = - (-naturalDeviceOrientationDegrees + 360) ~/ 4; - return RotatedBox( - quarterTurns: quarterTurnsToCorrectForLandscape, - child: cameraPreview); - } - return cameraPreview; - } - - // Fix for the rotation of the camera preview not backed by a SurfaceTexture - // with respect to the naturalOrientation of the device: - - final int signForCameraDirection = cameraIsFrontFacing ? 1 : -1; - - if (signForCameraDirection == 1 && - (currentDeviceOrientation == DeviceOrientation.landscapeLeft || - currentDeviceOrientation == DeviceOrientation.landscapeRight)) { - // For front-facing cameras, the image buffer is rotated counterclockwise, - // so we determine the rotation needed to correct the camera preview with - // respect to the naturalOrientation of the device based on the inverse of - // naturalOrientation. - naturalDeviceOrientationDegrees += 180; - } - - // See https://developer.android.com/media/camera/camera2/camera-preview#orientation_calculation - // for more context on this formula. - final double rotation = (sensorOrientation + - naturalDeviceOrientationDegrees * signForCameraDirection + - 360) % - 360; - int quarterTurnsToCorrectPreview = rotation ~/ 90; - - if (naturalOrientation == DeviceOrientation.landscapeLeft || - naturalOrientation == DeviceOrientation.landscapeRight) { - // We may need to correct the camera preview rotation if the device is - // naturally landscape-oriented. - quarterTurnsToCorrectPreview += - (-naturalDeviceOrientationDegrees + 360) ~/ 4; - return RotatedBox( - quarterTurns: quarterTurnsToCorrectPreview, child: cameraPreview); - } - - return RotatedBox( - quarterTurns: quarterTurnsToCorrectPreview, child: cameraPreview); + return Texture(textureId: cameraId); + // final Map degreesForDeviceOrientation = + // { + // DeviceOrientation.portraitUp: 0, + // DeviceOrientation.landscapeRight: 90, + // DeviceOrientation.portraitDown: 180, + // DeviceOrientation.landscapeLeft: 270, + // }; + // int naturalDeviceOrientationDegrees = + // degreesForDeviceOrientation[naturalOrientation]!; + + // if (isPreviewPreTransformed) { + // // If the camera preview is backed by a SurfaceTexture, the transformation + // // needed to correctly rotate the preview has already been applied. + // // However, we may need to correct the camera preview rotation if the + // // device is naturally landscape-oriented. + // if (naturalOrientation == DeviceOrientation.landscapeLeft || + // naturalOrientation == DeviceOrientation.landscapeRight) { + // final int quarterTurnsToCorrectForLandscape = + // (-naturalDeviceOrientationDegrees + 360) ~/ 4; + // return RotatedBox( + // quarterTurns: quarterTurnsToCorrectForLandscape, + // child: cameraPreview); + // } + // return cameraPreview; + // } + + // // Fix for the rotation of the camera preview not backed by a SurfaceTexture + // // with respect to the naturalOrientation of the device: + + // final int signForCameraDirection = cameraIsFrontFacing ? 1 : -1; + + // if (signForCameraDirection == 1 && + // (currentDeviceOrientation == DeviceOrientation.landscapeLeft || + // currentDeviceOrientation == DeviceOrientation.landscapeRight)) { + // // For front-facing cameras, the image buffer is rotated counterclockwise, + // // so we determine the rotation needed to correct the camera preview with + // // respect to the naturalOrientation of the device based on the inverse of + // // naturalOrientation. + // naturalDeviceOrientationDegrees += 180; + // } + + // // See https://developer.android.com/media/camera/camera2/camera-preview#orientation_calculation + // // for more context on this formula. + // final double rotation = (sensorOrientation + + // naturalDeviceOrientationDegrees * signForCameraDirection + + // 360) % + // 360; + // int quarterTurnsToCorrectPreview = rotation ~/ 90; + + // if (naturalOrientation == DeviceOrientation.landscapeLeft || + // naturalOrientation == DeviceOrientation.landscapeRight) { + // // We may need to correct the camera preview rotation if the device is + // // naturally landscape-oriented. + // quarterTurnsToCorrectPreview += + // (-naturalDeviceOrientationDegrees + 360) ~/ 4; + // return RotatedBox( + // quarterTurns: quarterTurnsToCorrectPreview, child: cameraPreview); + // } + + // return RotatedBox( + // quarterTurns: quarterTurnsToCorrectPreview, child: cameraPreview); } /// Captures an image and returns the file where it was saved. From afcd094d17d6b4d4d8b397d2567db3f9690b8209 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Wed, 11 Dec 2024 09:36:52 -0800 Subject: [PATCH 2/9] remove unused code --- .../lib/src/android_camera_camerax.dart | 88 +------------------ 1 file changed, 1 insertion(+), 87 deletions(-) diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 2a9b7591ce0..3f862f82d12 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -237,18 +237,6 @@ class AndroidCameraCameraX extends CameraPlatform { @visibleForTesting late bool cameraIsFrontFacing; - /// Whether or not the Surface used to create the camera preview is backed - /// by a SurfaceTexture. - @visibleForTesting - late bool isPreviewPreTransformed; - - /// The initial orientation of the device. - /// - /// The camera preview will use this orientation as the natural orientation - /// to correct its rotation with respect to, if necessary. - @visibleForTesting - DeviceOrientation? naturalOrientation; - /// The camera sensor orientation. @visibleForTesting late int sensorOrientation; @@ -399,20 +387,7 @@ class AndroidCameraCameraX extends CameraPlatform { final Camera2CameraInfo camera2CameraInfo = await proxy.getCamera2CameraInfo(cameraInfo!); - await Future.wait(>[ - SystemServices.isPreviewPreTransformed() - .then((bool value) => isPreviewPreTransformed = value), - proxy - .getSensorOrientation(camera2CameraInfo) - .then((int value) => sensorOrientation = value), - proxy - .getUiOrientation() - .then((DeviceOrientation value) => naturalOrientation ??= value), - ]); - _subscriptionForDeviceOrientationChanges = onDeviceOrientationChanged() - .listen((DeviceOrientationChangedEvent event) { - currentDeviceOrientation = event.orientation; - }); + sensorOrientation = await proxy.getSensorOrientation(camera2CameraInfo); return flutterSurfaceTextureId; } @@ -866,67 +841,6 @@ class AndroidCameraCameraX extends CameraPlatform { } return Texture(textureId: cameraId); - // final Map degreesForDeviceOrientation = - // { - // DeviceOrientation.portraitUp: 0, - // DeviceOrientation.landscapeRight: 90, - // DeviceOrientation.portraitDown: 180, - // DeviceOrientation.landscapeLeft: 270, - // }; - // int naturalDeviceOrientationDegrees = - // degreesForDeviceOrientation[naturalOrientation]!; - - // if (isPreviewPreTransformed) { - // // If the camera preview is backed by a SurfaceTexture, the transformation - // // needed to correctly rotate the preview has already been applied. - // // However, we may need to correct the camera preview rotation if the - // // device is naturally landscape-oriented. - // if (naturalOrientation == DeviceOrientation.landscapeLeft || - // naturalOrientation == DeviceOrientation.landscapeRight) { - // final int quarterTurnsToCorrectForLandscape = - // (-naturalDeviceOrientationDegrees + 360) ~/ 4; - // return RotatedBox( - // quarterTurns: quarterTurnsToCorrectForLandscape, - // child: cameraPreview); - // } - // return cameraPreview; - // } - - // // Fix for the rotation of the camera preview not backed by a SurfaceTexture - // // with respect to the naturalOrientation of the device: - - // final int signForCameraDirection = cameraIsFrontFacing ? 1 : -1; - - // if (signForCameraDirection == 1 && - // (currentDeviceOrientation == DeviceOrientation.landscapeLeft || - // currentDeviceOrientation == DeviceOrientation.landscapeRight)) { - // // For front-facing cameras, the image buffer is rotated counterclockwise, - // // so we determine the rotation needed to correct the camera preview with - // // respect to the naturalOrientation of the device based on the inverse of - // // naturalOrientation. - // naturalDeviceOrientationDegrees += 180; - // } - - // // See https://developer.android.com/media/camera/camera2/camera-preview#orientation_calculation - // // for more context on this formula. - // final double rotation = (sensorOrientation + - // naturalDeviceOrientationDegrees * signForCameraDirection + - // 360) % - // 360; - // int quarterTurnsToCorrectPreview = rotation ~/ 90; - - // if (naturalOrientation == DeviceOrientation.landscapeLeft || - // naturalOrientation == DeviceOrientation.landscapeRight) { - // // We may need to correct the camera preview rotation if the device is - // // naturally landscape-oriented. - // quarterTurnsToCorrectPreview += - // (-naturalDeviceOrientationDegrees + 360) ~/ 4; - // return RotatedBox( - // quarterTurns: quarterTurnsToCorrectPreview, child: cameraPreview); - // } - - // return RotatedBox( - // quarterTurns: quarterTurnsToCorrectPreview, child: cameraPreview); } /// Captures an image and returns the file where it was saved. From 6efe07a68e90e7a163cceb65c365bda6ddca49f6 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Wed, 11 Dec 2024 09:45:43 -0800 Subject: [PATCH 3/9] Delete rotation tests --- .../test/android_camera_camerax_test.dart | 136 ------------------ 1 file changed, 136 deletions(-) diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index 1f9ea762ce2..c051170c1ea 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -1336,148 +1336,12 @@ void main() { // bound to the lifecycle of the camera. camera.previewInitiallyBound = true; - // Tell camera the Surface used to build camera preview is backed by a - // SurfaceTexture. - camera.isPreviewPreTransformed = true; - - camera.naturalOrientation = DeviceOrientation.portraitDown; - final Widget widget = camera.buildPreview(cameraId); expect(widget is Texture, isTrue); expect((widget as Texture).textureId, cameraId); }); - test( - 'buildPreview returns preview with expected rotation if camera is not front facing and the preview is not backed by a SurfaceTexture', - () async { - final AndroidCameraCameraX camera = AndroidCameraCameraX(); - const int cameraId = 33; - - // Tell camera that createCamera has been called and thus, preview has been - // bound to the lifecycle of the camera. - camera.previewInitiallyBound = true; - - // Tell camera the Surface used to build camera preview is not backed by a - // SurfaceTexture. - camera.isPreviewPreTransformed = false; - - // Mock sensor and device orientation. - camera.sensorOrientation = 270; - camera.cameraIsFrontFacing = false; - camera.naturalOrientation = DeviceOrientation.portraitUp; - - final double expectedRotation = (camera.sensorOrientation + - 0 /* the natural orientation in clockwise degrees */ * - -1 /* camera is not front facing */ + - 360) % - 360; - final int expectedQuarterTurns = (expectedRotation / 90).toInt(); - - final Widget widget = camera.buildPreview(cameraId); - - expect(widget is RotatedBox, isTrue); - expect((widget as RotatedBox).quarterTurns, expectedQuarterTurns); - expect(widget.child is Texture, isTrue); - expect((widget.child! as Texture).textureId, cameraId); - }); - - test( - 'buildPreview returns preview with expected rotation if camera is front facing, the current orientation is landscape, and the preview is not backed by a SurfaceTexture', - () async { - final AndroidCameraCameraX camera = AndroidCameraCameraX(); - const int cameraId = 7; - - // Tell camera that createCamera has been called and thus, preview has been - // bound to the lifecycle of the camera. - camera.previewInitiallyBound = true; - - // Tell camera the Surface used to build camera preview is not backed by a - // SurfaceTexture. - camera.isPreviewPreTransformed = false; - - // Mock sensor and device orientation. - camera.sensorOrientation = 270; - camera.naturalOrientation = DeviceOrientation.portraitUp; - camera.cameraIsFrontFacing = true; - - // Calculate expected rotation with offset due to counter-clockwise rotation - // of the image with th efront camera in use. - final double expectedRotation = ((camera.sensorOrientation + - 0 /* the natural orientation in clockwise degrees */ * - 1 /* camera is front facing */ + - 360) % - 360) + - 180; - final int expectedQuarterTurns = (expectedRotation / 90).toInt() % 4; - - // Test landscape left. - camera.currentDeviceOrientation = DeviceOrientation.landscapeLeft; - Widget widget = camera.buildPreview(cameraId); - - expect(widget is RotatedBox, isTrue); - expect((widget as RotatedBox).quarterTurns, expectedQuarterTurns); - expect(widget.child is Texture, isTrue); - expect((widget.child! as Texture).textureId, cameraId); - - // Test landscape right. - camera.currentDeviceOrientation = DeviceOrientation.landscapeRight; - widget = camera.buildPreview(cameraId); - - expect(widget is RotatedBox, isTrue); - expect((widget as RotatedBox).quarterTurns, expectedQuarterTurns); - expect(widget.child is Texture, isTrue); - expect((widget.child! as Texture).textureId, cameraId); - }); - - test( - 'buildPreview returns preview with expected rotation if camera is front facing, the current orientation is not landscape, and the preview is not backed by a SurfaceTexture', - () async { - final AndroidCameraCameraX camera = AndroidCameraCameraX(); - const int cameraId = 733; - - // Tell camera that createCamera has been called and thus, preview has been - // bound to the lifecycle of the camera. - camera.previewInitiallyBound = true; - - // Tell camera the Surface used to build camera preview is not backed by a - // SurfaceTexture. - camera.isPreviewPreTransformed = false; - - // Mock sensor and device orientation. - camera.sensorOrientation = 270; - camera.naturalOrientation = DeviceOrientation.portraitUp; - camera.cameraIsFrontFacing = true; - - // Calculate expected rotation without offset needed for landscape orientations - // due to counter-clockwise rotation of the image with th efront camera in use. - final double expectedRotation = (camera.sensorOrientation + - 0 /* the natural orientation in clockwise degrees */ * - 1 /* camera is front facing */ + - 360) % - 360; - - final int expectedQuarterTurns = (expectedRotation / 90).toInt() % 4; - - // Test portrait up. - camera.currentDeviceOrientation = DeviceOrientation.portraitUp; - Widget widget = camera.buildPreview(cameraId); - - expect(widget is RotatedBox, isTrue); - expect((widget as RotatedBox).quarterTurns, expectedQuarterTurns); - expect(widget.child is Texture, isTrue); - expect((widget.child! as Texture).textureId, cameraId); - - // Test portrait down. - camera.currentDeviceOrientation = DeviceOrientation.portraitDown; - widget = camera.buildPreview(cameraId); - - expect(widget is RotatedBox, isTrue); - expect((widget as RotatedBox).quarterTurns, expectedQuarterTurns); - expect(widget.child is Texture, isTrue); - expect((widget.child! as Texture).textureId, cameraId); - }); - group('video recording', () { test( 'startVideoCapturing binds video capture use case, updates saved camera instance and its properties, and starts the recording', From d1d059094853e3bec2ff2176abc96f7889628d95 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Wed, 18 Dec 2024 11:03:42 -0800 Subject: [PATCH 4/9] Add 90 degree rotation --- .../camera_android_camerax/lib/src/android_camera_camerax.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 3f862f82d12..efa21d39595 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -840,7 +840,7 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - return Texture(textureId: cameraId); + return RotatedBox(quarterTurns: 1, child: Texture(textureId: cameraId)); } /// Captures an image and returns the file where it was saved. From 483c7a9720d5e3c346eaf3a3d918a312d8820717 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Mon, 6 Jan 2025 16:05:55 -0800 Subject: [PATCH 5/9] Working as of today on real devices on OpenGLES and Vulkan --- .../camera_android_camerax/lib/src/android_camera_camerax.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index efa21d39595..3f862f82d12 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -840,7 +840,7 @@ class AndroidCameraCameraX extends CameraPlatform { ); } - return RotatedBox(quarterTurns: 1, child: Texture(textureId: cameraId)); + return Texture(textureId: cameraId); } /// Captures an image and returns the file where it was saved. From 27cc91a6126243f4e48977f9c4248cac9e5d6e07 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 7 Jan 2025 15:33:41 -0800 Subject: [PATCH 6/9] Fix analyze hopefully --- .../camera_android_camerax/lib/src/android_camera_camerax.dart | 2 +- .../test/android_camera_camerax_test.dart | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 3f862f82d12..e049f82f005 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -10,7 +10,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart'; import 'package:flutter/services.dart' show DeviceOrientation, PlatformException; import 'package:flutter/widgets.dart' - show RotatedBox, Size, Texture, Widget, visibleForTesting; + show Size, Texture, Widget, visibleForTesting; import 'package:stream_transform/stream_transform.dart'; import 'analyzer.dart'; diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index c051170c1ea..2e9155ed69a 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -51,7 +51,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart'; import 'package:flutter/services.dart' show DeviceOrientation, PlatformException, Uint8List; import 'package:flutter/widgets.dart' - show BuildContext, RotatedBox, Size, Texture, Widget; + show BuildContext, Size, Texture, Widget; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; @@ -974,7 +974,6 @@ void main() { // Wait for currentDeviceOrientation to update. await Future.value(); - expect(camera.naturalOrientation, testUiOrientation); expect(camera.sensorOrientation, testSensorOrientation); expect(camera.currentDeviceOrientation, testCurrentOrientation); }); From e79d7944b673f40f654ccc93abf04ca6561482a3 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 7 Jan 2025 15:41:46 -0800 Subject: [PATCH 7/9] bump --- packages/camera/camera_android_camerax/CHANGELOG.md | 4 ++++ packages/camera/camera_android_camerax/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 07175134c88..7bd196b7e16 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.12 + +* Removes logic added to correct the rotation of the camera preview, since it is no longer required. + ## 0.6.11 * Replaces deprecated Android embedder APIs (`onSurfaceCreated` -> `onSurfaceAvailable`). diff --git a/packages/camera/camera_android_camerax/pubspec.yaml b/packages/camera/camera_android_camerax/pubspec.yaml index 0cdcd81c840..e007029d2c1 100644 --- a/packages/camera/camera_android_camerax/pubspec.yaml +++ b/packages/camera/camera_android_camerax/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_android_camerax description: Android implementation of the camera plugin using the CameraX library. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.6.11 +version: 0.6.12 environment: sdk: ^3.6.0 From 1d0de2433ef97e34b9a53cc7e64263fa7b8092b3 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 7 Jan 2025 15:50:25 -0800 Subject: [PATCH 8/9] Fix test, format --- .../lib/src/android_camera_camerax.dart | 4 ---- .../test/android_camera_camerax_test.dart | 17 ++--------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index e049f82f005..279956f8b17 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -241,10 +241,6 @@ class AndroidCameraCameraX extends CameraPlatform { @visibleForTesting late int sensorOrientation; - /// The current orientation of the device. - @visibleForTesting - DeviceOrientation? currentDeviceOrientation; - /// Subscription for listening to changes in device orientation. StreamSubscription? _subscriptionForDeviceOrientationChanges; diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index 2e9155ed69a..7cd97be75e0 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -50,8 +50,7 @@ import 'package:camera_android_camerax/src/zoom_state.dart'; import 'package:camera_platform_interface/camera_platform_interface.dart'; import 'package:flutter/services.dart' show DeviceOrientation, PlatformException, Uint8List; -import 'package:flutter/widgets.dart' - show BuildContext, Size, Texture, Widget; +import 'package:flutter/widgets.dart' show BuildContext, Size, Texture, Widget; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; @@ -920,9 +919,7 @@ void main() { expect(camera.recorder!.qualitySelector, isNull); }); - test( - 'createCamera sets sensor and device orientations needed to correct preview rotation as expected', - () async { + test('createCamera sets sensor orientation as expected', () async { final AndroidCameraCameraX camera = AndroidCameraCameraX(); const CameraLensDirection testLensDirection = CameraLensDirection.back; const int testSensorOrientation = 270; @@ -965,17 +962,7 @@ void main() { await camera.createCamera(testCameraDescription, testResolutionPreset, enableAudio: enableAudio); - const DeviceOrientationChangedEvent testEvent = - DeviceOrientationChangedEvent(testCurrentOrientation); - - DeviceOrientationManager.deviceOrientationChangedStreamController - .add(testEvent); - - // Wait for currentDeviceOrientation to update. - await Future.value(); - expect(camera.sensorOrientation, testSensorOrientation); - expect(camera.currentDeviceOrientation, testCurrentOrientation); }); test( From 40513e4787f0932264475041c51620b1aaf5f5a0 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 7 Jan 2025 15:58:50 -0800 Subject: [PATCH 9/9] fix analyze --- .../test/android_camera_camerax_test.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index 7cd97be75e0..bf1ff878edd 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -930,8 +930,6 @@ void main() { const bool enableAudio = true; const ResolutionPreset testResolutionPreset = ResolutionPreset.veryHigh; const DeviceOrientation testUiOrientation = DeviceOrientation.portraitDown; - const DeviceOrientation testCurrentOrientation = - DeviceOrientation.portraitUp; // Mock/Detached objects for (typically attached) objects created by // createCamera.