This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera] Fix coordinate rotation for setting focus- and exposure points on iOS #4158
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
89675f2
Fix coordinate rotation for setting focus- and exposure points on iOS
BeMacized 09a3f6a
Update packages/camera/camera/CHANGELOG.md
BeMacized 56ea3ac
Fix PR feedback
BeMacized 0570df2
Merge remote-tracking branch 'origin/issue/86468-ios' into issue/8646…
BeMacized 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
57 changes: 57 additions & 0 deletions
57
packages/camera/camera/example/ios/RunnerTests/CameraExposureTests.m
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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| @import camera; | ||
| @import XCTest; | ||
| @import AVFoundation; | ||
| #import <OCMock/OCMock.h> | ||
|
|
||
| @interface FLTCam : NSObject <FlutterTexture, | ||
| AVCaptureVideoDataOutputSampleBufferDelegate, | ||
| AVCaptureAudioDataOutputSampleBufferDelegate> | ||
|
|
||
| - (void)setExposurePointWithResult:(FlutterResult)result x:(double)x y:(double)y; | ||
| @end | ||
|
|
||
| @interface CameraExposureTests : XCTestCase | ||
| @property(readonly, nonatomic) FLTCam *camera; | ||
| @property(readonly, nonatomic) id mockDevice; | ||
| @property(readonly, nonatomic) id mockUIDevice; | ||
| @end | ||
|
|
||
| @implementation CameraExposureTests | ||
|
|
||
| - (void)setUp { | ||
| _camera = [[FLTCam alloc] init]; | ||
| _mockDevice = OCMClassMock([AVCaptureDevice class]); | ||
| _mockUIDevice = OCMPartialMock([UIDevice currentDevice]); | ||
| } | ||
|
|
||
| - (void)tearDown { | ||
| // Put teardown code here. This method is called after the invocation of each test method in the | ||
| // class. | ||
BeMacized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [_mockDevice stopMocking]; | ||
| [_mockUIDevice stopMocking]; | ||
| } | ||
|
|
||
| - (void)testSetExpsourePointWithResult_SetsExposurePointOfInterest { | ||
| // UI is currently in landscape left orientation | ||
| OCMStub([(UIDevice *)_mockUIDevice orientation]).andReturn(UIDeviceOrientationLandscapeLeft); | ||
| // Exposure point of interest is supported | ||
| OCMStub([_mockDevice isExposurePointOfInterestSupported]).andReturn(true); | ||
| // Set mock device as the current capture device | ||
| [_camera setValue:_mockDevice forKey:@"captureDevice"]; | ||
|
|
||
| // Run test | ||
| [_camera | ||
| setExposurePointWithResult:^void(id _Nullable result) { | ||
| } | ||
| x:1 | ||
| y:1]; | ||
|
|
||
| // Verify the focus point of interest has been set | ||
| OCMVerify([_mockDevice setExposurePointOfInterest:CGPointMake(1, 1)]); | ||
| } | ||
|
|
||
| @end | ||
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
54 changes: 54 additions & 0 deletions
54
packages/camera/camera/example/ios/RunnerTests/CameraUtilTests.m
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 |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| @import camera; | ||
| @import XCTest; | ||
| @import AVFoundation; | ||
| #import <OCMock/OCMock.h> | ||
|
|
||
| @interface FLTCam : NSObject <FlutterTexture, | ||
| AVCaptureVideoDataOutputSampleBufferDelegate, | ||
| AVCaptureAudioDataOutputSampleBufferDelegate> | ||
|
|
||
| - (CGPoint)getCGPointForCoordsWithOrientation:(UIDeviceOrientation)orientation | ||
| x:(double)x | ||
| y:(double)y; | ||
|
|
||
| @end | ||
|
|
||
| @interface CameraUtilTests : XCTestCase | ||
| @property(readonly, nonatomic) FLTCam *camera; | ||
|
|
||
| @end | ||
|
|
||
| @implementation CameraUtilTests | ||
|
|
||
| - (void)setUp { | ||
| _camera = [[FLTCam alloc] init]; | ||
| } | ||
|
|
||
| - (void)tearDown { | ||
| // Put teardown code here. This method is called after the invocation of each test method in the | ||
| // class. | ||
| } | ||
|
|
||
| - (void)testGetCGPointForCoordsWithOrientation_ShouldRotateCoords { | ||
| CGPoint point; | ||
| point = [_camera getCGPointForCoordsWithOrientation:UIDeviceOrientationLandscapeLeft x:1 y:1]; | ||
| XCTAssertTrue(CGPointEqualToPoint(point, CGPointMake(1, 1)), | ||
| @"Resulting coordinates are invalid."); | ||
| point = [_camera getCGPointForCoordsWithOrientation:UIDeviceOrientationPortrait x:0 y:1]; | ||
| XCTAssertTrue(CGPointEqualToPoint(point, CGPointMake(1, 1)), | ||
| @"Resulting coordinates are invalid."); | ||
| point = [_camera getCGPointForCoordsWithOrientation:UIDeviceOrientationLandscapeRight x:0 y:0]; | ||
| XCTAssertTrue(CGPointEqualToPoint(point, CGPointMake(1, 1)), | ||
| @"Resulting coordinates are invalid."); | ||
| point = [_camera getCGPointForCoordsWithOrientation:UIDeviceOrientationPortraitUpsideDown | ||
| x:1 | ||
| y:0]; | ||
| XCTAssertTrue(CGPointEqualToPoint(point, CGPointMake(1, 1)), | ||
| @"Resulting coordinates are invalid."); | ||
| } | ||
|
|
||
| @end |
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
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.