Skip to content

Commit 0ba9a82

Browse files
[image_picker_ios] PR 1/5 Add injectable protocol seams and migrate leaf native tests to Swift Testing (flutter#12897)
Adds injectable protocol seams for camera, photo library, and PHPicker so later PRs can test without OCMock. Migrates the ImageUtil, MetaDataUtil, PhotoAssetUtil, and PHPicker save-operation tests to Swift Testing. Plugin behavior is unchanged. Native tests capture async `savedPathBlock` results and assert after `await`, so those expectations can fail CI. Bumps `image_picker_ios` to **0.8.13+8**. PR 1/5 of the Obj-C → Swift migration. Part of flutter#119107 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 46c8280 commit 0ba9a82

22 files changed

Lines changed: 1045 additions & 1156 deletions

‎packages/image_picker/image_picker_ios/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.8.13+9
2+
3+
* Adds injectable protocol seams for camera, photo library, and PHPicker APIs.
4+
15
## 0.8.13+8
26

37
* Fixes scaling 10-bit images on iOS.

‎packages/image_picker/image_picker_ios/example/ios/Runner.xcodeproj/project.pbxproj‎

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
334733FC266813EE00DCC49E /* ImageUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.m */; };
11-
334733FD266813F100DCC49E /* MetaDataUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 680049252280D736006DD6AB /* MetaDataUtilTests.m */; };
12-
334733FE266813F400DCC49E /* PhotoAssetUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */; };
10+
334733FC266813EE00DCC49E /* ImageUtilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.swift */; };
11+
334733FD266813F100DCC49E /* MetaDataUtilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 680049252280D736006DD6AB /* MetaDataUtilTests.swift */; };
12+
334733FE266813F400DCC49E /* PhotoAssetUtilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.swift */; };
1313
334733FF266813FA00DCC49E /* ImagePickerTestImages.m in Sources */ = {isa = PBXBuildFile; fileRef = F78AF3182342D9D7008449C7 /* ImagePickerTestImages.m */; };
1414
33473400266813FD00DCC49E /* ImagePickerPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */; };
1515
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
@@ -25,7 +25,8 @@
2525
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
2626
78CF8D862BC5E7070051231B /* OCMock in Frameworks */ = {isa = PBXBuildFile; productRef = 78CF8D852BC5E7070051231B /* OCMock */; };
2727
86430DF9272D71E9002D9D6C /* gifImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */; };
28-
86E9A893272754860017E6E0 /* PickerSaveImageToPathOperationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 86E9A892272754860017E6E0 /* PickerSaveImageToPathOperationTests.m */; };
28+
86E9A893272754860017E6E0 /* PickerSaveImageToPathOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86E9A892272754860017E6E0 /* PickerSaveImageToPathOperationTests.swift */; };
29+
F8A11B022E8C000100000001 /* TestDoubles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A11B012E8C000100000001 /* TestDoubles.swift */; };
2930
86E9A894272754A30017E6E0 /* webpImage.webp in Resources */ = {isa = PBXBuildFile; fileRef = 86E9A88F272747B90017E6E0 /* webpImage.webp */; };
3031
86E9A895272769130017E6E0 /* pngImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 680049352280F2B8006DD6AB /* pngImage.png */; };
3132
86E9A896272769150017E6E0 /* jpgImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 680049362280F2B8006DD6AB /* jpgImage.jpg */; };
@@ -85,14 +86,14 @@
8586
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
8687
5C9512FF1EC38BD300040975 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
8788
5C9513001EC38BD300040975 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
88-
680049252280D736006DD6AB /* MetaDataUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MetaDataUtilTests.m; sourceTree = "<group>"; };
89+
680049252280D736006DD6AB /* MetaDataUtilTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetaDataUtilTests.swift; sourceTree = "<group>"; };
8990
680049352280F2B8006DD6AB /* pngImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pngImage.png; sourceTree = "<group>"; };
9091
680049362280F2B8006DD6AB /* jpgImage.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = jpgImage.jpg; sourceTree = "<group>"; };
9192
6801C8362555D726009DAF8D /* RunnerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
9293
6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromGalleryUITests.m; sourceTree = "<group>"; };
9394
6801C83A2555D726009DAF8D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9495
68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImagePickerPluginTests.m; sourceTree = "<group>"; };
95-
68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PhotoAssetUtilTests.m; sourceTree = "<group>"; };
96+
68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoAssetUtilTests.swift; sourceTree = "<group>"; };
9697
782C2B44299ECE33008DC703 /* jpgImageWithRightOrientation.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = jpgImageWithRightOrientation.jpg; sourceTree = "<group>"; };
9798
784666492D4C4C64000A1A5F /* FlutterFramework */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterFramework; path = Flutter/ephemeral/Packages/.packages/FlutterFramework; sourceTree = "<group>"; };
9899
7865C5E02941326F0010E17F /* bmpImage.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = bmpImage.bmp; sourceTree = "<group>"; };
@@ -107,7 +108,8 @@
107108
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
108109
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
109110
86E9A88F272747B90017E6E0 /* webpImage.webp */ = {isa = PBXFileReference; lastKnownFileType = file; path = webpImage.webp; sourceTree = "<group>"; };
110-
86E9A892272754860017E6E0 /* PickerSaveImageToPathOperationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PickerSaveImageToPathOperationTests.m; sourceTree = "<group>"; };
111+
86E9A892272754860017E6E0 /* PickerSaveImageToPathOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickerSaveImageToPathOperationTests.swift; sourceTree = "<group>"; };
112+
F8A11B012E8C000100000001 /* TestDoubles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestDoubles.swift; sourceTree = "<group>"; };
111113
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
112114
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
113115
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -117,7 +119,7 @@
117119
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
118120
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
119121
9FC8F0E8229FA49E00C8D58F /* gifImage.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = gifImage.gif; sourceTree = "<group>"; };
120-
9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageUtilTests.m; sourceTree = "<group>"; };
122+
9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageUtilTests.swift; sourceTree = "<group>"; };
121123
BE6173D726A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromLimitedGalleryUITests.m; sourceTree = "<group>"; };
122124
F706BF722E433163001263B9 /* jpgImageTall.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = jpgImageTall.jpg; sourceTree = "<group>"; };
123125
F78AF3172342D9D7008449C7 /* ImagePickerTestImages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImagePickerTestImages.h; sourceTree = "<group>"; };
@@ -154,13 +156,14 @@
154156
334733F32668136400DCC49E /* RunnerTests */ = {
155157
isa = PBXGroup;
156158
children = (
157-
9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.m */,
158-
680049252280D736006DD6AB /* MetaDataUtilTests.m */,
159-
68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */,
159+
9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.swift */,
160+
680049252280D736006DD6AB /* MetaDataUtilTests.swift */,
161+
68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.swift */,
160162
F78AF3172342D9D7008449C7 /* ImagePickerTestImages.h */,
161163
F78AF3182342D9D7008449C7 /* ImagePickerTestImages.m */,
162164
68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */,
163-
86E9A892272754860017E6E0 /* PickerSaveImageToPathOperationTests.m */,
165+
86E9A892272754860017E6E0 /* PickerSaveImageToPathOperationTests.swift */,
166+
F8A11B012E8C000100000001 /* TestDoubles.swift */,
164167
334733F62668136400DCC49E /* Info.plist */,
165168
);
166169
path = RunnerTests;
@@ -464,12 +467,13 @@
464467
isa = PBXSourcesBuildPhase;
465468
buildActionMask = 2147483647;
466469
files = (
467-
334733FD266813F100DCC49E /* MetaDataUtilTests.m in Sources */,
470+
334733FD266813F100DCC49E /* MetaDataUtilTests.swift in Sources */,
468471
334733FF266813FA00DCC49E /* ImagePickerTestImages.m in Sources */,
469-
86E9A893272754860017E6E0 /* PickerSaveImageToPathOperationTests.m in Sources */,
470-
334733FC266813EE00DCC49E /* ImageUtilTests.m in Sources */,
472+
86E9A893272754860017E6E0 /* PickerSaveImageToPathOperationTests.swift in Sources */,
473+
F8A11B022E8C000100000001 /* TestDoubles.swift in Sources */,
474+
334733FC266813EE00DCC49E /* ImageUtilTests.swift in Sources */,
471475
33473400266813FD00DCC49E /* ImagePickerPluginTests.m in Sources */,
472-
334733FE266813F400DCC49E /* PhotoAssetUtilTests.m in Sources */,
476+
334733FE266813F400DCC49E /* PhotoAssetUtilTests.swift in Sources */,
473477
);
474478
runOnlyForDeploymentPostprocessing = 0;
475479
};
@@ -533,12 +537,15 @@
533537
BUNDLE_LOADER = "$(TEST_HOST)";
534538
CODE_SIGN_STYLE = Automatic;
535539
INFOPLIST_FILE = RunnerTests/Info.plist;
540+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
536541
LD_RUNPATH_SEARCH_PATHS = (
537542
"$(inherited)",
538543
"@executable_path/Frameworks",
539544
"@loader_path/Frameworks",
540545
);
541546
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
547+
SWIFT_OBJC_BRIDGING_HEADER = "RunnerTests/RunnerTests-Bridging-Header.h";
548+
SWIFT_VERSION = 5.0;
542549
PRODUCT_NAME = "$(TARGET_NAME)";
543550
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
544551
};
@@ -550,12 +557,15 @@
550557
BUNDLE_LOADER = "$(TEST_HOST)";
551558
CODE_SIGN_STYLE = Automatic;
552559
INFOPLIST_FILE = RunnerTests/Info.plist;
560+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
553561
LD_RUNPATH_SEARCH_PATHS = (
554562
"$(inherited)",
555563
"@executable_path/Frameworks",
556564
"@loader_path/Frameworks",
557565
);
558566
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
567+
SWIFT_OBJC_BRIDGING_HEADER = "RunnerTests/RunnerTests-Bridging-Header.h";
568+
SWIFT_VERSION = 5.0;
559569
PRODUCT_NAME = "$(TARGET_NAME)";
560570
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
561571
};

0 commit comments

Comments
 (0)