[image_picker] Refactored tests to expose private interface in separate test header. (#4722)
diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md
index 1712aa0..3dbf2c5 100644
--- a/packages/image_picker/image_picker/CHANGELOG.md
+++ b/packages/image_picker/image_picker/CHANGELOG.md
@@ -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.
diff --git a/packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m b/packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
index cc901f0..bcaf2d1 100644
--- a/packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
+++ b/packages/image_picker/image_picker/example/ios/RunnerTests/ImagePickerPluginTests.m
@@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"
@import image_picker;
+@import image_picker.Test;
@import XCTest;
#import <OCMock/OCMock.h>
@@ -21,12 +22,6 @@
@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;
diff --git a/packages/image_picker/image_picker/example/ios/RunnerTests/ImageUtilTests.m b/packages/image_picker/image_picker/example/ios/RunnerTests/ImageUtilTests.m
index b793d6e..9b9719f 100644
--- a/packages/image_picker/image_picker/example/ios/RunnerTests/ImageUtilTests.m
+++ b/packages/image_picker/image_picker/example/ios/RunnerTests/ImageUtilTests.m
@@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"
@import image_picker;
+@import image_picker.Test;
@import XCTest;
@interface ImageUtilTests : XCTestCase
diff --git a/packages/image_picker/image_picker/example/ios/RunnerTests/MetaDataUtilTests.m b/packages/image_picker/image_picker/example/ios/RunnerTests/MetaDataUtilTests.m
index 54f9469..4160c51 100644
--- a/packages/image_picker/image_picker/example/ios/RunnerTests/MetaDataUtilTests.m
+++ b/packages/image_picker/image_picker/example/ios/RunnerTests/MetaDataUtilTests.m
@@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"
@import image_picker;
+@import image_picker.Test;
@import XCTest;
@interface MetaDataUtilTests : XCTestCase
diff --git a/packages/image_picker/image_picker/example/ios/RunnerTests/PhotoAssetUtilTests.m b/packages/image_picker/image_picker/example/ios/RunnerTests/PhotoAssetUtilTests.m
index c38930f..97b4b6c 100644
--- a/packages/image_picker/image_picker/example/ios/RunnerTests/PhotoAssetUtilTests.m
+++ b/packages/image_picker/image_picker/example/ios/RunnerTests/PhotoAssetUtilTests.m
@@ -5,6 +5,7 @@
#import "ImagePickerTestImages.h"
@import image_picker;
+@import image_picker.Test;
@import XCTest;
@interface PhotoAssetUtilTests : XCTestCase
diff --git a/packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m b/packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
index 65a5fb8..1301398 100644
--- a/packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
+++ b/packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#import "FLTImagePickerPlugin.h"
+#import "FLTImagePickerPlugin_Test.h"
#import <AVFoundation/AVFoundation.h>
#import <MobileCoreServices/MobileCoreServices.h>
@@ -30,8 +31,6 @@
PHPickerViewControllerDelegate,
UIAdaptivePresentationControllerDelegate>
-@property(copy, nonatomic) FlutterResult result;
-
@property(assign, nonatomic) int maxImagesAllowed;
@property(copy, nonatomic) NSDictionary *arguments;
diff --git a/packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin_Test.h b/packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin_Test.h
new file mode 100644
index 0000000..94eca42
--- /dev/null
+++ b/packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin_Test.h
@@ -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
diff --git a/packages/image_picker/image_picker/ios/Classes/ImagePickerPlugin.modulemap b/packages/image_picker/image_picker/ios/Classes/ImagePickerPlugin.modulemap
new file mode 100644
index 0000000..dc702ea
--- /dev/null
+++ b/packages/image_picker/image_picker/ios/Classes/ImagePickerPlugin.modulemap
@@ -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"
+ }
+}
diff --git a/packages/image_picker/image_picker/ios/Classes/image_picker-umbrella.h b/packages/image_picker/image_picker/ios/Classes/image_picker-umbrella.h
new file mode 100644
index 0000000..0d89b2e
--- /dev/null
+++ b/packages/image_picker/image_picker/ios/Classes/image_picker-umbrella.h
@@ -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>
diff --git a/packages/image_picker/image_picker/ios/image_picker.podspec b/packages/image_picker/image_picker/ios/image_picker.podspec
index a2bba5c..2a10b1c 100644
--- a/packages/image_picker/image_picker/ios/image_picker.podspec
+++ b/packages/image_picker/image_picker/ios/image_picker.podspec
@@ -14,8 +14,9 @@
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' }
diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml
index c072244..7142d82 100755
--- a/packages/image_picker/image_picker/pubspec.yaml
+++ b/packages/image_picker/image_picker/pubspec.yaml
@@ -3,7 +3,7 @@
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"