@@ -22,6 +22,9 @@ - (UIViewController *)presentedViewController {
22
22
23
23
@end
24
24
25
+ // Set a long timeout to avoid flake due to slow CI.
26
+ static const NSTimeInterval kTimeout = 30.0 ;
27
+
25
28
@interface ImagePickerPluginTests : XCTestCase
26
29
@property (readonly , nonatomic ) id mockUIImagePicker;
27
30
@property (readonly , nonatomic ) id mockAVCaptureDevice;
@@ -146,6 +149,33 @@ - (void)testPluginPickVideoDeviceFront {
146
149
UIImagePickerControllerCameraDeviceFront);
147
150
}
148
151
152
+ - (void )testPickMultiImageShouldUseUIImagePickerControllerOnPreiOS14 {
153
+ if (@available (iOS 14 , *)) {
154
+ return ;
155
+ }
156
+
157
+ id photoLibrary = OCMClassMock ([PHPhotoLibrary class ]);
158
+ OCMStub (ClassMethod ([photoLibrary authorizationStatus ]))
159
+ .andReturn (PHAuthorizationStatusAuthorized);
160
+
161
+ FLTImagePickerPlugin *plugin = [FLTImagePickerPlugin new ];
162
+ [plugin setImagePickerControllerOverride: _mockUIImagePicker];
163
+ FlutterMethodCall *call =
164
+ [FlutterMethodCall methodCallWithMethodName: @" pickMultiImage"
165
+ arguments: @{
166
+ @" maxWidth" : @(100 ),
167
+ @" maxHeight" : @(200 ),
168
+ @" imageQuality" : @(50 ),
169
+ }];
170
+
171
+ [plugin handleMethodCall: call
172
+ result: ^(id _Nullable r){
173
+ }];
174
+
175
+ OCMVerify (times (1 ),
176
+ [self ->_mockUIImagePicker setSourceType: UIImagePickerControllerSourceTypePhotoLibrary]);
177
+ }
178
+
149
179
#pragma mark - Test camera devices, no op on simulators
150
180
151
181
- (void )testPluginPickImageDeviceCancelClickMultipleTimes {
@@ -167,61 +197,6 @@ - (void)testPluginPickImageDeviceCancelClickMultipleTimes {
167
197
[plugin imagePickerControllerDidCancel: [plugin getImagePickerController ]];
168
198
}
169
199
170
- #pragma mark - Test that arguments and results are set for all method calls
171
- - (void )testPickImageShouldSetArgumentsAndResult {
172
- FlutterResult expectedResult = ^(id _Nullable r) {
173
- };
174
- NSDictionary *expectedArguments =
175
- @{@" source" : @(1 ), @" maxWidth" : @(200 ), @" maxHeight" : @(200 ), @" imageQuality" : @(50 )};
176
-
177
- // Run test
178
- FLTImagePickerPlugin *plugin = [FLTImagePickerPlugin new ];
179
- FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" pickImage"
180
- arguments: expectedArguments];
181
-
182
- [plugin handleMethodCall: call result: expectedResult];
183
-
184
- XCTAssertEqual (plugin.result , expectedResult);
185
- XCTAssertEqual (plugin.arguments , expectedArguments);
186
- }
187
-
188
- - (void )testPickMultiImageShouldSetArgumentsAndResult {
189
- FlutterResult expectedResult = ^(id _Nullable r) {
190
- };
191
- NSDictionary *expectedArguments =
192
- @{@" maxWidth" : @(200 ), @" maxHeight" : @(200 ), @" imageQuality" : @(50 )};
193
-
194
- // Run test
195
- FLTImagePickerPlugin *plugin = [FLTImagePickerPlugin new ];
196
- FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" pickMultiImage"
197
- arguments: expectedArguments];
198
-
199
- [plugin handleMethodCall: call result: expectedResult];
200
-
201
- XCTAssertEqual (plugin.result , expectedResult);
202
- XCTAssertEqual (plugin.arguments , expectedArguments);
203
- }
204
-
205
- - (void )testPickVideoShouldSetArgumentsAndResult {
206
- // AVAuthorizationStatusAuthorized is supported
207
- OCMStub ([_mockAVCaptureDevice authorizationStatusForMediaType: AVMediaTypeVideo])
208
- .andReturn (AVAuthorizationStatusAuthorized);
209
-
210
- FlutterResult expectedResult = ^(id _Nullable r) {
211
- };
212
- NSDictionary *expectedArguments = @{@" source" : @(1 ), @" maxDuration" : @(200 )};
213
-
214
- // Run test
215
- FLTImagePickerPlugin *plugin = [FLTImagePickerPlugin new ];
216
- FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" pickVideo"
217
- arguments: expectedArguments];
218
-
219
- [plugin handleMethodCall: call result: expectedResult];
220
-
221
- XCTAssertEqual (plugin.result , expectedResult);
222
- XCTAssertEqual (plugin.arguments , expectedArguments);
223
- }
224
-
225
200
#pragma mark - Test video duration
226
201
227
202
- (void )testPickingVideoWithDuration {
0 commit comments