Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class FLTCamExposureTests: XCTestCase {
func testSetExposurePoint_setsExposurePointOfInterest() {
let (camera, mockDevice, mockDeviceOrientationProvider) = createCamera()
// UI is currently in landscape left orientation.
mockDeviceOrientationProvider.orientation = .landscapeLeft
mockDeviceOrientationProvider.orientationStub = { .landscapeLeft }
// Exposure point of interest is supported.
mockDevice.isExposurePointOfInterestSupported = true

Expand All @@ -87,7 +87,7 @@ final class FLTCamExposureTests: XCTestCase {
func testSetExposurePoint_returnsError_ifNotSupported() {
let (camera, mockDevice, mockDeviceOrientationProvider) = createCamera()
// UI is currently in landscape left orientation.
mockDeviceOrientationProvider.orientation = .landscapeLeft
mockDeviceOrientationProvider.orientationStub = { .landscapeLeft }
// Exposure point of interest is not supported.
mockDevice.isExposurePointOfInterestSupported = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ final class FLTCamSetFocusModeTests: XCTestCase {
func testSetFocusPointWithResult_SetsFocusPointOfInterest() {
let (camera, mockDevice, mockDeviceOrientationProvider) = createCamera()
// UI is currently in landscape left orientation.
mockDeviceOrientationProvider.orientation = .landscapeLeft
mockDeviceOrientationProvider.orientationStub = { .landscapeLeft }
// Focus point of interest is supported.
mockDevice.isFocusPointOfInterestSupported = true

Expand All @@ -143,7 +143,7 @@ final class FLTCamSetFocusModeTests: XCTestCase {
func testSetFocusPoint_WhenNotSupported_ReturnsError() {
let (camera, mockDevice, mockDeviceOrientationProvider) = createCamera()
// UI is currently in landscape left orientation.
mockDeviceOrientationProvider.orientation = .landscapeLeft
mockDeviceOrientationProvider.orientationStub = { .landscapeLeft }
// Focus point of interest is not supported.
mockDevice.isFocusPointOfInterestSupported = false

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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.

/// Mock implementation of `FLTCameraDeviceDiscovering` protocol which allows injecting a custom
/// implementation for session discovery.
final class MockCameraDeviceDiscoverer: NSObject, FLTCameraDeviceDiscovering {
var discoverySessionStub:
(
(
_ deviceTypes: [AVCaptureDevice.DeviceType],
_ mediaType: AVMediaType,
_ position: AVCaptureDevice.Position
) -> [NSObject & FLTCaptureDevice]?
)?

/// A stub that replaces the default implementation of
/// `discoverySessionWithDeviceTypes:mediaType:position`.
func discoverySession(
withDeviceTypes deviceTypes: [AVCaptureDevice.DeviceType], mediaType: AVMediaType,
position: AVCaptureDevice.Position
) -> [FLTCaptureDevice] {
return discoverySessionStub?(deviceTypes, mediaType, position) ?? []
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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.

/// A mock implementation of `FLTCaptureConnection` that allows injecting a custom implementation.
final class MockCaptureConnection: NSObject, FLTCaptureConnection {
var setVideoOrientationStub: ((AVCaptureVideoOrientation) -> Void)?

var connection: AVCaptureConnection {
preconditionFailure("Attempted to access unimplemented property: connection")
}
var isVideoMirrored = false
var videoOrientation: AVCaptureVideoOrientation {
get { AVCaptureVideoOrientation.portrait }
set {
setVideoOrientationStub?(newValue)
}
}
var inputPorts: [AVCaptureInput.Port] = []
var isVideoMirroringSupported = false
var isVideoOrientationSupported = false
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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.

/// A mock implementation of `FLTCaptureDeviceFormat` that allows mocking the class
/// properties.
final class MockCaptureDeviceFormat: NSObject, FLTCaptureDeviceFormat {

/// The format associated with the capture device.
var format: AVCaptureDevice.Format {
preconditionFailure("Attempted to access unimplemented property: format")
}

var _formatDescription: CMVideoFormatDescription?

/// The format description for the capture device.
var formatDescription: CMFormatDescription {
_formatDescription!
}

/// The array of frame rate ranges supported by the video format.
var videoSupportedFrameRateRanges: [FLTFrameRateRange] = []

override init() {
super.init()

CMVideoFormatDescriptionCreate(
allocator: kCFAllocatorDefault, codecType: kCVPixelFormatType_32BGRA, width: 1920,
height: 1080, extensions: nil, formatDescriptionOut: &_formatDescription)
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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 AVFoundation

/// Mock implementation of `FLTCapturePhotoOutput` protocol which allows injecting a custom
/// implementation.
final class MockCapturePhotoOutput: NSObject, FLTCapturePhotoOutput {
var avOutput = AVCapturePhotoOutput()
var availablePhotoCodecTypes: [AVVideoCodecType] = []
var highResolutionCaptureEnabled = false
var supportedFlashModes: [NSNumber] = []

// Stub that is called when the corresponding public method is called.
var capturePhotoWithSettingsStub:
((_ settings: AVCapturePhotoSettings, _ delegate: AVCapturePhotoCaptureDelegate) -> Void)?

// Stub that is called when the corresponding public method is called.
var connectionWithMediaTypeStub: ((_ mediaType: AVMediaType) -> FLTCaptureConnection?)?

func capturePhoto(with settings: AVCapturePhotoSettings, delegate: AVCapturePhotoCaptureDelegate)
{
capturePhotoWithSettingsStub?(settings, delegate)
}

func connection(withMediaType mediaType: AVMediaType) -> FLTCaptureConnection? {
return connectionWithMediaTypeStub?(mediaType)
}
}

This file was deleted.

Loading