Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[image_picker] Refactored tests to expose private interface in separate test header. #4722

Merged
merged 5 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.8.4+7

* Refactors unit test to expose private interface via a separate test header instead of the inline declaration.

## 0.8.4+6

* Fixes minor type issues in iOS implementation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"

@import image_picker;
@import image_picker.Test;
@import XCTest;
#import <OCMock/OCMock.h>

Expand All @@ -21,12 +22,6 @@ - (UIViewController *)presentedViewController {

@end

@interface FLTImagePickerPlugin (Test)
@property(copy, nonatomic) FlutterResult result;
- (void)handleSavedPathList:(NSMutableArray *)pathList;
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
@end

@interface ImagePickerPluginTests : XCTestCase
@property(readonly, nonatomic) id mockUIImagePicker;
@property(readonly, nonatomic) id mockAVCaptureDevice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"

@import image_picker;
@import image_picker.Test;
@import XCTest;

@interface ImageUtilTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"

@import image_picker;
@import image_picker.Test;
@import XCTest;

@interface MetaDataUtilTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"

@import image_picker;
@import image_picker.Test;
@import XCTest;

@interface PhotoAssetUtilTests : XCTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#import "FLTImagePickerPlugin.h"
#import "FLTImagePickerPlugin_Test.h"

#import <AVFoundation/AVFoundation.h>
#import <MobileCoreServices/MobileCoreServices.h>
Expand Down Expand Up @@ -30,8 +31,6 @@ @interface FLTImagePickerPlugin () <UINavigationControllerDelegate,
PHPickerViewControllerDelegate,
UIAdaptivePresentationControllerDelegate>

@property(copy, nonatomic) FlutterResult result;

@property(assign, nonatomic) int maxImagesAllowed;

@property(copy, nonatomic) NSDictionary *arguments;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This header is available in the Test module. Import via "@import image_picker.Test;"

#import <image_picker/FLTImagePickerPlugin.h>

/** Methods exposed for unit testing. */
@interface FLTImagePickerPlugin ()

/** The Flutter result callback use to report results back to Flutter App. */
@property(copy, nonatomic) FlutterResult result;

/**
* Applies NSMutableArray on the FLutterResult.
*
* NSString must be returned by FlutterResult if the single image
* mode is active. It is checked by maxImagesAllowed and
* returns the first object of the pathlist.
*
* NSMutableArray must be returned by FlutterResult if the multi-image
* mode is active. After the pathlist count is checked then it returns
* the pathlist.
*
* @param pathList that should be applied to FlutterResult.
*/
- (void)handleSavedPathList:(NSArray *)pathList;

/**
* Tells the delegate that the user cancelled the pick operation.
*
* Your delegate’s implementation of this method should dismiss the picker view
* by calling the dismissModalViewControllerAnimated: method of the parent
* view controller.
*
* Implementation of this method is optional, but expected.
*
* @param picker The controller object managing the image picker interface.
*/
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
framework module image_picker {
umbrella header "image_picker-umbrella.h"

export *
module * { export * }

explicit module Test {
header "FLTImagePickerPlugin_Test.h"
header "FLTImagePickerImageUtil.h"
header "FLTImagePickerMetaDataUtil.h"
header "FLTImagePickerPhotoAssetUtil.h"
header "FLTPHPickerSaveImageToPathOperation.h"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Foundation/Foundation.h>
#import <image_picker/FLTImagePickerPlugin.h>
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Downloaded by pub (not CocoaPods).
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/image_picker' }
s.documentation_url = 'https://pub.dev/packages/image_picker'
s.source_files = 'Classes/**/*'
s.source_files = 'Classes/**/*.{h,m}'
s.public_header_files = 'Classes/**/*.h'
s.module_map = 'Classes/ImagePickerPlugin.modulemap'
s.dependency 'Flutter'
s.platform = :ios, '9.0'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image
library, and taking new pictures with the camera.
repository: https://github.com/flutter/plugins/tree/main/packages/image_picker/image_picker
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 0.8.4+6
version: 0.8.4+7

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down