Skip to content

Commit 2dc24c5

Browse files
[camera_avfoundation] Wrappers swift migration - part 6 (#10752)
Migrates camera wrappers as part of flutter/flutter#119109 This (last wrappers related 🎉) PR migrates wrappers to Swift: * `FLTSavePhotoDelegate` * `FLTWritableData` * `FLTImageStreamHandler` * `CameraProperties` * `QueueUtils` In line with Swift conventions, the `FLT` prefixes are removed. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 9010299 commit 2dc24c5

49 files changed

Lines changed: 405 additions & 488 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.9.22+9
2+
3+
* Migrates `FLTSavePhotoDelegate`, `FLTWritableData`, and `FLTImageStreamHandler` classes to Swift.
4+
* Migrates `CameraProperties` and `QueueUtils` helpers to Swift.
5+
16
## 0.9.22+8
27

38
* Migrates `FLTPermissionServicing` and `FLTCameraPermissionManager` classes to Swift.

packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraPermissionTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import AVFoundation
6+
import Flutter
67
import XCTest
78

89
@testable import camera_avfoundation

packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraPropertiesTests.swift

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,68 +19,60 @@ final class CameraPropertiesTests: XCTestCase {
1919
func testGetAVCaptureFlashModeForPigeonFlashMode() {
2020
XCTAssertEqual(
2121
AVCaptureDevice.FlashMode.off,
22-
FCPGetAVCaptureFlashModeForPigeonFlashMode(FCPPlatformFlashMode.off))
22+
getAVCaptureFlashMode(for: .off))
2323
XCTAssertEqual(
2424
AVCaptureDevice.FlashMode.auto,
25-
FCPGetAVCaptureFlashModeForPigeonFlashMode(FCPPlatformFlashMode.auto))
25+
getAVCaptureFlashMode(for: .auto))
2626
XCTAssertEqual(
2727
AVCaptureDevice.FlashMode.on,
28-
FCPGetAVCaptureFlashModeForPigeonFlashMode(FCPPlatformFlashMode.always))
29-
30-
// TODO(FirentisTFW): Migrate implementation to throw Swift error in this case.
31-
let exception = ExceptionCatcher.catchException {
32-
_ = FCPGetAVCaptureFlashModeForPigeonFlashMode(.torch)
33-
}
34-
XCTAssertNotNil(exception)
28+
getAVCaptureFlashMode(for: .always))
3529
}
3630

3731
// MARK: - Video Format Tests
3832

3933
func testGetPixelFormatForPigeonFormat() {
4034
XCTAssertEqual(
4135
kCVPixelFormatType_32BGRA,
42-
FCPGetPixelFormatForPigeonFormat(FCPPlatformImageFormatGroup.bgra8888))
36+
getPixelFormat(for: .bgra8888))
4337
XCTAssertEqual(
4438
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,
45-
FCPGetPixelFormatForPigeonFormat(FCPPlatformImageFormatGroup.yuv420))
39+
getPixelFormat(for: .yuv420))
4640
}
4741

4842
// MARK: - Device Orientation Tests
4943

5044
func testGetUIDeviceOrientationForPigeonDeviceOrientation() {
5145
XCTAssertEqual(
5246
UIDeviceOrientation.portraitUpsideDown,
53-
FCPGetUIDeviceOrientationForPigeonDeviceOrientation(FCPPlatformDeviceOrientation.portraitDown)
47+
getUIDeviceOrientation(for: .portraitDown)
5448
)
5549
XCTAssertEqual(
5650
UIDeviceOrientation.landscapeLeft,
57-
FCPGetUIDeviceOrientationForPigeonDeviceOrientation(
58-
FCPPlatformDeviceOrientation.landscapeLeft))
51+
getUIDeviceOrientation(for: .landscapeLeft))
5952
XCTAssertEqual(
6053
UIDeviceOrientation.landscapeRight,
61-
FCPGetUIDeviceOrientationForPigeonDeviceOrientation(
62-
FCPPlatformDeviceOrientation.landscapeRight))
54+
getUIDeviceOrientation(for: .landscapeRight))
6355
XCTAssertEqual(
6456
UIDeviceOrientation.portrait,
65-
FCPGetUIDeviceOrientationForPigeonDeviceOrientation(FCPPlatformDeviceOrientation.portraitUp))
57+
getUIDeviceOrientation(for: .portraitUp))
6658
}
6759

6860
func testGetPigeonDeviceOrientationForUIDeviceOrientation() {
6961
XCTAssertEqual(
7062
FCPPlatformDeviceOrientation.portraitDown,
71-
FCPGetPigeonDeviceOrientationForOrientation(UIDeviceOrientation.portraitUpsideDown))
63+
getPigeonDeviceOrientation(for: .portraitUpsideDown))
7264
XCTAssertEqual(
7365
FCPPlatformDeviceOrientation.landscapeLeft,
74-
FCPGetPigeonDeviceOrientationForOrientation(UIDeviceOrientation.landscapeLeft))
66+
getPigeonDeviceOrientation(for: .landscapeLeft))
7567
XCTAssertEqual(
7668
FCPPlatformDeviceOrientation.landscapeRight,
77-
FCPGetPigeonDeviceOrientationForOrientation(UIDeviceOrientation.landscapeRight))
69+
getPigeonDeviceOrientation(for: .landscapeRight))
7870
XCTAssertEqual(
7971
FCPPlatformDeviceOrientation.portraitUp,
80-
FCPGetPigeonDeviceOrientationForOrientation(UIDeviceOrientation.portrait))
72+
getPigeonDeviceOrientation(for: .portrait))
8173
// Test default case.
8274
XCTAssertEqual(
8375
FCPPlatformDeviceOrientation.portraitUp,
84-
FCPGetPigeonDeviceOrientationForOrientation(UIDeviceOrientation.unknown))
76+
getPigeonDeviceOrientation(for: .unknown))
8577
}
8678
}

packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraTestUtils.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import AVFoundation
56
import XCTest
67

78
@testable import camera_avfoundation

packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockAssetWriter.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import AVFoundation
6+
57
@testable import camera_avfoundation
68

79
// Import Objective-C part of the implementation when SwiftPM is used.

packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockAssetWriterInput.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import AVFoundation
6+
57
@testable import camera_avfoundation
68

79
// Import Objective-C part of the implementation when SwiftPM is used.

packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockAssetWriterInputPixelBufferAdaptor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import AVFoundation
6+
57
@testable import camera_avfoundation
68

79
// Import Objective-C part of the implementation when SwiftPM is used.

packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCamera.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import AVFoundation
6+
import Flutter
7+
58
@testable import camera_avfoundation
69

710
// Import Objective-C part of the implementation when SwiftPM is used.

packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCameraDeviceDiscoverer.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import AVFoundation
6+
57
@testable import camera_avfoundation
68

79
// Import Objective-C part of the implementation when SwiftPM is used.

packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureConnection.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import AVFoundation
6+
57
@testable import camera_avfoundation
68

79
// Import Objective-C part of the implementation when SwiftPM is used.

0 commit comments

Comments
 (0)