22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- @ testable import camera_avfoundation
5+ 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 : NSObject , Camera {
12+ final class MockCamera : FLTCam {
1313 var setDartApiStub : ( ( FCPCameraEventApi ? ) -> Void ) ?
1414 var setOnFrameAvailableStub : ( ( ( ( ) -> Void ) ? ) -> Void ) ?
1515 var getMinimumExposureOffsetStub : ( ( ) -> CGFloat ) ?
@@ -42,7 +42,7 @@ final class MockCamera: NSObject, Camera {
4242 var startImageStreamStub : ( ( FlutterBinaryMessenger ) -> Void ) ?
4343 var stopImageStreamStub : ( ( ) -> Void ) ?
4444
45- var dartAPI : FCPCameraEventApi ? {
45+ override var dartAPI : FCPCameraEventApi {
4646 get {
4747 preconditionFailure ( " Attempted to access unimplemented property: dartAPI " )
4848 }
@@ -51,7 +51,7 @@ final class MockCamera: NSObject, Camera {
5151 }
5252 }
5353
54- var onFrameAvailable : ( ( ) -> Void ) ? {
54+ override var onFrameAvailable : ( ( ) -> Void ) {
5555 get {
5656 preconditionFailure ( " Attempted to access unimplemented property: onFrameAvailable " )
5757 }
@@ -60,149 +60,147 @@ final class MockCamera: NSObject, Camera {
6060 }
6161 }
6262
63- var videoFormat : FourCharCode = kCVPixelFormatType_32BGRA
64-
65- var isPreviewPaused : Bool = false
66-
67- var minimumExposureOffset : CGFloat {
63+ override var minimumExposureOffset : CGFloat {
6864 return getMinimumExposureOffsetStub ? ( ) ?? 0
6965 }
7066
71- var maximumExposureOffset : CGFloat {
67+ override var maximumExposureOffset : CGFloat {
7268 return getMaximumExposureOffsetStub ? ( ) ?? 0
7369 }
7470
75- var minimumAvailableZoomFactor : CGFloat {
71+ override var minimumAvailableZoomFactor : CGFloat {
7672 return getMinimumAvailableZoomFactorStub ? ( ) ?? 0
7773 }
7874
79- var maximumAvailableZoomFactor : CGFloat {
75+ override var maximumAvailableZoomFactor : CGFloat {
8076 return getMaximumAvailableZoomFactorStub ? ( ) ?? 0
8177 }
8278
83- func setUpCaptureSessionForAudioIfNeeded( ) {
79+ override func setUpCaptureSessionForAudioIfNeeded( ) {
8480 setUpCaptureSessionForAudioIfNeededStub ? ( )
8581 }
8682
87- func reportInitializationState( ) { }
83+ override func reportInitializationState( ) { }
8884
89- func receivedImageStreamData( ) {
85+ override func receivedImageStreamData( ) {
9086 receivedImageStreamDataStub ? ( )
9187 }
9288
93- func start( ) {
89+ override func start( ) {
9490 startStub ? ( )
9591 }
9692
97- func stop( ) { }
93+ override func stop( ) { }
9894
99- func startVideoRecording(
95+ override func startVideoRecording(
10096 completion: @escaping ( FlutterError ? ) -> Void ,
10197 messengerForStreaming messenger: FlutterBinaryMessenger ?
10298 ) {
10399 startVideoRecordingStub ? ( completion, messenger)
104100 }
105101
106- func pauseVideoRecording( ) {
102+ override func pauseVideoRecording( ) {
107103 pauseVideoRecordingStub ? ( )
108104 }
109105
110- func resumeVideoRecording( ) {
106+ override func resumeVideoRecording( ) {
111107 resumeVideoRecordingStub ? ( )
112108 }
113109
114- func stopVideoRecording( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
110+ override func stopVideoRecording( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
115111 stopVideoRecordingStub ? ( completion)
116112 }
117113
118- func captureToFile( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
114+ override func captureToFile( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
119115 captureToFileStub ? ( completion)
120116 }
121117
122- func setDeviceOrientation( _ orientation: UIDeviceOrientation ) {
118+ override func setDeviceOrientation( _ orientation: UIDeviceOrientation ) {
123119 setDeviceOrientationStub ? ( orientation)
124120 }
125121
126- func lockCaptureOrientation( _ orientation: FCPPlatformDeviceOrientation ) {
122+ override func lockCaptureOrientation( _ orientation: FCPPlatformDeviceOrientation ) {
127123 lockCaptureOrientationStub ? ( orientation)
128124 }
129125
130- func unlockCaptureOrientation( ) {
126+ override func unlockCaptureOrientation( ) {
131127 unlockCaptureOrientationStub ? ( )
132128 }
133129
134- func setImageFileFormat( _ fileFormat: FCPPlatformImageFileFormat ) {
130+ override func setImageFileFormat( _ fileFormat: FCPPlatformImageFileFormat ) {
135131 setImageFileFormatStub ? ( fileFormat)
136132 }
137133
138- func setExposureMode( _ mode: FCPPlatformExposureMode ) {
134+ override func setExposureMode( _ mode: FCPPlatformExposureMode ) {
139135 setExposureModeStub ? ( mode)
140136 }
141137
142- func setExposureOffset( _ offset: Double ) {
138+ override func setExposureOffset( _ offset: Double ) {
143139 setExposureOffsetStub ? ( offset)
144140 }
145141
146- func setExposurePoint(
142+ override func setExposurePoint(
147143 _ point: FCPPlatformPoint ? , withCompletion: @escaping ( FlutterError ? ) -> Void
148144 ) {
149145 setExposurePointStub ? ( point, withCompletion)
150146 }
151147
152- func setFocusMode( _ mode: FCPPlatformFocusMode ) {
148+ override func setFocusMode( _ mode: FCPPlatformFocusMode ) {
153149 setFocusModeStub ? ( mode)
154150 }
155151
156- func setFocusPoint( _ point: FCPPlatformPoint ? , completion: @escaping ( FlutterError ? ) -> Void ) {
152+ override func setFocusPoint(
153+ _ point: FCPPlatformPoint ? , completion: @escaping ( FlutterError ? ) -> Void
154+ ) {
157155 setFocusPointStub ? ( point, completion)
158156 }
159157
160- func setZoomLevel(
158+ override func setZoomLevel(
161159 _ zoom: CGFloat ,
162160 withCompletion completion: @escaping ( FlutterError ? ) -> Void
163161 ) {
164162 setZoomLevelStub ? ( zoom, completion)
165163 }
166164
167- func setFlashMode(
165+ override func setFlashMode(
168166 _ mode: FCPPlatformFlashMode ,
169167 withCompletion completion: @escaping ( FlutterError ? ) -> Void
170168 ) {
171169 setFlashModeStub ? ( mode, completion)
172170 }
173171
174- func pausePreview( ) {
172+ override func pausePreview( ) {
175173 pausePreviewStub ? ( )
176174 }
177175
178- func resumePreview( ) {
176+ override func resumePreview( ) {
179177 resumePreviewStub ? ( )
180178 }
181179
182- func setDescriptionWhileRecording(
180+ override func setDescriptionWhileRecording(
183181 _ cameraName: String ,
184182 withCompletion completion: @escaping ( FlutterError ? ) -> Void
185183 ) {
186184 setDescriptionWhileRecordingStub ? ( cameraName, completion)
187185 }
188186
189- func startImageStream( with messenger: FlutterBinaryMessenger ) {
187+ override func startImageStream( with messenger: FlutterBinaryMessenger ) {
190188 startImageStreamStub ? ( messenger)
191189 }
192190
193- func stopImageStream( ) {
191+ override func stopImageStream( ) {
194192 stopImageStreamStub ? ( )
195193 }
196194
197- func captureOutput(
195+ override func captureOutput(
198196 _ output: AVCaptureOutput ,
199197 didOutput sampleBuffer: CMSampleBuffer ,
200198 from connection: AVCaptureConnection
201199 ) { }
202200
203- func close( ) { }
201+ override func close( ) { }
204202
205- func copyPixelBuffer( ) -> Unmanaged < CVPixelBuffer > ? {
203+ override func copyPixelBuffer( ) -> Unmanaged < CVPixelBuffer > ? {
206204 return nil
207205 }
208206}
0 commit comments