From 5aa00054cd45e8a2879d248f8a9bae07e20ca691 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Tue, 5 Aug 2025 23:43:56 -0700 Subject: [PATCH 1/7] [image_picker] Add photo to simulator Photos app during test --- .../image_picker_ios/CHANGELOG.md | 1 + .../ios/Runner.xcodeproj/project.pbxproj | 46 +++++++++++-------- .../example/ios/Runner/AppDelegate.m | 22 +++++++-- .../ImagePickerFromGalleryUITests.m | 9 +++- 4 files changed, 54 insertions(+), 24 deletions(-) diff --git a/packages/image_picker/image_picker_ios/CHANGELOG.md b/packages/image_picker/image_picker_ios/CHANGELOG.md index de2edfd411f..87177efeb9b 100644 --- a/packages/image_picker/image_picker_ios/CHANGELOG.md +++ b/packages/image_picker/image_picker_ios/CHANGELOG.md @@ -1,6 +1,7 @@ ## NEXT * Updates minimum supported SDK version to Flutter 3.27/Dart 3.6. +* Adds photo to Photos app during test to support iOS 26. ## 0.8.12+2 diff --git a/packages/image_picker/image_picker_ios/example/ios/Runner.xcodeproj/project.pbxproj b/packages/image_picker/image_picker_ios/example/ios/Runner.xcodeproj/project.pbxproj index 34a80cc4d40..9f6500ce2be 100644 --- a/packages/image_picker/image_picker_ios/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/image_picker/image_picker_ios/example/ios/Runner.xcodeproj/project.pbxproj @@ -15,23 +15,14 @@ 3A72BAD3FAE6E0FA9D80826B /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35AE65F25E0B8C8214D8372B /* libPods-RunnerTests.a */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 5C9513011EC38BD300040975 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C9513001EC38BD300040975 /* GeneratedPluginRegistrant.m */; }; - 680049382280F2B9006DD6AB /* pngImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 680049352280F2B8006DD6AB /* pngImage.png */; }; - 680049392280F2B9006DD6AB /* jpgImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 680049362280F2B8006DD6AB /* jpgImage.jpg */; }; 6801C8392555D726009DAF8D /* ImagePickerFromGalleryUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */; }; 782C2B45299ECE33008DC703 /* jpgImageWithRightOrientation.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 782C2B44299ECE33008DC703 /* jpgImageWithRightOrientation.jpg */; }; - 782C2B46299ECE33008DC703 /* jpgImageWithRightOrientation.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 782C2B44299ECE33008DC703 /* jpgImageWithRightOrientation.jpg */; }; 7865C5E12941326F0010E17F /* bmpImage.bmp in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E02941326F0010E17F /* bmpImage.bmp */; }; - 7865C5E22941326F0010E17F /* bmpImage.bmp in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E02941326F0010E17F /* bmpImage.bmp */; }; 7865C5E72941374F0010E17F /* heicImage.heic in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E62941374F0010E17F /* heicImage.heic */; }; - 7865C5E82941374F0010E17F /* heicImage.heic in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E62941374F0010E17F /* heicImage.heic */; }; 7865C5EA294137960010E17F /* icoImage.ico in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E9294137960010E17F /* icoImage.ico */; }; - 7865C5EB294137960010E17F /* icoImage.ico in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E9294137960010E17F /* icoImage.ico */; }; 7865C5ED294137AB0010E17F /* tiffImage.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5EC294137AB0010E17F /* tiffImage.tiff */; }; - 7865C5EE294137AB0010E17F /* tiffImage.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5EC294137AB0010E17F /* tiffImage.tiff */; }; 7865C5FC294157BC0010E17F /* icnsImage.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5FB294157BB0010E17F /* icnsImage.icns */; }; - 7865C5FD294157BC0010E17F /* icnsImage.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5FB294157BB0010E17F /* icnsImage.icns */; }; 7865C5FF294252A60010E17F /* proRawImage.dng in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5FE294252A60010E17F /* proRawImage.dng */; }; - 7865C600294252A60010E17F /* proRawImage.dng in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5FE294252A60010E17F /* proRawImage.dng */; }; 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 78CF8D862BC5E7070051231B /* OCMock in Frameworks */ = {isa = PBXBuildFile; productRef = 78CF8D852BC5E7070051231B /* OCMock */; }; 86430DF9272D71E9002D9D6C /* gifImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */; }; @@ -44,9 +35,20 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 9FC8F0E9229FA49E00C8D58F /* gifImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */; }; - 9FC8F0EC229FA68500C8D58F /* gifImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */; }; BE6173D826A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = BE6173D726A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m */; }; F4F7A436CCA4BF276270A3AE /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EC32F6993F4529982D9519F1 /* libPods-Runner.a */; }; + F706BF732E433163001263B9 /* jpgImageTall.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F706BF722E433163001263B9 /* jpgImageTall.jpg */; }; + F706BF762E4331C4001263B9 /* pngImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 680049352280F2B8006DD6AB /* pngImage.png */; }; + F706BF772E4331C4001263B9 /* jpgImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 680049362280F2B8006DD6AB /* jpgImage.jpg */; }; + F706BF782E4331C4001263B9 /* icnsImage.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5FB294157BB0010E17F /* icnsImage.icns */; }; + F706BF792E4331C4001263B9 /* icoImage.ico in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E9294137960010E17F /* icoImage.ico */; }; + F706BF7A2E4331C4001263B9 /* jpgImageTall.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F706BF722E433163001263B9 /* jpgImageTall.jpg */; }; + F706BF7B2E4331C4001263B9 /* proRawImage.dng in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5FE294252A60010E17F /* proRawImage.dng */; }; + F706BF7C2E4331C4001263B9 /* heicImage.heic in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E62941374F0010E17F /* heicImage.heic */; }; + F706BF7D2E4331C4001263B9 /* tiffImage.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5EC294137AB0010E17F /* tiffImage.tiff */; }; + F706BF7E2E4331C4001263B9 /* jpgImageWithRightOrientation.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 782C2B44299ECE33008DC703 /* jpgImageWithRightOrientation.jpg */; }; + F706BF7F2E4331C4001263B9 /* webpImage.webp in Resources */ = {isa = PBXBuildFile; fileRef = 86E9A88F272747B90017E6E0 /* webpImage.webp */; }; + F706BF802E4331C4001263B9 /* bmpImage.bmp in Resources */ = {isa = PBXBuildFile; fileRef = 7865C5E02941326F0010E17F /* bmpImage.bmp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -122,6 +124,7 @@ BE6173D726A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromLimitedGalleryUITests.m; sourceTree = ""; }; DC6FCAAD4E7580C9B3C2E21D /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; EC32F6993F4529982D9519F1 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + F706BF722E433163001263B9 /* jpgImageTall.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = jpgImageTall.jpg; sourceTree = ""; }; F78AF3172342D9D7008449C7 /* ImagePickerTestImages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImagePickerTestImages.h; sourceTree = ""; }; F78AF3182342D9D7008449C7 /* ImagePickerTestImages.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerTestImages.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -177,6 +180,7 @@ 86E9A88F272747B90017E6E0 /* webpImage.webp */, 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */, 680049362280F2B8006DD6AB /* jpgImage.jpg */, + F706BF722E433163001263B9 /* jpgImageTall.jpg */, 680049352280F2B8006DD6AB /* pngImage.png */, 7865C5E02941326F0010E17F /* bmpImage.bmp */, 7865C5E62941374F0010E17F /* heicImage.heic */, @@ -407,6 +411,7 @@ 86430DF9272D71E9002D9D6C /* gifImage.gif in Resources */, 7865C5FF294252A60010E17F /* proRawImage.dng in Resources */, 7865C5EA294137960010E17F /* icoImage.ico in Resources */, + F706BF732E433163001263B9 /* jpgImageTall.jpg in Resources */, 7865C5E72941374F0010E17F /* heicImage.heic in Resources */, 86E9A894272754A30017E6E0 /* webpImage.webp in Resources */, 86E9A895272769130017E6E0 /* pngImage.png in Resources */, @@ -421,16 +426,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 9FC8F0EC229FA68500C8D58F /* gifImage.gif in Resources */, - 7865C5EE294137AB0010E17F /* tiffImage.tiff in Resources */, - 782C2B46299ECE33008DC703 /* jpgImageWithRightOrientation.jpg in Resources */, - 7865C5E82941374F0010E17F /* heicImage.heic in Resources */, - 7865C5FD294157BC0010E17F /* icnsImage.icns in Resources */, - 680049382280F2B9006DD6AB /* pngImage.png in Resources */, - 680049392280F2B9006DD6AB /* jpgImage.jpg in Resources */, - 7865C5EB294137960010E17F /* icoImage.ico in Resources */, - 7865C5E22941326F0010E17F /* bmpImage.bmp in Resources */, - 7865C600294252A60010E17F /* proRawImage.dng in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -439,6 +434,17 @@ buildActionMask = 2147483647; files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + F706BF762E4331C4001263B9 /* pngImage.png in Resources */, + F706BF772E4331C4001263B9 /* jpgImage.jpg in Resources */, + F706BF782E4331C4001263B9 /* icnsImage.icns in Resources */, + F706BF792E4331C4001263B9 /* icoImage.ico in Resources */, + F706BF7A2E4331C4001263B9 /* jpgImageTall.jpg in Resources */, + F706BF7B2E4331C4001263B9 /* proRawImage.dng in Resources */, + F706BF7C2E4331C4001263B9 /* heicImage.heic in Resources */, + F706BF7D2E4331C4001263B9 /* tiffImage.tiff in Resources */, + F706BF7E2E4331C4001263B9 /* jpgImageWithRightOrientation.jpg in Resources */, + F706BF7F2E4331C4001263B9 /* webpImage.webp in Resources */, + F706BF802E4331C4001263B9 /* bmpImage.bmp in Resources */, 9FC8F0E9229FA49E00C8D58F /* gifImage.gif in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, diff --git a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m index b790a0a5263..9259614b146 100644 --- a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m +++ b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m @@ -5,12 +5,28 @@ #include "AppDelegate.h" #include "GeneratedPluginRegistrant.h" +@import Photos; +@import os.log; + @implementation AppDelegate - (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GeneratedPluginRegistrant registerWithRegistry:self]; - return [super application:application didFinishLaunchingWithOptions:launchOptions]; +didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + + if (@available(iOS 14, *)) { + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + __block NSError *saveError = nil; + [PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelAddOnly handler:^(PHAuthorizationStatus status) { + if (![PHPhotoLibrary.sharedPhotoLibrary performChangesAndWait:^{ + NSURL *jpgImageTall = [bundle URLForResource:@"jpgImageTall" withExtension:@"jpg"]; + [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:jpgImageTall]; + } error:&saveError]) { + os_log_error(OS_LOG_DEFAULT, "%@", saveError); + } + }]; + } + return [super application:application didFinishLaunchingWithOptions:launchOptions]; } @end diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m index 45149f65f19..c8b1987c175 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -220,7 +220,14 @@ - (void)launchPickerAndPickWithMaxWidth:(NSNumber *)maxWidth os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); XCTFail(@"Failed due to not able to find an image with %@ seconds", @(kElementWaitingTime)); } - [aImage tap]; + if (aImage.isHittable) { + [aImage tap]; + } else { + // Know issue where tappable things are not hittable. Tap it anyway. + // See https://github.com/flutter/plugins/pull/6783 for a similar case. + XCUICoordinate *coordinate = [aImage coordinateWithNormalizedOffset:CGVectorMake(0, 0)]; + [coordinate tap]; + } // Find the picked image. XCUIElement *pickedImage = self.app.images[@"image_picker_example_picked_image"].firstMatch; From c1bef85273bab071ca872e9db455c38869f89d10 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Tue, 5 Aug 2025 23:58:43 -0700 Subject: [PATCH 2/7] Update packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m --- .../example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m index c8b1987c175..c4f7b7cbc25 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -223,7 +223,7 @@ - (void)launchPickerAndPickWithMaxWidth:(NSNumber *)maxWidth if (aImage.isHittable) { [aImage tap]; } else { - // Know issue where tappable things are not hittable. Tap it anyway. + // Known issue where tappable elements are not hittable. Tap it anyway. // See https://github.com/flutter/plugins/pull/6783 for a similar case. XCUICoordinate *coordinate = [aImage coordinateWithNormalizedOffset:CGVectorMake(0, 0)]; [coordinate tap]; From 4bebeb49f5d578d1a0c125b345f7f49a81ed23c0 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 6 Aug 2025 00:34:16 -0700 Subject: [PATCH 3/7] Format --- .../example/ios/Runner/AppDelegate.m | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m index 9259614b146..80a6de082a3 100644 --- a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m +++ b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m @@ -11,22 +11,30 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application -didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GeneratedPluginRegistrant registerWithRegistry:self]; - - if (@available(iOS 14, *)) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - __block NSError *saveError = nil; - [PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelAddOnly handler:^(PHAuthorizationStatus status) { - if (![PHPhotoLibrary.sharedPhotoLibrary performChangesAndWait:^{ - NSURL *jpgImageTall = [bundle URLForResource:@"jpgImageTall" withExtension:@"jpg"]; - [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:jpgImageTall]; - } error:&saveError]) { - os_log_error(OS_LOG_DEFAULT, "%@", saveError); - } - }]; - } - return [super application:application didFinishLaunchingWithOptions:launchOptions]; + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + + if (@available(iOS 14, *)) { + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + __block NSError *saveError = nil; + [PHPhotoLibrary + requestAuthorizationForAccessLevel:PHAccessLevelAddOnly + handler:^(PHAuthorizationStatus status) { + if (![PHPhotoLibrary.sharedPhotoLibrary + performChangesAndWait:^{ + NSURL *jpgImageTall = + [bundle URLForResource:@"jpgImageTall" + withExtension:@"jpg"]; + [PHAssetChangeRequest + creationRequestForAssetFromImageAtFileURL: + jpgImageTall]; + } + error:&saveError]) { + os_log_error(OS_LOG_DEFAULT, "%@", saveError); + } + }]; + } + return [super application:application didFinishLaunchingWithOptions:launchOptions]; } @end From 62a1b7df2e0424abd4519690b257901d7c8983d9 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 6 Aug 2025 00:36:30 -0700 Subject: [PATCH 4/7] library --- packages/image_picker/image_picker_ios/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/image_picker_ios/CHANGELOG.md b/packages/image_picker/image_picker_ios/CHANGELOG.md index 87177efeb9b..4a1bae0c068 100644 --- a/packages/image_picker/image_picker_ios/CHANGELOG.md +++ b/packages/image_picker/image_picker_ios/CHANGELOG.md @@ -1,7 +1,7 @@ ## NEXT * Updates minimum supported SDK version to Flutter 3.27/Dart 3.6. -* Adds photo to Photos app during test to support iOS 26. +* Adds photo to Photos library during test to support iOS 26. ## 0.8.12+2 From 2d6dbd8e1f4b1e38292f3c5878b9310d64200328 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 6 Aug 2025 10:17:04 -0700 Subject: [PATCH 5/7] format --- .../ImagePickerFromGalleryUITests.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m index c4f7b7cbc25..d17f2b6b600 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -220,14 +220,14 @@ - (void)launchPickerAndPickWithMaxWidth:(NSNumber *)maxWidth os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); XCTFail(@"Failed due to not able to find an image with %@ seconds", @(kElementWaitingTime)); } - if (aImage.isHittable) { - [aImage tap]; - } else { - // Known issue where tappable elements are not hittable. Tap it anyway. - // See https://github.com/flutter/plugins/pull/6783 for a similar case. - XCUICoordinate *coordinate = [aImage coordinateWithNormalizedOffset:CGVectorMake(0, 0)]; - [coordinate tap]; - } + if (aImage.isHittable) { + [aImage tap]; + } else { + // Known issue where tappable elements are not hittable. Tap it anyway. + // See https://github.com/flutter/plugins/pull/6783 for a similar case. + XCUICoordinate *coordinate = [aImage coordinateWithNormalizedOffset:CGVectorMake(0, 0)]; + [coordinate tap]; + } // Find the picked image. XCUIElement *pickedImage = self.app.images[@"image_picker_example_picked_image"].firstMatch; From f452ca258fae0ce252bfab8b5f31cb75e0036252 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 13 Aug 2025 22:13:58 -0700 Subject: [PATCH 6/7] another test --- .../example/ios/Runner/AppDelegate.m | 48 +++++++++++-------- .../ImagePickerFromLimitedGalleryUITests.m | 9 +++- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m index 80a6de082a3..855192bbb2d 100644 --- a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m +++ b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m @@ -13,27 +13,33 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GeneratedPluginRegistrant registerWithRegistry:self]; - - if (@available(iOS 14, *)) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - __block NSError *saveError = nil; - [PHPhotoLibrary - requestAuthorizationForAccessLevel:PHAccessLevelAddOnly - handler:^(PHAuthorizationStatus status) { - if (![PHPhotoLibrary.sharedPhotoLibrary - performChangesAndWait:^{ - NSURL *jpgImageTall = - [bundle URLForResource:@"jpgImageTall" - withExtension:@"jpg"]; - [PHAssetChangeRequest - creationRequestForAssetFromImageAtFileURL: - jpgImageTall]; - } - error:&saveError]) { - os_log_error(OS_LOG_DEFAULT, "%@", saveError); - } - }]; - } + if (@available(iOS 14, *)) { + // Seed the photo library with at least one image for tests to operate on. + NSString *photoAddedKey = @"PhotoAdded"; + BOOL photoAdded = [NSUserDefaults.standardUserDefaults boolForKey:photoAddedKey]; + if (!photoAdded) { + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + __block NSError *saveError = nil; + [PHPhotoLibrary + requestAuthorizationForAccessLevel:PHAccessLevelAddOnly + handler:^(PHAuthorizationStatus status) { + if ([PHPhotoLibrary.sharedPhotoLibrary + performChangesAndWait:^{ + NSURL *jpgImageTall = + [bundle URLForResource:@"jpgImageTall" + withExtension:@"jpg"]; + [PHAssetChangeRequest + creationRequestForAssetFromImageAtFileURL: + jpgImageTall]; + } + error:&saveError]) { + [NSUserDefaults.standardUserDefaults setBool:YES forKey:photoAddedKey]; + } else { + os_log_error(OS_LOG_DEFAULT, "%@", saveError); + } + }]; + } + } return [super application:application didFinishLaunchingWithOptions:launchOptions]; } diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m index bc5f8add84f..fc246ee793d 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m @@ -115,7 +115,14 @@ - (void)testSelectingFromGallery API_AVAILABLE(ios(14)) { @(kLimitedElementWaitingTime)); } - [aImage tap]; + if (aImage.isHittable) { + [aImage tap]; + } else { + // Known issue where tappable elements are not hittable. Tap it anyway. + // See https://github.com/flutter/plugins/pull/6783 for a similar case. + XCUICoordinate *coordinate = [aImage coordinateWithNormalizedOffset:CGVectorMake(0, 0)]; + [coordinate tap]; + } // Find the picked image. XCUIElement *pickedImage = self.app.images[@"image_picker_example_picked_image"].firstMatch; From eef8b0a0283c6e41014694e0757d8d3441808b16 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 13 Aug 2025 22:27:08 -0700 Subject: [PATCH 7/7] format --- .../example/ios/Runner/AppDelegate.m | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m index 855192bbb2d..f9e336794b4 100644 --- a/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m +++ b/packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m @@ -13,33 +13,35 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GeneratedPluginRegistrant registerWithRegistry:self]; - if (@available(iOS 14, *)) { + if (@available(iOS 14, *)) { // Seed the photo library with at least one image for tests to operate on. NSString *photoAddedKey = @"PhotoAdded"; BOOL photoAdded = [NSUserDefaults.standardUserDefaults boolForKey:photoAddedKey]; if (!photoAdded) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - __block NSError *saveError = nil; - [PHPhotoLibrary - requestAuthorizationForAccessLevel:PHAccessLevelAddOnly - handler:^(PHAuthorizationStatus status) { - if ([PHPhotoLibrary.sharedPhotoLibrary - performChangesAndWait:^{ - NSURL *jpgImageTall = - [bundle URLForResource:@"jpgImageTall" - withExtension:@"jpg"]; - [PHAssetChangeRequest - creationRequestForAssetFromImageAtFileURL: - jpgImageTall]; - } - error:&saveError]) { - [NSUserDefaults.standardUserDefaults setBool:YES forKey:photoAddedKey]; - } else { - os_log_error(OS_LOG_DEFAULT, "%@", saveError); - } - }]; - } + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + __block NSError *saveError = nil; + [PHPhotoLibrary + requestAuthorizationForAccessLevel:PHAccessLevelAddOnly + handler:^(PHAuthorizationStatus status) { + if ([PHPhotoLibrary.sharedPhotoLibrary + performChangesAndWait:^{ + NSURL *jpgImageTall = + [bundle URLForResource:@"jpgImageTall" + withExtension:@"jpg"]; + [PHAssetChangeRequest + creationRequestForAssetFromImageAtFileURL: + jpgImageTall]; + } + error:&saveError]) { + [NSUserDefaults.standardUserDefaults + setBool:YES + forKey:photoAddedKey]; + } else { + os_log_error(OS_LOG_DEFAULT, "%@", saveError); + } + }]; } + } return [super application:application didFinishLaunchingWithOptions:launchOptions]; }