-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[camera_avfoundation] Wrappers swift migration - part 3 #10293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RobertOdrowaz
wants to merge
1
commit into
flutter:main
Choose a base branch
from
leancodepl:feature/camera-wrappers-swift-migration-part3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,31 +39,31 @@ private final class TestMediaSettingsAVWrapper: FLTCamMediaSettingsAVWrapper { | |
| videoSettingsExpectation = test.expectation(description: "videoSettingsExpectation") | ||
| } | ||
|
|
||
| override func lockDevice(_ captureDevice: FLTCaptureDevice) throws { | ||
| override func lockDevice(_ captureDevice: CaptureDevice) throws { | ||
RobertOdrowaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| lockExpectation.fulfill() | ||
| } | ||
|
|
||
| override func unlockDevice(_ captureDevice: FLTCaptureDevice) { | ||
| override func unlockDevice(_ captureDevice: CaptureDevice) { | ||
RobertOdrowaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| unlockExpectation.fulfill() | ||
| } | ||
|
|
||
| override func beginConfiguration(for videoCaptureSession: FLTCaptureSession) { | ||
| override func beginConfiguration(for videoCaptureSession: CaptureSession) { | ||
RobertOdrowaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| beginConfigurationExpectation.fulfill() | ||
| } | ||
|
|
||
| override func commitConfiguration(for videoCaptureSession: FLTCaptureSession) { | ||
| override func commitConfiguration(for videoCaptureSession: CaptureSession) { | ||
RobertOdrowaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| commitConfigurationExpectation.fulfill() | ||
| } | ||
|
|
||
| override func setMinFrameDuration(_ duration: CMTime, on captureDevice: FLTCaptureDevice) { | ||
| override func setMinFrameDuration(_ duration: CMTime, on captureDevice: CaptureDevice) { | ||
RobertOdrowaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // FLTCam allows to set frame rate with 1/10 precision. | ||
| let expectedDuration = CMTimeMake(value: 10, timescale: Int32(testFramesPerSecond * 10)) | ||
| if duration == expectedDuration { | ||
| minFrameDurationExpectation.fulfill() | ||
| } | ||
| } | ||
|
|
||
| override func setMaxFrameDuration(_ duration: CMTime, on captureDevice: FLTCaptureDevice) { | ||
| override func setMaxFrameDuration(_ duration: CMTime, on captureDevice: CaptureDevice) { | ||
RobertOdrowaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // FLTCam allows to set frame rate with 1/10 precision. | ||
| let expectedDuration = CMTimeMake(value: 10, timescale: Int32(testFramesPerSecond * 10)) | ||
| if duration == expectedDuration { | ||
|
|
@@ -203,7 +203,7 @@ final class CameraSettingsTests: XCTestCase { | |
| configuration.mediaSettings = settings | ||
| let camera = CameraTestUtils.createTestCamera(configuration) | ||
|
|
||
| let range = camera.captureDevice.activeFormat.videoSupportedFrameRateRanges[0] | ||
| let range = camera.captureDevice.fltActiveFormat.videoSupportedFrameRateRanges[0] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we renaming it? |
||
| XCTAssertLessThanOrEqual(range.minFrameRate, 60) | ||
| XCTAssertGreaterThanOrEqual(range.maxFrameRate, 60) | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import camera_avfoundation | ||
| @testable import camera_avfoundation | ||
|
|
||
| // Import Objective-C part of the implementation when SwiftPM is used. | ||
| #if canImport(camera_avfoundation_objc) | ||
|
|
@@ -11,7 +11,7 @@ import camera_avfoundation | |
|
|
||
| /// A mock implementation of `FLTCaptureDevice` that allows mocking the class | ||
| /// properties. | ||
| class MockCaptureDevice: NSObject, FLTCaptureDevice { | ||
| class MockCaptureDevice: NSObject, CaptureDevice { | ||
| var activeFormatStub: (() -> FLTCaptureDeviceFormat)? | ||
| var setActiveFormatStub: ((FLTCaptureDeviceFormat) -> Void)? | ||
| var getTorchModeStub: (() -> AVCaptureDevice.TorchMode)? | ||
|
|
@@ -26,15 +26,15 @@ class MockCaptureDevice: NSObject, FLTCaptureDevice { | |
| var setVideoZoomFactorStub: ((CGFloat) -> Void)? | ||
| var lockForConfigurationStub: (() throws -> Void)? | ||
|
|
||
| var device: AVCaptureDevice { | ||
| var avDevice: AVCaptureDevice { | ||
| preconditionFailure("Attempted to access unimplemented property: device") | ||
| } | ||
|
|
||
| var uniqueID = "" | ||
| var position = AVCaptureDevice.Position.unspecified | ||
| var deviceType = AVCaptureDevice.DeviceType.builtInWideAngleCamera | ||
|
|
||
| var activeFormat: FLTCaptureDeviceFormat { | ||
| var fltActiveFormat: FLTCaptureDeviceFormat { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is |
||
| get { | ||
| activeFormatStub?() ?? MockCaptureDeviceFormat() | ||
| } | ||
|
|
@@ -43,7 +43,7 @@ class MockCaptureDevice: NSObject, FLTCaptureDevice { | |
| } | ||
| } | ||
|
|
||
| var formats: [FLTCaptureDeviceFormat] = [] | ||
| var fltFormats: [FLTCaptureDeviceFormat] = [] | ||
| var hasFlash = false | ||
| var hasTorch = false | ||
| var isTorchAvailable = false | ||
|
|
@@ -78,20 +78,28 @@ class MockCaptureDevice: NSObject, FLTCaptureDevice { | |
| return isFocusModeSupportedStub?(mode) ?? false | ||
| } | ||
|
|
||
| var focusMode: AVCaptureDevice.FocusMode { | ||
| get { .autoFocus } | ||
| set { setFocusModeStub?(newValue) } | ||
| } | ||
|
|
||
| func setFocusMode(_ focusMode: AVCaptureDevice.FocusMode) { | ||
| setFocusModeStub?(focusMode) | ||
| } | ||
|
|
||
| func setFocusPointOfInterest(_ point: CGPoint) { | ||
| setFocusPointOfInterestStub?(point) | ||
| var focusPointOfInterest: CGPoint { | ||
| get { CGPoint.zero } | ||
| set { setFocusPointOfInterestStub?(newValue) } | ||
| } | ||
|
|
||
| func setExposureMode(_ exposureMode: AVCaptureDevice.ExposureMode) { | ||
| setExposureModeStub?(exposureMode) | ||
| var exposureMode: AVCaptureDevice.ExposureMode { | ||
| get { .autoExpose } | ||
| set { setExposureModeStub?(newValue) } | ||
| } | ||
|
|
||
| func setExposurePointOfInterest(_ point: CGPoint) { | ||
| setExposurePointOfInterestStub?(point) | ||
| var exposurePointOfInterest: CGPoint { | ||
| get { CGPoint.zero } | ||
| set { setExposurePointOfInterestStub?(newValue) } | ||
| } | ||
|
|
||
| func setExposureTargetBias(_ bias: Float, completionHandler handler: ((CMTime) -> Void)? = nil) { | ||
|
|
@@ -102,17 +110,11 @@ class MockCaptureDevice: NSObject, FLTCaptureDevice { | |
| return isExposureModeSupportedStub?(mode) ?? false | ||
| } | ||
|
|
||
| func lensAperture() -> Float { | ||
| return 0 | ||
| } | ||
| var lensAperture: Float { 0 } | ||
|
|
||
| func exposureDuration() -> CMTime { | ||
| return CMTime(value: 1, timescale: 1) | ||
| } | ||
| var exposureDuration: CMTime { CMTime(value: 1, timescale: 1) } | ||
|
|
||
| func iso() -> Float { | ||
| return 0 | ||
| } | ||
| var iso: Float { 0 } | ||
|
|
||
| func lockForConfiguration() throws { | ||
| try lockForConfigurationStub?() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.