Skip to content

Commit

Permalink
[image_picker] Do not copy a static field into another static field (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetf authored Dec 21, 2020
1 parent c986058 commit 8980d79
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.7+19

* Do not copy static field to another static field.

## 0.6.7+18

* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276))
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker/lib/image_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export 'package:image_picker_platform_interface/image_picker_platform_interface.
class ImagePicker {
/// The platform interface that drives this plugin
@visibleForTesting
static ImagePickerPlatform platform = ImagePickerPlatform.instance;
static ImagePickerPlatform get platform => ImagePickerPlatform.instance;

/// Returns a [File] object pointing to the image that was picked.
///
Expand Down
4 changes: 3 additions & 1 deletion packages/image_picker/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/image_picker
version: 0.6.7+18
version: 0.6.7+19

flutter:
plugin:
Expand All @@ -25,7 +25,9 @@ dev_dependencies:
sdk: flutter
integration_test:
path: ../../integration_test
mockito: ^4.1.3
pedantic: ^1.8.0
plugin_platform_interface: ^1.0.3

environment:
sdk: ">=2.1.0 <3.0.0"
Expand Down
16 changes: 16 additions & 0 deletions packages/image_picker/image_picker/test/image_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:image_picker/image_picker.dart';
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';
import 'package:mockito/mockito.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Expand All @@ -26,6 +29,15 @@ void main() {
log.clear();
});

test('ImagePicker platform instance overrides the actual platform used',
() {
final ImagePickerPlatform savedPlatform = ImagePickerPlatform.instance;
final MockPlatform mockPlatform = MockPlatform();
ImagePickerPlatform.instance = mockPlatform;
expect(ImagePicker.platform, mockPlatform);
ImagePickerPlatform.instance = savedPlatform;
});

group('#pickImage', () {
test('passes the image source argument correctly', () async {
await picker.getImage(source: ImageSource.camera);
Expand Down Expand Up @@ -336,3 +348,7 @@ void main() {
});
});
}

class MockPlatform extends Mock
with MockPlatformInterfaceMixin
implements ImagePickerPlatform {}

0 comments on commit 8980d79

Please sign in to comment.