2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- import camera_avfoundation
5
+ @ testable import camera_avfoundation
6
6
7
7
// Import Objectice-C part of the implementation when SwiftPM is used.
8
8
#if canImport(camera_avfoundation_objc)
9
9
import camera_avfoundation_objc
10
10
#endif
11
11
12
- final class MockCamera : FLTCam {
12
+ final class MockCamera : NSObject , Camera {
13
13
var setDartApiStub : ( ( FCPCameraEventApi ? ) -> Void ) ?
14
14
var setOnFrameAvailableStub : ( ( ( ( ) -> Void ) ? ) -> Void ) ?
15
15
var getMinimumExposureOffsetStub : ( ( ) -> CGFloat ) ?
@@ -42,7 +42,7 @@ final class MockCamera: FLTCam {
42
42
var startImageStreamStub : ( ( FlutterBinaryMessenger ) -> Void ) ?
43
43
var stopImageStreamStub : ( ( ) -> Void ) ?
44
44
45
- override var dartAPI : FCPCameraEventApi {
45
+ var dartAPI : FCPCameraEventApi ? {
46
46
get {
47
47
preconditionFailure ( " Attempted to access unimplemented property: dartAPI " )
48
48
}
@@ -51,7 +51,7 @@ final class MockCamera: FLTCam {
51
51
}
52
52
}
53
53
54
- override var onFrameAvailable : ( ( ) -> Void ) {
54
+ var onFrameAvailable : ( ( ) -> Void ) ? {
55
55
get {
56
56
preconditionFailure ( " Attempted to access unimplemented property: onFrameAvailable " )
57
57
}
@@ -60,147 +60,149 @@ final class MockCamera: FLTCam {
60
60
}
61
61
}
62
62
63
- override var minimumExposureOffset : CGFloat {
63
+ var videoFormat : FourCharCode = kCVPixelFormatType_32BGRA
64
+
65
+ var isPreviewPaused : Bool = false
66
+
67
+ var minimumExposureOffset : CGFloat {
64
68
return getMinimumExposureOffsetStub ? ( ) ?? 0
65
69
}
66
70
67
- override var maximumExposureOffset : CGFloat {
71
+ var maximumExposureOffset : CGFloat {
68
72
return getMaximumExposureOffsetStub ? ( ) ?? 0
69
73
}
70
74
71
- override var minimumAvailableZoomFactor : CGFloat {
75
+ var minimumAvailableZoomFactor : CGFloat {
72
76
return getMinimumAvailableZoomFactorStub ? ( ) ?? 0
73
77
}
74
78
75
- override var maximumAvailableZoomFactor : CGFloat {
79
+ var maximumAvailableZoomFactor : CGFloat {
76
80
return getMaximumAvailableZoomFactorStub ? ( ) ?? 0
77
81
}
78
82
79
- override func setUpCaptureSessionForAudioIfNeeded( ) {
83
+ func setUpCaptureSessionForAudioIfNeeded( ) {
80
84
setUpCaptureSessionForAudioIfNeededStub ? ( )
81
85
}
82
86
83
- override func reportInitializationState( ) { }
87
+ func reportInitializationState( ) { }
84
88
85
- override func receivedImageStreamData( ) {
89
+ func receivedImageStreamData( ) {
86
90
receivedImageStreamDataStub ? ( )
87
91
}
88
92
89
- override func start( ) {
93
+ func start( ) {
90
94
startStub ? ( )
91
95
}
92
96
93
- override func stop( ) { }
97
+ func stop( ) { }
94
98
95
- override func startVideoRecording(
99
+ func startVideoRecording(
96
100
completion: @escaping ( FlutterError ? ) -> Void ,
97
101
messengerForStreaming messenger: FlutterBinaryMessenger ?
98
102
) {
99
103
startVideoRecordingStub ? ( completion, messenger)
100
104
}
101
105
102
- override func pauseVideoRecording( ) {
106
+ func pauseVideoRecording( ) {
103
107
pauseVideoRecordingStub ? ( )
104
108
}
105
109
106
- override func resumeVideoRecording( ) {
110
+ func resumeVideoRecording( ) {
107
111
resumeVideoRecordingStub ? ( )
108
112
}
109
113
110
- override func stopVideoRecording( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
114
+ func stopVideoRecording( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
111
115
stopVideoRecordingStub ? ( completion)
112
116
}
113
117
114
- override func captureToFile( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
118
+ func captureToFile( completion: @escaping ( String ? , FlutterError ? ) -> Void ) {
115
119
captureToFileStub ? ( completion)
116
120
}
117
121
118
- override func setDeviceOrientation( _ orientation: UIDeviceOrientation ) {
122
+ func setDeviceOrientation( _ orientation: UIDeviceOrientation ) {
119
123
setDeviceOrientationStub ? ( orientation)
120
124
}
121
125
122
- override func lockCaptureOrientation( _ orientation: FCPPlatformDeviceOrientation ) {
126
+ func lockCaptureOrientation( _ orientation: FCPPlatformDeviceOrientation ) {
123
127
lockCaptureOrientationStub ? ( orientation)
124
128
}
125
129
126
- override func unlockCaptureOrientation( ) {
130
+ func unlockCaptureOrientation( ) {
127
131
unlockCaptureOrientationStub ? ( )
128
132
}
129
133
130
- override func setImageFileFormat( _ fileFormat: FCPPlatformImageFileFormat ) {
134
+ func setImageFileFormat( _ fileFormat: FCPPlatformImageFileFormat ) {
131
135
setImageFileFormatStub ? ( fileFormat)
132
136
}
133
137
134
- override func setExposureMode( _ mode: FCPPlatformExposureMode ) {
138
+ func setExposureMode( _ mode: FCPPlatformExposureMode ) {
135
139
setExposureModeStub ? ( mode)
136
140
}
137
141
138
- override func setExposureOffset( _ offset: Double ) {
142
+ func setExposureOffset( _ offset: Double ) {
139
143
setExposureOffsetStub ? ( offset)
140
144
}
141
145
142
- override func setExposurePoint(
146
+ func setExposurePoint(
143
147
_ point: FCPPlatformPoint ? , withCompletion: @escaping ( FlutterError ? ) -> Void
144
148
) {
145
149
setExposurePointStub ? ( point, withCompletion)
146
150
}
147
151
148
- override func setFocusMode( _ mode: FCPPlatformFocusMode ) {
152
+ func setFocusMode( _ mode: FCPPlatformFocusMode ) {
149
153
setFocusModeStub ? ( mode)
150
154
}
151
155
152
- override func setFocusPoint(
153
- _ point: FCPPlatformPoint ? , completion: @escaping ( FlutterError ? ) -> Void
154
- ) {
156
+ func setFocusPoint( _ point: FCPPlatformPoint ? , completion: @escaping ( FlutterError ? ) -> Void ) {
155
157
setFocusPointStub ? ( point, completion)
156
158
}
157
159
158
- override func setZoomLevel(
160
+ func setZoomLevel(
159
161
_ zoom: CGFloat ,
160
162
withCompletion completion: @escaping ( FlutterError ? ) -> Void
161
163
) {
162
164
setZoomLevelStub ? ( zoom, completion)
163
165
}
164
166
165
- override func setFlashMode(
167
+ func setFlashMode(
166
168
_ mode: FCPPlatformFlashMode ,
167
169
withCompletion completion: @escaping ( FlutterError ? ) -> Void
168
170
) {
169
171
setFlashModeStub ? ( mode, completion)
170
172
}
171
173
172
- override func pausePreview( ) {
174
+ func pausePreview( ) {
173
175
pausePreviewStub ? ( )
174
176
}
175
177
176
- override func resumePreview( ) {
178
+ func resumePreview( ) {
177
179
resumePreviewStub ? ( )
178
180
}
179
181
180
- override func setDescriptionWhileRecording(
182
+ func setDescriptionWhileRecording(
181
183
_ cameraName: String ,
182
184
withCompletion completion: @escaping ( FlutterError ? ) -> Void
183
185
) {
184
186
setDescriptionWhileRecordingStub ? ( cameraName, completion)
185
187
}
186
188
187
- override func startImageStream( with messenger: FlutterBinaryMessenger ) {
189
+ func startImageStream( with messenger: FlutterBinaryMessenger ) {
188
190
startImageStreamStub ? ( messenger)
189
191
}
190
192
191
- override func stopImageStream( ) {
193
+ func stopImageStream( ) {
192
194
stopImageStreamStub ? ( )
193
195
}
194
196
195
- override func captureOutput(
197
+ func captureOutput(
196
198
_ output: AVCaptureOutput ,
197
199
didOutput sampleBuffer: CMSampleBuffer ,
198
200
from connection: AVCaptureConnection
199
201
) { }
200
202
201
- override func close( ) { }
203
+ func close( ) { }
202
204
203
- override func copyPixelBuffer( ) -> Unmanaged < CVPixelBuffer > ? {
205
+ func copyPixelBuffer( ) -> Unmanaged < CVPixelBuffer > ? {
204
206
return nil
205
207
}
206
208
}
0 commit comments