29 lines
1,005 B
Swift
29 lines
1,005 B
Swift
// Copyright 2013 The Flutter Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import AVFoundation
|
|
|
|
@testable import camera_avfoundation
|
|
|
|
/// Mock implementation of `CameraDeviceDiscoverer` protocol which allows injecting a custom
|
|
/// implementation for session discovery.
|
|
final class MockCameraDeviceDiscoverer: NSObject, CameraDeviceDiscoverer {
|
|
var discoverySessionStub:
|
|
(
|
|
(
|
|
_ deviceTypes: [AVCaptureDevice.DeviceType],
|
|
_ mediaType: AVMediaType,
|
|
_ position: AVCaptureDevice.Position
|
|
) -> [NSObject & CaptureDevice]?
|
|
)?
|
|
|
|
/// A stub that replaces the default implementation of
|
|
/// `discoverySessionWithDeviceTypes:mediaType:position`.
|
|
func discoverySession(
|
|
withDeviceTypes deviceTypes: [AVCaptureDevice.DeviceType], mediaType: AVMediaType,
|
|
position: AVCaptureDevice.Position
|
|
) -> [CaptureDevice] {
|
|
return discoverySessionStub?(deviceTypes, mediaType, position) ?? []
|
|
}
|
|
}
|