From 7b5285b2baffcaaef4b65fada2763feecb1e63f2 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 8 Nov 2019 10:31:00 -0800 Subject: [PATCH] more documentations and tests --- packages/image_picker/CHANGELOG.md | 4 +++ packages/image_picker/README.md | 4 +-- packages/image_picker/lib/image_picker.dart | 2 ++ packages/image_picker/pubspec.yaml | 2 +- .../image_picker/test/image_picker_test.dart | 27 +++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index 418d3a0a57d6..d8a170e47499 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.1+11 + +* Stability and Maintainability: update documentations, add unit tests. + ## 0.6.1+10 * iOS: Fix image orientation problems when scaling images. diff --git a/packages/image_picker/README.md b/packages/image_picker/README.md index 201113b2e771..fa73bfd1658a 100755 --- a/packages/image_picker/README.md +++ b/packages/image_picker/README.md @@ -5,8 +5,6 @@ A Flutter plugin for iOS and Android for picking images from the image library, and taking new pictures with the camera. -*Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback welcome](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome! - ## Installation First, add `image_picker` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). @@ -67,7 +65,7 @@ class _MyHomePageState extends State { ### Handling MainActivity destruction on Android -Android system -- although very rarely -- sometimes kills the MainActivity after the image_picker finishes. When this happens, we lost the data selected from the image_picker. You can use `retrieveLostData` to retrieve the lost data in this situation. For example: +Android system -- although very rarely -- sometimes kills the MainActivity after the image_picker finishes. When this happens, we lost the data selected from the image_picker. You can use `retrieveLostData` to retrieve the lost data in this situation. For example: ```dart Future retrieveLostData() async { diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index bbe5157f4274..b1a7c8b36c00 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -20,6 +20,8 @@ enum ImageSource { gallery, } +/// Provides an easy way to pick an image/video from the image library, +/// or to take a picture/video with the camera. class ImagePicker { static const MethodChannel _channel = MethodChannel('plugins.flutter.io/image_picker'); diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index 93379d32fe7e..998d921005a1 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -5,7 +5,7 @@ authors: - Flutter Team - Rhodes Davis Jr. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.6.1+10 +version: 0.6.1+11 flutter: plugin: diff --git a/packages/image_picker/test/image_picker_test.dart b/packages/image_picker/test/image_picker_test.dart index 1a40e11d76e1..28eae8eaa46d 100644 --- a/packages/image_picker/test/image_picker_test.dart +++ b/packages/image_picker/test/image_picker_test.dart @@ -143,6 +143,33 @@ void main() { }); }); + group('#pickVideo', () { + test('passes the image source argument correctly', () async { + await ImagePicker.pickVideo(source: ImageSource.camera); + await ImagePicker.pickVideo(source: ImageSource.gallery); + + expect( + log, + [ + isMethodCall('pickVideo', arguments: { + 'source': 0, + }), + isMethodCall('pickVideo', arguments: { + 'source': 1, + }), + ], + ); + }); + + test('handles a null image path response gracefully', () async { + channel.setMockMethodCallHandler((MethodCall methodCall) => null); + + expect( + await ImagePicker.pickVideo(source: ImageSource.gallery), isNull); + expect(await ImagePicker.pickVideo(source: ImageSource.camera), isNull); + }); + }); + group('#retrieveLostData', () { test('retrieveLostData get success response', () async { channel.setMockMethodCallHandler((MethodCall methodCall) async {