From 3e4b1f3edf6ef6b61edc787813de012d23b54134 Mon Sep 17 00:00:00 2001 From: yusufdag Date: Thu, 22 Jul 2021 10:14:12 +0200 Subject: [PATCH 1/6] Move UI test to RunnerUITests target --- .../ios/Runner.xcodeproj/project.pbxproj | 121 +------------ .../ImagePickerFromLimitedGalleryUITests.m | 170 ++++++++++++++++++ 2 files changed, 174 insertions(+), 117 deletions(-) create mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m diff --git a/packages/image_picker/image_picker/example/ios/Runner.xcodeproj/project.pbxproj b/packages/image_picker/image_picker/example/ios/Runner.xcodeproj/project.pbxproj index fc1609f5eeda..2f28c9ad2d6d 100644 --- a/packages/image_picker/image_picker/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/image_picker/image_picker/example/ios/Runner.xcodeproj/project.pbxproj @@ -25,7 +25,7 @@ 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 */; }; - BE7AEE7926403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = BE7AEE7826403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m */; }; + BE6173D826A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = BE6173D726A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m */; }; F4F7A436CCA4BF276270A3AE /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EC32F6993F4529982D9519F1 /* libPods-Runner.a */; }; /* End PBXBuildFile section */ @@ -44,13 +44,6 @@ remoteGlobalIDString = 97C146ED1CF9000F007C117D; remoteInfo = Runner; }; - BE7AEE7126403C46006181AA /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 97C146E61CF9000F007C117D /* Project object */; - proxyType = 1; - remoteGlobalIDString = 97C146ED1CF9000F007C117D; - remoteInfo = Runner; - }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -100,7 +93,7 @@ 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = gifImage.gif; sourceTree = ""; }; 9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImageUtilTests.m; sourceTree = ""; }; A908FAEEA2A9B26D903C09C5 /* libPods-RunnerUITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerUITests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITestiOS14.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + BE6173D726A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromLimitedGalleryUITests.m; sourceTree = ""; }; BE7AEE7026403C46006181AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; BE7AEE7826403CC8006181AA /* 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 = ""; }; @@ -134,13 +127,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - BE7AEE6926403C46006181AA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -171,6 +157,7 @@ 6801C8372555D726009DAF8D /* RunnerUITests */ = { isa = PBXGroup; children = ( + BE6173D726A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m */, 6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */, 6801C83A2555D726009DAF8D /* Info.plist */, ); @@ -221,7 +208,6 @@ children = ( 97C146EE1CF9000F007C117D /* Runner.app */, 6801C8362555D726009DAF8D /* RunnerUITests.xctest */, - BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */, 334733F22668136400DCC49E /* RunnerTests.xctest */, ); name = Products; @@ -332,24 +318,6 @@ productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productType = "com.apple.product-type.application"; }; - BE7AEE6B26403C46006181AA /* RunnerUITestiOS14 */ = { - isa = PBXNativeTarget; - buildConfigurationList = BE7AEE7526403C46006181AA /* Build configuration list for PBXNativeTarget "RunnerUITestiOS14" */; - buildPhases = ( - BE7AEE6826403C46006181AA /* Sources */, - BE7AEE6926403C46006181AA /* Frameworks */, - BE7AEE6A26403C46006181AA /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - BE7AEE7226403C46006181AA /* PBXTargetDependency */, - ); - name = RunnerUITestiOS14; - productName = RunnerUITestiOS14; - productReference = BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */; - productType = "com.apple.product-type.bundle.ui-testing"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -378,11 +346,6 @@ }; }; }; - BE7AEE6B26403C46006181AA = { - CreatedOnToolsVersion = 12.4; - ProvisioningStyle = Automatic; - TestTargetID = 97C146ED1CF9000F007C117D; - }; }; }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; @@ -401,7 +364,6 @@ 97C146ED1CF9000F007C117D /* Runner */, 334733F12668136400DCC49E /* RunnerTests */, 6801C8352555D726009DAF8D /* RunnerUITests */, - BE7AEE6B26403C46006181AA /* RunnerUITestiOS14 */, ); }; /* End PBXProject section */ @@ -435,13 +397,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - BE7AEE6A26403C46006181AA /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -555,6 +510,7 @@ buildActionMask = 2147483647; files = ( 6801C8392555D726009DAF8D /* ImagePickerFromGalleryUITests.m in Sources */, + BE6173D826A958B800D0974D /* ImagePickerFromLimitedGalleryUITests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -568,14 +524,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - BE7AEE6826403C46006181AA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BE7AEE7926403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -589,11 +537,6 @@ target = 97C146ED1CF9000F007C117D /* Runner */; targetProxy = 6801C83B2555D726009DAF8D /* PBXContainerItemProxy */; }; - BE7AEE7226403C46006181AA /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 97C146ED1CF9000F007C117D /* Runner */; - targetProxy = BE7AEE7126403C46006181AA /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -843,53 +786,6 @@ }; name = Release; }; - BE7AEE7326403C46006181AA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = RunnerUITestiOS14/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.RunnerUITestiOS14; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_TARGET_NAME = Runner; - }; - name = Debug; - }; - BE7AEE7426403C46006181AA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = RunnerUITestiOS14/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.RunnerUITestiOS14; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_TARGET_NAME = Runner; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -929,15 +825,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - BE7AEE7526403C46006181AA /* Build configuration list for PBXNativeTarget "RunnerUITestiOS14" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BE7AEE7326403C46006181AA /* Debug */, - BE7AEE7426403C46006181AA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m new file mode 100644 index 000000000000..52204afa89ed --- /dev/null +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m @@ -0,0 +1,170 @@ +// 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 +#import + +const int kLimitedElementWaitingTime = 30; + +@interface ImagePickerFromLimitedGalleryUITests : XCTestCase + +@property(nonatomic, strong) XCUIApplication* app; + +@end + +@implementation ImagePickerFromLimitedGalleryUITests + +- (void)setUp { + [super setUp]; + // Delete the app if already exists, to test permission popups + + self.continueAfterFailure = NO; + self.app = [[XCUIApplication alloc] init]; + [self.app launch]; + __weak typeof(self) weakSelf = self; + [self addUIInterruptionMonitorWithDescription:@"Permission popups" + handler:^BOOL(XCUIElement* _Nonnull interruptingElement) { + XCUIElement* limitedPhotoPermission = + [interruptingElement.buttons elementBoundByIndex:0]; + if (![limitedPhotoPermission + waitForExistenceWithTimeout: + kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", + weakSelf.app.debugDescription); + XCTFail(@"Failed due to not able to find " + @"selectPhotos butt on with %@ seconds", + @(kLimitedElementWaitingTime)); + } + [limitedPhotoPermission tap]; + return YES; + }]; +} + +- (void)tearDown { + [super tearDown]; + [self.app terminate]; +} + +- (void)testSelectingFromGallery { + if (@available(iOS 14, *)) { + [self launchPickerAndSelect]; + } else { + return; + } +} + +- (void)launchPickerAndSelect { + // Find and tap on the pick from gallery button. + NSPredicate* predicateToFindImageFromGalleryButton = + [NSPredicate predicateWithFormat:@"label == %@", @"image_picker_example_from_gallery"]; + + XCUIElement* imageFromGalleryButton = + [self.app.otherElements elementMatchingPredicate:predicateToFindImageFromGalleryButton]; + if (![imageFromGalleryButton waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", + @(kLimitedElementWaitingTime)); + } + + XCTAssertTrue(imageFromGalleryButton.exists); + [imageFromGalleryButton tap]; + + // Find and tap on the `pick` button. + NSPredicate* predicateToFindPickButton = + [NSPredicate predicateWithFormat:@"label == %@", @"PICK"]; + + XCUIElement* pickButton = [self.app.buttons elementMatchingPredicate:predicateToFindPickButton]; + if (![pickButton waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTSkip(@"Pick button isn't found so the test is skipped..."); + } + + XCTAssertTrue(pickButton.exists); + [pickButton tap]; + + // There is a known bug where the permission popups interruption won't get fired until a tap + // happened in the app. We expect a permission popup so we do a tap here. + [self.app tap]; + + // Find an image and tap on it. (IOS 14 UI, images are showing directly) + XCUIElement* aImage; + if (@available(iOS 14, *)) { + aImage = [self.app.scrollViews.firstMatch.images elementBoundByIndex:1]; + } else { + XCUIElement* selectedPhotosCell = [self.app.cells + elementMatchingPredicate:[NSPredicate + predicateWithFormat:@"label == %@", @"Selected Photos"]]; + if (![selectedPhotosCell waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find \"Selected Photos\" cell with %@ seconds", + @(kLimitedElementWaitingTime)); + } + [selectedPhotosCell tap]; + aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView + identifier:@"PhotosGridView"] + .cells.firstMatch; + } + os_log_error(OS_LOG_DEFAULT, "description before picking image %@", self.app.debugDescription); + if (![aImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find an image with %@ seconds", + @(kLimitedElementWaitingTime)); + } + XCTAssertTrue(aImage.exists); + [aImage tap]; + + // Find and tap on the `Done` button. + NSPredicate* predicateToFindDoneButton = + [NSPredicate predicateWithFormat:@"label == %@", @"Done"]; + + XCUIElement* doneButton = [self.app.buttons elementMatchingPredicate:predicateToFindDoneButton]; + if (![doneButton waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTSkip(@"Permissions popup could not fired so the test is skipped..."); + } + + XCTAssertTrue(doneButton.exists); + [doneButton tap]; + + // Find an image and tap on it to have access to selected photos. + if (@available(iOS 14, *)) { + aImage = [self.app.scrollViews.firstMatch.images elementBoundByIndex:1]; + } else { + XCUIElement* selectedPhotosCell = [self.app.cells + elementMatchingPredicate:[NSPredicate + predicateWithFormat:@"label == %@", @"Selected Photos"]]; + if (![selectedPhotosCell waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find \"Selected Photos\" cell with %@ seconds", + @(kLimitedElementWaitingTime)); + } + [selectedPhotosCell tap]; + aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView + identifier:@"PhotosGridView"] + .cells.firstMatch; + } + os_log_error(OS_LOG_DEFAULT, "description before picking image %@", self.app.debugDescription); + if (![aImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find an image with %@ seconds", + @(kLimitedElementWaitingTime)); + } + XCTAssertTrue(aImage.exists); + [aImage tap]; + + // Find the picked image. + NSPredicate* predicateToFindPickedImage = + [NSPredicate predicateWithFormat:@"label == %@", @"image_picker_example_picked_image"]; + + XCUIElement* pickedImage = [self.app.images elementMatchingPredicate:predicateToFindPickedImage]; + if (![pickedImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find pickedImage with %@ seconds", + @(kLimitedElementWaitingTime)); + } + + XCTAssertTrue(pickedImage.exists); +} + +@end From ea7c5fd9a4a1665d91029d6a7caf9de8df02504c Mon Sep 17 00:00:00 2001 From: yusufdag Date: Thu, 22 Jul 2021 10:16:31 +0200 Subject: [PATCH 2/6] Update version and CHANGELOG --- packages/image_picker/image_picker/CHANGELOG.md | 4 ++++ packages/image_picker/image_picker/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md index fef3e47cdf1a..831eb8a059ec 100644 --- a/packages/image_picker/image_picker/CHANGELOG.md +++ b/packages/image_picker/image_picker/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.2+1 + +* Move `ImagePickerFromLimitedGalleryUITests` to `RunnerUITests` target. + ## 0.8.2 * Added new methods that return `package:cross_file` `XFile` instances. [Docs](https://pub.dev/documentation/cross_file/latest/index.html). diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml index e5ecfeb22232..d16aa5a868f8 100755 --- a/packages/image_picker/image_picker/pubspec.yaml +++ b/packages/image_picker/image_picker/pubspec.yaml @@ -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/master/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.2 +version: 0.8.2+1 environment: sdk: ">=2.12.0 <3.0.0" From 2726c6ab9bbdf12252cc719bb3b50ec786a45c60 Mon Sep 17 00:00:00 2001 From: yusufdag Date: Fri, 23 Jul 2021 10:51:21 +0200 Subject: [PATCH 3/6] Remove the old test target --- .../ImagePickerFromLimitedGalleryUITests.m | 179 ------------------ .../example/ios/RunnerUITestiOS14/Info.plist | 22 --- 2 files changed, 201 deletions(-) delete mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/ImagePickerFromLimitedGalleryUITests.m delete mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/Info.plist diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/ImagePickerFromLimitedGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/ImagePickerFromLimitedGalleryUITests.m deleted file mode 100644 index 86cad03d27cf..000000000000 --- a/packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/ImagePickerFromLimitedGalleryUITests.m +++ /dev/null @@ -1,179 +0,0 @@ -// 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 -#import - -const int kLimitedElementWaitingTime = 30; - -@interface ImagePickerFromLimitedGalleryUITests : XCTestCase - -@property(nonatomic, strong) XCUIApplication* app; - -@end - -@implementation ImagePickerFromLimitedGalleryUITests - -- (void)setUp { - [super setUp]; - // Delete the app if already exists, to test permission popups - - self.continueAfterFailure = NO; - self.app = [[XCUIApplication alloc] init]; - [self.app launch]; - __weak typeof(self) weakSelf = self; - [self addUIInterruptionMonitorWithDescription:@"Permission popups" - handler:^BOOL(XCUIElement* _Nonnull interruptingElement) { - if (@available(iOS 14, *)) { - XCUIElement* limitedPhotoPermission = - [interruptingElement.buttons elementBoundByIndex:0]; - if (![limitedPhotoPermission - waitForExistenceWithTimeout: - kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", - weakSelf.app.debugDescription); - XCTFail(@"Failed due to not able to find " - @"selectPhotos butt on with %@ seconds", - @(kLimitedElementWaitingTime)); - } - [limitedPhotoPermission tap]; - } else { - XCUIElement* ok = interruptingElement.buttons[@"OK"]; - if (![ok waitForExistenceWithTimeout: - kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", - weakSelf.app.debugDescription); - XCTFail(@"Failed due to not able to find ok button " - @"with %@ seconds", - @(kLimitedElementWaitingTime)); - } - [ok tap]; - } - return YES; - }]; -} - -- (void)tearDown { - [super tearDown]; - [self.app terminate]; -} - -- (void)testSelectingFromGallery { - [self launchPickerAndSelect]; -} - -- (void)launchPickerAndSelect { - // Find and tap on the pick from gallery button. - NSPredicate* predicateToFindImageFromGalleryButton = - [NSPredicate predicateWithFormat:@"label == %@", @"image_picker_example_from_gallery"]; - - XCUIElement* imageFromGalleryButton = - [self.app.otherElements elementMatchingPredicate:predicateToFindImageFromGalleryButton]; - if (![imageFromGalleryButton waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", - @(kLimitedElementWaitingTime)); - } - - XCTAssertTrue(imageFromGalleryButton.exists); - [imageFromGalleryButton tap]; - - // Find and tap on the `pick` button. - NSPredicate* predicateToFindPickButton = - [NSPredicate predicateWithFormat:@"label == %@", @"PICK"]; - - XCUIElement* pickButton = [self.app.buttons elementMatchingPredicate:predicateToFindPickButton]; - if (![pickButton waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTSkip(@"Pick button isn't found so the test is skipped..."); - } - - XCTAssertTrue(pickButton.exists); - [pickButton tap]; - - // There is a known bug where the permission popups interruption won't get fired until a tap - // happened in the app. We expect a permission popup so we do a tap here. - [self.app tap]; - - // Find an image and tap on it. (IOS 14 UI, images are showing directly) - XCUIElement* aImage; - if (@available(iOS 14, *)) { - aImage = [self.app.scrollViews.firstMatch.images elementBoundByIndex:1]; - } else { - XCUIElement* selectedPhotosCell = [self.app.cells - elementMatchingPredicate:[NSPredicate - predicateWithFormat:@"label == %@", @"Selected Photos"]]; - if (![selectedPhotosCell waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find \"Selected Photos\" cell with %@ seconds", - @(kLimitedElementWaitingTime)); - } - [selectedPhotosCell tap]; - aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView - identifier:@"PhotosGridView"] - .cells.firstMatch; - } - os_log_error(OS_LOG_DEFAULT, "description before picking image %@", self.app.debugDescription); - if (![aImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find an image with %@ seconds", - @(kLimitedElementWaitingTime)); - } - XCTAssertTrue(aImage.exists); - [aImage tap]; - - // Find and tap on the `Done` button. - NSPredicate* predicateToFindDoneButton = - [NSPredicate predicateWithFormat:@"label == %@", @"Done"]; - - XCUIElement* doneButton = [self.app.buttons elementMatchingPredicate:predicateToFindDoneButton]; - if (![doneButton waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTSkip(@"Permissions popup could not fired so the test is skipped..."); - } - - XCTAssertTrue(doneButton.exists); - [doneButton tap]; - - // Find an image and tap on it to have access to selected photos. - if (@available(iOS 14, *)) { - aImage = [self.app.scrollViews.firstMatch.images elementBoundByIndex:1]; - } else { - XCUIElement* selectedPhotosCell = [self.app.cells - elementMatchingPredicate:[NSPredicate - predicateWithFormat:@"label == %@", @"Selected Photos"]]; - if (![selectedPhotosCell waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find \"Selected Photos\" cell with %@ seconds", - @(kLimitedElementWaitingTime)); - } - [selectedPhotosCell tap]; - aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView - identifier:@"PhotosGridView"] - .cells.firstMatch; - } - os_log_error(OS_LOG_DEFAULT, "description before picking image %@", self.app.debugDescription); - if (![aImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find an image with %@ seconds", - @(kLimitedElementWaitingTime)); - } - XCTAssertTrue(aImage.exists); - [aImage tap]; - - // Find the picked image. - NSPredicate* predicateToFindPickedImage = - [NSPredicate predicateWithFormat:@"label == %@", @"image_picker_example_picked_image"]; - - XCUIElement* pickedImage = [self.app.images elementMatchingPredicate:predicateToFindPickedImage]; - if (![pickedImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find pickedImage with %@ seconds", - @(kLimitedElementWaitingTime)); - } - - XCTAssertTrue(pickedImage.exists); -} - -@end diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/Info.plist b/packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/Info.plist deleted file mode 100644 index 64d65ca49577..000000000000 --- a/packages/image_picker/image_picker/example/ios/RunnerUITestiOS14/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - From 1bb6ceaf8860bda601af135291fd712ad07af418 Mon Sep 17 00:00:00 2001 From: yusufdag Date: Fri, 23 Jul 2021 10:52:56 +0200 Subject: [PATCH 4/6] Update version and CHANGELOG --- packages/image_picker/image_picker/CHANGELOG.md | 2 +- packages/image_picker/image_picker/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md index 831eb8a059ec..e7048c371a95 100644 --- a/packages/image_picker/image_picker/CHANGELOG.md +++ b/packages/image_picker/image_picker/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.8.2+1 +## NEXT * Move `ImagePickerFromLimitedGalleryUITests` to `RunnerUITests` target. diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml index d16aa5a868f8..e5ecfeb22232 100755 --- a/packages/image_picker/image_picker/pubspec.yaml +++ b/packages/image_picker/image_picker/pubspec.yaml @@ -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/master/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.2+1 +version: 0.8.2 environment: sdk: ">=2.12.0 <3.0.0" From 031c4c2d0d7b63a9ac98efee810f112dd6daf9d9 Mon Sep 17 00:00:00 2001 From: yusufdag Date: Mon, 26 Jul 2021 07:57:16 +0200 Subject: [PATCH 5/6] Fix the fail message --- .../ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m index 52204afa89ed..093d54021220 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m @@ -33,7 +33,7 @@ - (void)setUp { os_log_error(OS_LOG_DEFAULT, "%@", weakSelf.app.debugDescription); XCTFail(@"Failed due to not able to find " - @"selectPhotos butt on with %@ seconds", + @"selectPhotos button with %@ seconds", @(kLimitedElementWaitingTime)); } [limitedPhotoPermission tap]; From 202bfcc87f0fbc7285fdc0620615867902aac837 Mon Sep 17 00:00:00 2001 From: yusufdag Date: Mon, 26 Jul 2021 07:57:50 +0200 Subject: [PATCH 6/6] Add comment to explain why it is filtered by OS --- .../ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m index 093d54021220..802a494b0f5e 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m @@ -47,6 +47,7 @@ - (void)tearDown { } - (void)testSelectingFromGallery { + // Test the `Select Photos` button which is available after iOS 14. if (@available(iOS 14, *)) { [self launchPickerAndSelect]; } else {