Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1a5afbf
I've added the `pickMultiVideo` feature to `image_picker`.
google-labs-jules[bot] Aug 6, 2025
3ac98cd
Minor cleanup (analysis, autoformat, stale comments, changelog/versio…
stuartmorgan-g Aug 7, 2025
528a6e7
Rework examples for testing and to reduce drift
stuartmorgan-g Aug 7, 2025
f2c219c
Android: Fix API version issue and add native tests
stuartmorgan-g Aug 7, 2025
47086bb
iOS: Fix, and unify some older code flows
stuartmorgan-g Aug 8, 2025
acfbfd1
Simplify iOS Dart code
stuartmorgan-g Aug 8, 2025
5dd0563
Merge branch 'main' into add-pick-multi-video
stuartmorgan-g Aug 8, 2025
100beef
Fix hero tags
stuartmorgan-g Aug 8, 2025
25f9458
Fix unguarded .first
stuartmorgan-g Aug 8, 2025
0c60fd7
Update packages/image_picker/image_picker_android/android/src/main/ja…
stuartmorgan-g Aug 8, 2025
c3040d2
Fix unit test expectation handling
stuartmorgan-g Aug 10, 2025
b5d0098
Revert part of app-facing example change
stuartmorgan-g Aug 10, 2025
21a2c50
Analysis fix
stuartmorgan-g Aug 11, 2025
9ebcff3
Fix UIImagePicker code path
stuartmorgan-g Aug 11, 2025
3c7e229
Merge branch 'main' into add-pick-multi-video-platform-interface
stuartmorgan-g Aug 14, 2025
8306374
Revert non-p-i changes
stuartmorgan-g Aug 14, 2025
c711fc3
Revert method channel changes
stuartmorgan-g Aug 14, 2025
86e96d1
Fix method name in changelog
stuartmorgan-g Aug 14, 2025
f7c6749
Add unit test
stuartmorgan-g Aug 14, 2025
59c91a9
GCAfGH review fixes
stuartmorgan-g Aug 14, 2025
886a7c4
Remove blank line
stuartmorgan-g Aug 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix unit test expectation handling
  • Loading branch information
stuartmorgan-g committed Aug 10, 2025
commit c3040d22e0724273c918aacef7373f931fe7e2b6
29 changes: 21 additions & 8 deletions packages/image_picker/image_picker/test/image_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -401,25 +401,38 @@ void main() {
group('#pickMultiVideo', () {
setUp(() {
when(mockPlatform.getMultiVideoWithOptions(
options: any,
options: anyNamed('options'),
)).thenAnswer((Invocation _) async => <XFile>[]);
});

test('passes the arguments correctly', () async {
final ImagePicker picker = ImagePicker();
await picker.pickMultiVideo();
await picker.pickMultiVideo(maxDuration: const Duration(seconds: 10));
await picker.pickMultiVideo(
limit: 5,
);
await picker.pickMultiVideo(limit: 5);

verifyInOrder(<Object>[
mockPlatform.getMultiVideoWithOptions(),
mockPlatform.getMultiVideoWithOptions(
options: const MultiVideoPickerOptions(
maxDuration: Duration(seconds: 10))),
options: argThat(
isInstanceOf<MultiVideoPickerOptions>(),
named: 'options',
)),
mockPlatform.getMultiVideoWithOptions(
options: const MultiVideoPickerOptions(limit: 5)),
options: argThat(
isInstanceOf<MultiVideoPickerOptions>().having(
(MultiVideoPickerOptions options) => options.maxDuration,
'maxDuration',
equals(const Duration(seconds: 10))),
named: 'options',
)),
mockPlatform.getMultiVideoWithOptions(
options: argThat(
isInstanceOf<MultiVideoPickerOptions>().having(
(MultiVideoPickerOptions options) => options.limit,
'limit',
equals(5)),
named: 'options',
)),
]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,6 @@ class ImagePickerAndroid extends ImagePickerPlatform {
return paths.isEmpty ? null : paths.first;
}

Future<List<String>> _getMultiVideoPath({
Duration? maxDuration,
int? limit,
}) {
return _hostApi.pickVideos(
SourceSpecification(type: SourceType.gallery),
VideoSelectionOptions(maxDurationSeconds: maxDuration?.inSeconds),
GeneralOptions(
allowMultiple: true,
usePhotoPicker: useAndroidPhotoPicker,
limit: limit,
),
);
}

@override
Future<PickedFile?> pickVideo({
required ImageSource source,
Expand Down Expand Up @@ -280,9 +265,14 @@ class ImagePickerAndroid extends ImagePickerPlatform {
Future<List<XFile>> getMultiVideoWithOptions({
MultiVideoPickerOptions options = const MultiVideoPickerOptions(),
}) async {
final List<String> paths = await _getMultiVideoPath(
maxDuration: options.maxDuration,
limit: options.limit,
final List<String> paths = await _hostApi.pickVideos(
SourceSpecification(type: SourceType.gallery),
VideoSelectionOptions(maxDurationSeconds: options.maxDuration?.inSeconds),
GeneralOptions(
allowMultiple: true,
usePhotoPicker: useAndroidPhotoPicker,
limit: options.limit,
),
);

if (paths.isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ class _FakeImagePickerApi implements ImagePickerApi {
passedVideoOptions = options;
passedAllowMultiple = generalOptions.allowMultiple;
passedPhotoPickerFlag = generalOptions.usePhotoPicker;
limit = generalOptions.limit;
return returnValue as List<String>? ?? <String>[];
}

Expand Down