Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1634873
Added maxDuration property to pickVideo method
derTuca Sep 9, 2019
b3e452f
Added additional comment on maxDuration purpose
derTuca Sep 16, 2019
953f22a
Changed pick intent to open gallery instead of documents on Android
derTuca Sep 19, 2019
46e5507
Replaced copy-pasted video ref to image
derTuca Sep 19, 2019
09bead9
Revert "Changed pick intent to open gallery instead of documents on A…
derTuca Nov 15, 2019
6e6feee
Revert project.pbxproj
derTuca Nov 15, 2019
9a449b7
Add iskindof check for argument
derTuca Nov 15, 2019
d5d3a90
Merge branch 'master' into image_picker_max_duration
derTuca Nov 16, 2019
254ffd0
Update AUTHORS
Nov 20, 2019
97cd154
Merge branch 'master' of github.com:flutter/plugins into image_picker…
derTuca Nov 26, 2019
2e03c76
Added const initializers for Duation
derTuca Nov 26, 2019
5a88cee
Formatted code using tool
derTuca Nov 26, 2019
bf445eb
Merge branch 'image_picker_max_duration' of github.com:derTuca/plugin…
derTuca Nov 26, 2019
5c9e477
Fixed iOS formatting
derTuca Nov 26, 2019
c901384
Reverted changelog accidental replace and added author to pubspec
derTuca Dec 6, 2019
50a1170
Update CHANGELOG.md
Dec 17, 2019
c83d9ee
Update CHANGELOG.md
Dec 17, 2019
669a420
Merge branch 'master' of github.com:flutter/plugins into image_picker…
derTuca Dec 31, 2019
b6301da
Merge branch 'image_picker_max_duration' of github.com:derTuca/plugin…
derTuca Dec 31, 2019
8a0dd18
Merge branch 'master' of github.com:flutter/plugins into image_picker…
derTuca Feb 2, 2020
1c8c816
Added JUnit test for max duration
derTuca Feb 2, 2020
8822565
Updated changelog and pubspec version
derTuca Feb 18, 2020
e7c7532
Merge branch 'master' of github.com:flutter/plugins into image_picker…
derTuca Feb 18, 2020
bdd8208
merge master and resolve conflicts
Apr 8, 2020
f288d75
add tests and fix existing tests
Apr 8, 2020
37d006f
Merge pull request #1 from cyanglaz/derTuna
derTuca Apr 9, 2020
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Lukasz Piliszczuk <[email protected]>
SoundReply Solutions GmbH <[email protected]>
Rafal Wachol <[email protected]>
Pau Picas <[email protected]>
Alexandru Tuca <[email protected]>
Christian Weder <[email protected]>
Rhodes Davis Jr. <[email protected]>
Luigi Agosti <[email protected]>
Expand Down
5 changes: 5 additions & 0 deletions packages/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.6.5

* Set maximum duration for video recording.
* Fix some existing XCTests.

## 0.6.4

* Add a new parameter to select preferred camera device.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ public void takeVideoWithCamera(MethodCall methodCall, MethodChannel.Result resu

private void launchTakeVideoWithCameraIntent() {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (this.methodCall != null && this.methodCall.argument("maxDuration") != null) {
int maxSeconds = this.methodCall.argument("maxDuration");
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, maxSeconds);
}
if (cameraDevice == CameraDevice.FRONT) {
useFrontCamera(intent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class ImagePickerDelegateTest {
private static final Double WIDTH = 10.0;
private static final Double HEIGHT = 10.0;
private static final Double MAX_DURATION = 10.0;
private static final Integer IMAGE_QUALITY = 90;

@Mock Activity mockActivity;
Expand Down Expand Up @@ -373,6 +374,19 @@ public void onActivityResult_WhenImageTakenWithCamera_AndNoResizeNeeded_Finishes
verifyNoMoreInteractions(mockResult);
}

@Test
public void
onActivityResult_WhenVideoTakenWithCamera_AndMaxDurationParametersSupplied_FinishesWithFilePath() {
when(mockMethodCall.argument("maxDuration")).thenReturn(MAX_DURATION);

ImagePickerDelegate delegate = createDelegateWithPendingResultAndMethodCall();
delegate.onActivityResult(
ImagePickerDelegate.REQUEST_CODE_TAKE_VIDEO_WITH_CAMERA, Activity.RESULT_OK, mockIntent);

verify(mockResult).success("pathFromUri");
verifyNoMoreInteractions(mockResult);
}

private ImagePickerDelegate createDelegate() {
return new ImagePickerDelegate(
mockActivity,
Expand Down
23 changes: 10 additions & 13 deletions packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@

/* Begin PBXBuildFile section */
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
5C9513011EC38BD300040975 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C9513001EC38BD300040975 /* GeneratedPluginRegistrant.m */; };
680049262280D736006DD6AB /* MetaDataUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 680049252280D736006DD6AB /* MetaDataUtilTests.m */; };
680049272280D79A006DD6AB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
680049382280F2B9006DD6AB /* pngImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 680049352280F2B8006DD6AB /* pngImage.png */; };
680049392280F2B9006DD6AB /* jpgImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 680049362280F2B8006DD6AB /* jpgImage.jpg */; };
68B9AF72243E4B3F00927CE4 /* ImagePickerPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */; };
68F4B464228B3AB500C25614 /* PhotoAssetUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
Expand Down Expand Up @@ -46,8 +43,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -56,7 +51,6 @@

/* Begin PBXFileReference section */
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
5A9D31B91557877A0E8EF3E7 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
5C9512FF1EC38BD300040975 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
5C9513001EC38BD300040975 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
Expand All @@ -66,13 +60,13 @@
680049352280F2B8006DD6AB /* pngImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pngImage.png; sourceTree = "<group>"; };
680049362280F2B8006DD6AB /* jpgImage.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = jpgImage.jpg; sourceTree = "<group>"; };
6801632E632668F4349764C9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImagePickerPluginTests.m; path = ../../../ios/Tests/ImagePickerPluginTests.m; sourceTree = "<group>"; };
68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PhotoAssetUtilTests.m; path = ../../../ios/Tests/PhotoAssetUtilTests.m; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand All @@ -98,8 +92,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
F4F7A436CCA4BF276270A3AE /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -116,6 +108,7 @@
68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */,
F78AF3172342D9D7008449C7 /* ImagePickerTestImages.h */,
F78AF3182342D9D7008449C7 /* ImagePickerTestImages.m */,
68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */,
);
path = image_picker_exampleTests;
sourceTree = "<group>";
Expand All @@ -142,9 +135,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
Expand Down Expand Up @@ -331,17 +322,20 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
95BB15E9E1769C0D146AA592 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -390,6 +384,7 @@
9FC8F0EE229FB90B00C8D58F /* ImageUtilTests.m in Sources */,
F78AF3192342D9D7008449C7 /* ImagePickerTestImages.m in Sources */,
680049262280D736006DD6AB /* MetaDataUtilTests.m in Sources */,
68B9AF72243E4B3F00927CE4 /* ImagePickerPluginTests.m in Sources */,
68F4B464228B3AB500C25614 /* PhotoAssetUtilTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -598,6 +593,7 @@
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -619,6 +615,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
3 changes: 2 additions & 1 deletion packages/image_picker/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class _MyHomePageState extends State<MyHomePage> {
await _controller.setVolume(0.0);
}
if (isVideo) {
final File file = await ImagePicker.pickVideo(source: source);
final File file = await ImagePicker.pickVideo(
source: source, maxDuration: const Duration(seconds: 10));
await _playVideo(file);
} else {
await _displayPickImageDialog(context,
Expand Down
4 changes: 4 additions & 0 deletions packages/image_picker/ios/Classes/FLTImagePickerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
_arguments = call.arguments;

int imageSource = [[_arguments objectForKey:@"source"] intValue];
if ([[_arguments objectForKey:@"maxDuration"] isKindOfClass:[NSNumber class]]) {
NSTimeInterval max = [[_arguments objectForKey:@"maxDuration"] doubleValue];
_imagePickerController.videoMaximumDuration = max;
}

switch (imageSource) {
case SOURCE_CAMERA:
Expand Down
21 changes: 17 additions & 4 deletions packages/image_picker/ios/Tests/ImagePickerPluginTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @implementation ImagePickerPluginTests

#pragma mark - Test camera devices, no op on simulators
- (void)testPluginPickImageDeviceBack {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
return;
}
FLTImagePickerPlugin *plugin =
Expand All @@ -30,7 +30,7 @@ - (void)testPluginPickImageDeviceBack {
}

- (void)testPluginPickImageDeviceFront {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
return;
}
FLTImagePickerPlugin *plugin =
Expand All @@ -46,7 +46,7 @@ - (void)testPluginPickImageDeviceFront {
}

- (void)testPluginPickVideoDeviceBack {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
return;
}
FLTImagePickerPlugin *plugin =
Expand All @@ -62,7 +62,7 @@ - (void)testPluginPickVideoDeviceBack {
}

- (void)testPluginPickVideoDeviceFront {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
return;
}
FLTImagePickerPlugin *plugin =
Expand All @@ -77,4 +77,17 @@ - (void)testPluginPickVideoDeviceFront {
UIImagePickerControllerCameraDeviceFront);
}

#pragma mark - Test video duration
- (void)testPickingVideoWithDuration {
FLTImagePickerPlugin *plugin =
[[FLTImagePickerPlugin alloc] initWithViewController:[UIViewController new]];
FlutterMethodCall *call = [FlutterMethodCall
methodCallWithMethodName:@"pickVideo"
arguments:@{@"source" : @(0), @"cameraDevice" : @(0), @"maxDuration" : @95}];
[plugin handleMethodCall:call
result:^(id _Nullable r){
}];
XCTAssertEqual([plugin getImagePickerController].videoMaximumDuration, 95);
}

@end
7 changes: 6 additions & 1 deletion packages/image_picker/lib/image_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class ImagePicker {
/// The [source] argument controls where the video comes from. This can
/// be either [ImageSource.camera] or [ImageSource.gallery].
///
/// The [maxDuration] argument specifies the maximum duration of the captured video. If no [maxDuration] is specified,
/// the maximum duration will be infinite.
///
/// Use `preferredCameraDevice` to specify the camera to use when the `source` is [ImageSource.camera].
/// The `preferredCameraDevice` is ignored when `source` is [ImageSource.gallery]. It is also ignored if the chosen camera is not supported on the device.
/// Defaults to [CameraDevice.rear].
Expand All @@ -109,12 +112,14 @@ class ImagePicker {
/// in this call. You can then call [retrieveLostData] when your app relaunches to retrieve the lost data.
static Future<File> pickVideo(
{@required ImageSource source,
CameraDevice preferredCameraDevice = CameraDevice.rear}) async {
CameraDevice preferredCameraDevice = CameraDevice.rear,
Duration maxDuration}) async {
assert(source != null);
final String path = await _channel.invokeMethod<String>(
'pickVideo',
<String, dynamic>{
'source': source.index,
'maxDuration': maxDuration?.inSeconds,
'cameraDevice': preferredCameraDevice.index
},
);
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: image_picker
description: Flutter plugin for selecting images from the Android and iOS image
library, and taking new pictures with the camera.
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
version: 0.6.4
version: 0.6.5

flutter:
plugin:
Expand Down
43 changes: 42 additions & 1 deletion packages/image_picker/test/image_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,55 @@ void main() {
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
'cameraDevice': 0,
'maxDuration': null,
}),
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 1,
'cameraDevice': 0,
'maxDuration': null,
}),
],
);
});

test('handles a null image path response gracefully', () async {
test('passes the duration argument correctly', () async {
await ImagePicker.pickVideo(source: ImageSource.camera);
await ImagePicker.pickVideo(
source: ImageSource.camera,
maxDuration: const Duration(seconds: 10));
await ImagePicker.pickVideo(
source: ImageSource.camera,
maxDuration: const Duration(minutes: 1));
await ImagePicker.pickVideo(
source: ImageSource.camera, maxDuration: const Duration(hours: 1));
expect(
log,
<Matcher>[
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
'maxDuration': null,
'cameraDevice': 0,
}),
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
'maxDuration': 10,
'cameraDevice': 0,
}),
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
'maxDuration': 60,
'cameraDevice': 0,
}),
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
'maxDuration': 3600,
'cameraDevice': 0,
}),
],
);
});

test('handles a null video path response gracefully', () async {
channel.setMockMethodCallHandler((MethodCall methodCall) => null);

expect(
Expand All @@ -225,6 +264,7 @@ void main() {
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
'cameraDevice': 0,
'maxDuration': null,
}),
],
);
Expand All @@ -240,6 +280,7 @@ void main() {
<Matcher>[
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
'maxDuration': null,
'cameraDevice': 1,
}),
],
Expand Down