Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5070536
Introduce protocols and remove OCMock from CameraFocusTests
mchudy Dec 27, 2024
335deed
Migrate CameraExposureTests
mchudy Dec 6, 2024
ca581d7
Format code
mchudy Dec 27, 2024
2e3c8e7
Use DI for mocking dependencies
mchudy Dec 30, 2024
c96e9da
Fix CI
mchudy Dec 30, 2024
7155838
Fix imports
mchudy Dec 30, 2024
3cd5341
Fix imports
mchudy Dec 30, 2024
8256579
Another try to fix imports
mchudy Dec 30, 2024
27f31c0
Change order in modulemap
mchudy Dec 30, 2024
7a25909
Add FLTCamMediaSettingsAVWrapper to module map
mchudy Dec 30, 2024
cdb1578
Remove new protocols from modulemap
mchudy Dec 31, 2024
486686a
Add header search path
mchudy Dec 31, 2024
2a070ca
Fix formatting
mchudy Dec 31, 2024
04f1e8b
Flatten the structure
mchudy Jan 2, 2025
0d81c7f
Remove OCMock from CameraOrientationTests
mchudy Jan 2, 2025
bb1cf1a
Add protocol for event channel
mchudy Jan 2, 2025
de26f9c
Remove OCMock from ThreadSafeEventChannelTests
mchudy Jan 2, 2025
4b45f30
Introduce FLTCameraDeviceDiscovering
mchudy Jan 2, 2025
abb1fdb
Update changelog
mchudy Jan 2, 2025
96e300a
Make default implementations for protocols and clean up the DI to mak…
mchudy Jan 3, 2025
88f9fe6
Introduce new protocol for creating capture inputs
mchudy Jan 6, 2025
0063b6f
Fix DI and tests
mchudy Jan 7, 2025
327233d
Rename FLTCaptureDeviceControlling to FLTCaptureDevice
mchudy Jan 9, 2025
8235080
Merge remote-tracking branch 'upstream/main' into feature/camera-ocmo…
mchudy Jan 14, 2025
37bb576
Merge remote-tracking branch 'upstream/main' into feature/camera-ocmo…
mchudy Jan 24, 2025
6cdf473
Fix conflicts
mchudy Jan 24, 2025
469bc8e
Add doc comments
mchudy Jan 24, 2025
5ea3480
Rename property
mchudy Jan 24, 2025
7f20088
Fix formatting
mchudy Jan 24, 2025
64c3d1f
Code cleanup
mchudy Jan 30, 2025
1ad5966
Fix warning with nils being passed in tests by introducing new mocks
mchudy Jan 31, 2025
40cce59
Reintroduce default protocol wrappers and rely on NSObject for safer …
mchudy Feb 2, 2025
fc0e826
Fix nits
mchudy Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format code
  • Loading branch information
mchudy committed Dec 30, 2024
commit ca581d79a80667f5dca7f1492364433c452aecbe
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ - (void)setUp {
_camera = [[FLTCam alloc] init];
_mockDevice = [[MockCaptureDeviceController alloc] init];
_mockDeviceOrientationProvider = [[MockDeviceOrientationProvider alloc] init];

[_camera setValue:_mockDevice forKey:@"captureDevice"];
[_camera setValue:_mockDeviceOrientationProvider forKey:@"deviceOrientationProvider"];
}
Expand All @@ -31,7 +31,7 @@ - (void)testSetExposurePointWithResult_SetsExposurePointOfInterest {
_mockDeviceOrientationProvider.orientation = UIDeviceOrientationLandscapeLeft;
// Exposure point of interest is supported
_mockDevice.isExposurePointOfInterestSupported = YES;

// Verify the focus point of interest has been set
__block CGPoint setPoint = CGPointZero;
_mockDevice.setExposurePointOfInterestStub = ^(CGPoint point) {
Expand All @@ -43,9 +43,9 @@ - (void)testSetExposurePointWithResult_SetsExposurePointOfInterest {
// Run test
XCTestExpectation *completionExpectation = [self expectationWithDescription:@"Completion called"];
[_camera setExposurePoint:[FCPPlatformPoint makeWithX:1 y:1]
withCompletion:^(FlutterError * _Nullable error) {
XCTAssertNil(error);
[completionExpectation fulfill];
withCompletion:^(FlutterError *_Nullable error) {
XCTAssertNil(error);
[completionExpectation fulfill];
}];

[self waitForExpectationsWithTimeout:1 handler:nil];
Expand All @@ -58,18 +58,19 @@ - (void)testSetExposurePoint_WhenNotSupported_ReturnsError {
_mockDeviceOrientationProvider.orientation = UIDeviceOrientationLandscapeLeft;
// Exposure point of interest is not supported
_mockDevice.isExposurePointOfInterestSupported = NO;

XCTestExpectation *expectation = [self expectationWithDescription:@"Completion with error"];

// Run
[_camera setExposurePoint:[FCPPlatformPoint makeWithX:1 y:1]
withCompletion:^(FlutterError *_Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqualObjects(error.code, @"setExposurePointFailed");
XCTAssertEqualObjects(error.message, @"Device does not have exposure point capabilities");
[expectation fulfill];
}];

[_camera
setExposurePoint:[FCPPlatformPoint makeWithX:1 y:1]
withCompletion:^(FlutterError *_Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqualObjects(error.code, @"setExposurePointFailed");
XCTAssertEqualObjects(error.message, @"Device does not have exposure point capabilities");
[expectation fulfill];
}];

// Verify
[self waitForExpectationsWithTimeout:1 handler:nil];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ - (void)setUp {
_camera = [[FLTCam alloc] init];
_mockDevice = [[MockCaptureDeviceController alloc] init];
_mockDeviceOrientationProvider = [[MockDeviceOrientationProvider alloc] init];

[_camera setValue:_mockDevice forKey:@"captureDevice"];
[_camera setValue:_mockDeviceOrientationProvider forKey:@"deviceOrientationProvider"];
}
Expand All @@ -34,7 +34,7 @@ - (void)testAutoFocusWithContinuousModeSupported_ShouldSetContinuousAutoFocus {
_mockDevice.isFocusModeSupportedStub = ^BOOL(AVCaptureFocusMode mode) {
return mode == AVCaptureFocusModeContinuousAutoFocus || mode == AVCaptureFocusModeAutoFocus;
};

__block BOOL setFocusModeContinuousAutoFocusCalled = NO;

_mockDevice.setFocusModeStub = ^(AVCaptureFocusMode mode) {
Expand All @@ -59,9 +59,9 @@ - (void)testAutoFocusWithContinuousModeNotSupported_ShouldSetAutoFocus {
_mockDevice.isFocusModeSupportedStub = ^BOOL(AVCaptureFocusMode mode) {
return mode == AVCaptureFocusModeAutoFocus;
};

__block BOOL setFocusModeAutoFocusCalled = NO;

// Don't expect setFocusMode:AVCaptureFocusModeContinuousAutoFocus
_mockDevice.setFocusModeStub = ^(AVCaptureFocusMode mode) {
if (mode == AVCaptureFocusModeContinuousAutoFocus) {
Expand All @@ -70,10 +70,10 @@ - (void)testAutoFocusWithContinuousModeNotSupported_ShouldSetAutoFocus {
setFocusModeAutoFocusCalled = YES;
}
};

// Run test
[_camera applyFocusMode:FCPPlatformFocusModeAuto onDevice:_mockDevice];

// Expect setFocusMode:AVCaptureFocusModeAutoFocus
XCTAssertTrue(setFocusModeAutoFocusCalled);
}
Expand All @@ -86,7 +86,7 @@ - (void)testAutoFocusWithNoModeSupported_ShouldSetNothing {

// Don't expect any setFocus
_mockDevice.setFocusModeStub = ^(AVCaptureFocusMode mode) {
XCTFail(@"Unexpected call to setFocusMode");
XCTFail(@"Unexpected call to setFocusMode");
};

// Run test
Expand All @@ -98,7 +98,7 @@ - (void)testLockedFocusWithModeSupported_ShouldSetModeAutoFocus {
_mockDevice.isFocusModeSupportedStub = ^BOOL(AVCaptureFocusMode mode) {
return mode == AVCaptureFocusModeContinuousAutoFocus || mode == AVCaptureFocusModeAutoFocus;
};

__block BOOL setFocusModeAutoFocusCalled = NO;

// Expect only setFocusMode:AVCaptureFocusModeAutoFocus
Expand All @@ -109,7 +109,7 @@ - (void)testLockedFocusWithModeSupported_ShouldSetModeAutoFocus {
setFocusModeAutoFocusCalled = YES;
}
};

// Run test
[_camera applyFocusMode:FCPPlatformFocusModeLocked onDevice:_mockDevice];

Expand All @@ -123,7 +123,7 @@ - (void)testLockedFocusWithModeNotSupported_ShouldSetNothing {

// Don't expect any setFocus
_mockDevice.setFocusModeStub = ^(AVCaptureFocusMode mode) {
XCTFail(@"Unexpected call to setFocusMode");
XCTFail(@"Unexpected call to setFocusMode");
};

// Run test
Expand Down Expand Up @@ -157,18 +157,18 @@ - (void)testSetFocusPoint_WhenNotSupported_ReturnsError {
_mockDeviceOrientationProvider.orientation = UIDeviceOrientationLandscapeLeft;
// Exposure point of interest is not supported
_mockDevice.isFocusPointOfInterestSupported = NO;

XCTestExpectation *expectation = [self expectationWithDescription:@"Completion with error"];

// Run
[_camera setFocusPoint:[FCPPlatformPoint makeWithX:1 y:1]
withCompletion:^(FlutterError *_Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqualObjects(error.code, @"setFocusPointFailed");
XCTAssertEqualObjects(error.message, @"Device does not have focus point capabilities");
[expectation fulfill];
}];
withCompletion:^(FlutterError *_Nullable error) {
XCTAssertNotNil(error);
XCTAssertEqualObjects(error.code, @"setFocusPointFailed");
XCTAssertEqualObjects(error.message, @"Device does not have focus point capabilities");
[expectation fulfill];
}];

// Verify
[self waitForExpectationsWithTimeout:1 handler:nil];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ - (void)testOrientationUpdateMustBeOnCaptureSessionQueue {
(void *)captureSessionQueueSpecific, NULL);
FLTCam *mockCam = OCMClassMock([FLTCam class]);
camera.camera = mockCam;

OCMStub([mockCam setDeviceOrientation:UIDeviceOrientationLandscapeLeft])
.andDo(^(NSInvocation *invocation) {
if (dispatch_get_specific(captureSessionQueueSpecific)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,18 @@
OCMStub([audioSessionMock addInputWithNoConnections:[OCMArg any]]);
OCMStub([audioSessionMock canSetSessionPreset:[OCMArg any]]).andReturn(YES);

return [[FLTCam alloc] initWithMediaSettings:FCPGetDefaultMediaSettings(resolutionPreset)
mediaSettingsAVWrapper:[[FLTCamMediaSettingsAVWrapper alloc] init]
orientation:UIDeviceOrientationPortrait
videoCaptureSession:captureSession
audioCaptureSession:audioSessionMock
captureSessionQueue:dispatch_queue_create("capture_session_queue", NULL)
captureDeviceFactory:^id<FLTCaptureDeviceControlling>(void) {
return [[FLTDefaultCaptureDeviceController alloc] initWithDevice:captureDevice]; }
videoDimensionsForFormat:videoDimensionsForFormat
error:nil];
return [[FLTCam alloc]
initWithMediaSettings:FCPGetDefaultMediaSettings(resolutionPreset)
mediaSettingsAVWrapper:[[FLTCamMediaSettingsAVWrapper alloc] init]
orientation:UIDeviceOrientationPortrait
videoCaptureSession:captureSession
audioCaptureSession:audioSessionMock
captureSessionQueue:dispatch_queue_create("capture_session_queue", NULL)
captureDeviceFactory:^id<FLTCaptureDeviceControlling>(void) {
return [[FLTDefaultCaptureDeviceController alloc] initWithDevice:captureDevice];
}
videoDimensionsForFormat:videoDimensionsForFormat
error:nil];
}

CMSampleBufferRef FLTCreateTestSampleBuffer(void) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ - (void)testCaptureToFile_handlesTorchMode {
dispatch_queue_set_specific(captureSessionQueue, FLTCaptureSessionQueueSpecific,
(void *)FLTCaptureSessionQueueSpecific, NULL);

FLTCam *cam = FLTCreateCamWithCaptureSessionQueueAndMediaSettings(captureSessionQueue, nil, nil,
^id<FLTCaptureDeviceControlling>(void) {
return
[[FLTDefaultCaptureDeviceController alloc] initWithDevice:captureDeviceMock];
});
FLTCam *cam = FLTCreateCamWithCaptureSessionQueueAndMediaSettings(
captureSessionQueue, nil, nil, ^id<FLTCaptureDeviceControlling>(void) {
return [[FLTDefaultCaptureDeviceController alloc] initWithDevice:captureDeviceMock];
});

AVCapturePhotoSettings *settings = [AVCapturePhotoSettings photoSettings];
id mockSettings = OCMClassMock([AVCapturePhotoSettings class]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy) void (^setExposurePointOfInterestStub)(CGPoint point);
@property(nonatomic, assign) float minExposureTargetBias;
@property(nonatomic, assign) float maxExposureTargetBias;
@property(nonatomic, copy) void (^setExposureTargetBiasStub)(float bias, void (^_Nullable handler)(CMTime));
@property(nonatomic, copy) void (^setExposureTargetBiasStub)
(float bias, void (^_Nullable handler)(CMTime));

// Zoom
@property(nonatomic, assign) float maxAvailableVideoZoomFactor;
Expand Down
Loading