22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- import camera_avfoundation
5+ @ testable import camera_avfoundation
66
77// Import Objectice-C part of the implementation when SwiftPM is used.
88#if canImport(camera_avfoundation_objc)
99 import camera_avfoundation_objc
1010#endif
1111
12- final class MockCamera : FLTCam {
12+ final class MockCamera : NSObject , Camera {
1313 var setDartApiStub : ( ( FCPCameraEventApi ? ) -> Void ) ?
1414 var setOnFrameAvailableStub : ( ( ( ( ) -> Void ) ? ) -> Void ) ?
1515 var getMinimumExposureOffsetStub : ( ( ) -> CGFloat ) ?
@@ -42,7 +42,7 @@ final class MockCamera: FLTCam {
4242 var startImageStreamStub : ( ( FlutterBinaryMessenger ) -> Void ) ?
4343 var stopImageStreamStub : ( ( ) -> Void ) ?
4444
45- override var dartAPI : FCPCameraEventApi {
45+ var dartAPI : FCPCameraEventApi ? {
4646 get {
4747 preconditionFailure ( " Attempted to access unimplemented property: dartAPI " )
4848 }
@@ -51,7 +51,7 @@ final class MockCamera: FLTCam {
5151 }
5252 }
5353
54- override var onFrameAvailable : ( ( ) -> Void ) {
54+ var onFrameAvailable : ( ( ) -> Void ) ? {
5555 get {
5656 preconditionFailure ( " Attempted to access unimplemented property: onFrameAvailable " )
5757 }
@@ -60,147 +60,149 @@ final class MockCamera: FLTCam {
6060 }
6161 }
6262
63- override var minimumExposureOffset : CGFloat {
63+ var videoFormat : FourCharCode = kCVPixelFormatType_32BGRA
64+
65+ var isPreviewPaused : Bool = false
66+
67+ var minimumExposureOffset : CGFloat {
6468 return getMinimumExposureOffsetStub ? ( ) ?? 0
6569 }
6670
67- override var maximumExposureOffset : CGFloat {
71+ var maximumExposureOffset : CGFloat {
6872 return getMaximumExposureOffsetStub ? ( ) ?? 0
6973 }
7074
71- override var minimumAvailableZoomFactor : CGFloat {
75+ var minimumAvailableZoomFactor : CGFloat {
7276 return getMinimumAvailableZoomFactorStub ? ( ) ?? 0
7377 }
7478
75- override var maximumAvailableZoomFactor : CGFloat {
79+ var maximumAvailableZoomFactor : CGFloat {
7680 return getMaximumAvailableZoomFactorStub ? ( ) ?? 0
7781 }
7882
79- override func setUpCaptureSessionForAudioIfNeeded( ) {
83+ func setUpCaptureSessionForAudioIfNeeded( ) {
8084 setUpCaptureSessionForAudioIfNeededStub ? ( )
8185 }
8286
83- override func reportInitializationState( ) { }
87+ func reportInitializationState( ) { }
8488
85- override func receivedImageStreamData( ) {
89+ func receivedImageStreamData( ) {
8690 receivedImageStreamDataStub ? ( )
8791 }
8892
89- override func start( ) {
93+ func start( ) {
9094 startStub ? ( )
9195 }
9296
93- override func stop( ) { }
97+ func stop( ) { }
9498
95- override func startVideoRecording(
99+ func startVideoRecording(
96100 completion: @escaping ( FlutterError ? ) -> Void ,
97101 messengerForStreaming messenger: FlutterBinaryMessenger ?
98102 ) {
99103 startVideoRecordingStub ? ( completion, messenger)
100104 }
101105
102- override func pauseVideoRecording( ) {
106+ func pauseVideoRecording( ) {
103107 pauseVideoRecordingStub ? ( )
104108 }
105109
106- override func resumeVideoRecording( ) {
110+ func resumeVideoRecording( ) {
107111 resumeVideoRecordingStub ? ( )
108112 }
109113
110- override func stopVideoRecording( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
114+ func stopVideoRecording( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
111115 stopVideoRecordingStub ? ( completion)
112116 }
113117
114- override func captureToFile( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
118+ func captureToFile( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
115119 captureToFileStub ? ( completion)
116120 }
117121
118- override func setDeviceOrientation( _ orientation: UIDeviceOrientation ) {
122+ func setDeviceOrientation( _ orientation: UIDeviceOrientation ) {
119123 setDeviceOrientationStub ? ( orientation)
120124 }
121125
122- override func lockCaptureOrientation( _ orientation: FCPPlatformDeviceOrientation ) {
126+ func lockCaptureOrientation( _ orientation: FCPPlatformDeviceOrientation ) {
123127 lockCaptureOrientationStub ? ( orientation)
124128 }
125129
126- override func unlockCaptureOrientation( ) {
130+ func unlockCaptureOrientation( ) {
127131 unlockCaptureOrientationStub ? ( )
128132 }
129133
130- override func setImageFileFormat( _ fileFormat: FCPPlatformImageFileFormat ) {
134+ func setImageFileFormat( _ fileFormat: FCPPlatformImageFileFormat ) {
131135 setImageFileFormatStub ? ( fileFormat)
132136 }
133137
134- override func setExposureMode( _ mode: FCPPlatformExposureMode ) {
138+ func setExposureMode( _ mode: FCPPlatformExposureMode ) {
135139 setExposureModeStub ? ( mode)
136140 }
137141
138- override func setExposureOffset( _ offset: Double ) {
142+ func setExposureOffset( _ offset: Double ) {
139143 setExposureOffsetStub ? ( offset)
140144 }
141145
142- override func setExposurePoint(
146+ func setExposurePoint(
143147 _ point: FCPPlatformPoint ? , withCompletion: @escaping ( FlutterError ? ) -> Void
144148 ) {
145149 setExposurePointStub ? ( point, withCompletion)
146150 }
147151
148- override func setFocusMode( _ mode: FCPPlatformFocusMode ) {
152+ func setFocusMode( _ mode: FCPPlatformFocusMode ) {
149153 setFocusModeStub ? ( mode)
150154 }
151155
152- override func setFocusPoint(
153- _ point: FCPPlatformPoint ? , completion: @escaping ( FlutterError ? ) -> Void
154- ) {
156+ func setFocusPoint( _ point: FCPPlatformPoint ? , completion: @escaping ( FlutterError ? ) -> Void ) {
155157 setFocusPointStub ? ( point, completion)
156158 }
157159
158- override func setZoomLevel(
160+ func setZoomLevel(
159161 _ zoom: CGFloat ,
160162 withCompletion completion: @escaping ( FlutterError ? ) -> Void
161163 ) {
162164 setZoomLevelStub ? ( zoom, completion)
163165 }
164166
165- override func setFlashMode(
167+ func setFlashMode(
166168 _ mode: FCPPlatformFlashMode ,
167169 withCompletion completion: @escaping ( FlutterError ? ) -> Void
168170 ) {
169171 setFlashModeStub ? ( mode, completion)
170172 }
171173
172- override func pausePreview( ) {
174+ func pausePreview( ) {
173175 pausePreviewStub ? ( )
174176 }
175177
176- override func resumePreview( ) {
178+ func resumePreview( ) {
177179 resumePreviewStub ? ( )
178180 }
179181
180- override func setDescriptionWhileRecording(
182+ func setDescriptionWhileRecording(
181183 _ cameraName: String ,
182184 withCompletion completion: @escaping ( FlutterError ? ) -> Void
183185 ) {
184186 setDescriptionWhileRecordingStub ? ( cameraName, completion)
185187 }
186188
187- override func startImageStream( with messenger: FlutterBinaryMessenger ) {
189+ func startImageStream( with messenger: FlutterBinaryMessenger ) {
188190 startImageStreamStub ? ( messenger)
189191 }
190192
191- override func stopImageStream( ) {
193+ func stopImageStream( ) {
192194 stopImageStreamStub ? ( )
193195 }
194196
195- override func captureOutput(
197+ func captureOutput(
196198 _ output: AVCaptureOutput ,
197199 didOutput sampleBuffer: CMSampleBuffer ,
198200 from connection: AVCaptureConnection
199201 ) { }
200202
201- override func close( ) { }
203+ func close( ) { }
202204
203- override func copyPixelBuffer( ) -> Unmanaged < CVPixelBuffer > ? {
205+ func copyPixelBuffer( ) -> Unmanaged < CVPixelBuffer > ? {
204206 return nil
205207 }
206208}
0 commit comments