From b2bf3c848e2a7bdffcd3b9a3f4a940b449fb4985 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 6 Nov 2020 13:33:08 -0800 Subject: [PATCH 1/7] setup xcuitests --- .../image_picker/image_picker/CHANGELOG.md | 4 + .../ios/Runner.xcodeproj/project.pbxproj | 137 ++++++++++++++- .../ImagePickerFromGalleryUITests.m | 162 ++++++++++++++++++ .../example/ios/RunnerUITests/Info.plist | 22 +++ .../ios/RunnerUITests/RunnerUITestUtils.h | 17 ++ .../ios/RunnerUITests/RunnerUITestUtils.m | 25 +++ .../image_picker/example/lib/main.dart | 23 ++- .../image_picker/image_picker/pubspec.yaml | 2 +- 8 files changed, 380 insertions(+), 12 deletions(-) create mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m create mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITests/Info.plist create mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h create mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md index 0fb0ce46b4c5..26e8b100cd20 100644 --- a/packages/image_picker/image_picker/CHANGELOG.md +++ b/packages/image_picker/image_picker/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.7+14 + +* Set up XCUITests. + ## 0.6.7+13 * Update documentation of `getImage()` about HEIC images. 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 106d49cad0c7..8e59418736f8 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 @@ -13,6 +13,8 @@ 680049272280D79A006DD6AB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 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 */; }; + 6801C8422555E0A7009DAF8D /* RunnerUITestUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 6801C8412555E0A7009DAF8D /* RunnerUITestUtils.m */; }; 68B9AF72243E4B3F00927CE4 /* ImagePickerPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */; }; 68F4B464228B3AB500C25614 /* PhotoAssetUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; @@ -34,6 +36,13 @@ remoteGlobalIDString = 97C146ED1CF9000F007C117D; remoteInfo = Runner; }; + 6801C83B2555D726009DAF8D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -60,6 +69,11 @@ 680049352280F2B8006DD6AB /* pngImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pngImage.png; sourceTree = ""; }; 680049362280F2B8006DD6AB /* jpgImage.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = jpgImage.jpg; sourceTree = ""; }; 6801632E632668F4349764C9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 6801C8362555D726009DAF8D /* RunnerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromGalleryUITests.m; sourceTree = ""; }; + 6801C83A2555D726009DAF8D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6801C8402555E0A7009DAF8D /* RunnerUITestUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RunnerUITestUtils.h; sourceTree = ""; }; + 6801C8412555E0A7009DAF8D /* RunnerUITestUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RunnerUITestUtils.m; sourceTree = ""; }; 68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImagePickerPluginTests.m; path = ../../../ios/Tests/ImagePickerPluginTests.m; sourceTree = ""; }; 68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PhotoAssetUtilTests.m; path = ../../../ios/Tests/PhotoAssetUtilTests.m; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -88,6 +102,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6801C8332555D726009DAF8D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EB1CF9000F007C117D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -123,6 +144,17 @@ path = TestImages; sourceTree = ""; }; + 6801C8372555D726009DAF8D /* RunnerUITests */ = { + isa = PBXGroup; + children = ( + 6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */, + 6801C83A2555D726009DAF8D /* Info.plist */, + 6801C8402555E0A7009DAF8D /* RunnerUITestUtils.h */, + 6801C8412555E0A7009DAF8D /* RunnerUITestUtils.m */, + ); + path = RunnerUITests; + sourceTree = ""; + }; 840012C8B5EDBCF56B0E4AC1 /* Pods */ = { isa = PBXGroup; children = ( @@ -150,6 +182,7 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 680049182280D368006DD6AB /* image_picker_exampleTests */, + 6801C8372555D726009DAF8D /* RunnerUITests */, 97C146EF1CF9000F007C117D /* Products */, 840012C8B5EDBCF56B0E4AC1 /* Pods */, CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, @@ -161,6 +194,7 @@ children = ( 97C146EE1CF9000F007C117D /* Runner.app */, 680049172280D368006DD6AB /* image_picker_exampleTests.xctest */, + 6801C8362555D726009DAF8D /* RunnerUITests.xctest */, ); name = Products; sourceTree = ""; @@ -218,6 +252,24 @@ productReference = 680049172280D368006DD6AB /* image_picker_exampleTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 6801C8352555D726009DAF8D /* RunnerUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6801C83F2555D726009DAF8D /* Build configuration list for PBXNativeTarget "RunnerUITests" */; + buildPhases = ( + 6801C8322555D726009DAF8D /* Sources */, + 6801C8332555D726009DAF8D /* Frameworks */, + 6801C8342555D726009DAF8D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 6801C83C2555D726009DAF8D /* PBXTargetDependency */, + ); + name = RunnerUITests; + productName = RunnerUITests; + productReference = 6801C8362555D726009DAF8D /* RunnerUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; 97C146ED1CF9000F007C117D /* Runner */ = { isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; @@ -255,6 +307,11 @@ ProvisioningStyle = Automatic; TestTargetID = 97C146ED1CF9000F007C117D; }; + 6801C8352555D726009DAF8D = { + CreatedOnToolsVersion = 11.7; + ProvisioningStyle = Automatic; + TestTargetID = 97C146ED1CF9000F007C117D; + }; 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; SystemCapabilities = { @@ -280,6 +337,7 @@ targets = ( 97C146ED1CF9000F007C117D /* Runner */, 680049162280D368006DD6AB /* image_picker_exampleTests */, + 6801C8352555D726009DAF8D /* RunnerUITests */, ); }; /* End PBXProject section */ @@ -296,6 +354,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6801C8342555D726009DAF8D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EC1CF9000F007C117D /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -389,6 +454,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6801C8322555D726009DAF8D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6801C8392555D726009DAF8D /* ImagePickerFromGalleryUITests.m in Sources */, + 6801C8422555E0A7009DAF8D /* RunnerUITestUtils.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EA1CF9000F007C117D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -407,6 +481,11 @@ target = 97C146ED1CF9000F007C117D /* Runner */; targetProxy = 6800491C2280D368006DD6AB /* PBXContainerItemProxy */; }; + 6801C83C2555D726009DAF8D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 6801C83B2555D726009DAF8D /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -480,9 +559,55 @@ }; name = Release; }; + 6801C83D2555D726009DAF8D /* 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_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = RunnerUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + 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.google.RunnerUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Runner; + }; + name = Debug; + }; + 6801C83E2555D726009DAF8D /* 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_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = RunnerUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Runner; + }; + name = Release; + }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -539,7 +664,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -644,6 +768,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 6801C83F2555D726009DAF8D /* Build configuration list for PBXNativeTarget "RunnerUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6801C83D2555D726009DAF8D /* Debug */, + 6801C83E2555D726009DAF8D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m new file mode 100644 index 000000000000..b55a6a5a8ce5 --- /dev/null +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -0,0 +1,162 @@ +// Copyright 2019 The Chromium 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 "RunnerUITestUtils.h" + +@interface ImagePickerFromGalleryUITests : XCTestCase + +@property (nonatomic, strong) XCUIApplication *app; + +@end + +@implementation ImagePickerFromGalleryUITests + +- (void)setUp { + // Delete the app if already exists, to test permission popups + + self.continueAfterFailure = NO; + self.app = [[XCUIApplication alloc] init]; + [self.app launch]; + [self addUIInterruptionMonitorWithDescription:@"Permission popups" handler:^BOOL(XCUIElement * _Nonnull interruptingElement) { + XCUIElement *ok = interruptingElement.buttons[@"OK"]; + if (ok.exists) { + [ok tap]; + } + // iOS 14. + XCUIElement *allPhotoPermission = interruptingElement.buttons[@"Allow Access to All Photos"]; + if (allPhotoPermission.exists) { + [allPhotoPermission tap]; + } + return YES; + }]; +} + +- (void)testPickingFromGallery { + [self launchPickerAndCancel]; + [self launchPickerAndPick]; +} + +- (void)launchPickerAndCancel { + // 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:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(30)); + } + + 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:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find pick button with %@ seconds", @(30)); + } + + 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 and tap on the `Cancel` button. + NSPredicate* predicateToFindCancelButton = + [NSPredicate predicateWithFormat:@"label == %@", @"Cancel"]; + + XCUIElement* cancelButton = [self.app.buttons elementMatchingPredicate:predicateToFindCancelButton]; + if (![cancelButton waitForExistenceWithTimeout:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find Cancel button with %@ seconds", @(30)); + } + + XCTAssertTrue(cancelButton.exists); + [cancelButton tap]; + + // Find the "not picked image text". + XCUIElement* imageNotPickedText = [self.app.otherElements + elementMatchingPredicate:[NSPredicate + predicateWithFormat:@"label == %@", + @"You have not yet picked an image."]]; + if (![imageNotPickedText waitForExistenceWithTimeout:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find imageNotPickedText with %@ seconds", @(30)); + } + + XCTAssertTrue(imageNotPickedText.exists); +} + +- (void)launchPickerAndPick { + + // 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:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(30)); + } + + 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:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find pick button with %@ seconds", @(30)); + } + + XCTAssertTrue(pickButton.exists); + [pickButton tap]; + + // Find an image and tap on it. (IOS 14 UI, images are showing direclty) + XCUIElement* aImage = self.app.scrollViews.firstMatch.images.firstMatch; + XCUIElement* allPhotosCell = [self.app.cells elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"All Photos"]]; + XCUIElement *firstExist = [RunnerUITestUtils waitForFirstExistence:@[aImage, allPhotosCell] timeout:30]; + if (firstExist) { + // For iOS 14 and below, we need to tap on the "All Photos" cell to get to the images page. + // The image a11y info is also different. + if (allPhotosCell.exists) { + [allPhotosCell tap]; + aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView identifier:@"PhotosGridView"].cells.firstMatch; + } + if (![aImage waitForExistenceWithTimeout:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find an image with %@ seconds", @(30)); + } + XCTAssertTrue(aImage.exists); + [aImage tap]; + } else { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find an image with %@ seconds", @(30)); + } + + // Find the picked image. + NSPredicate* predicateToFindPickedImage = + [NSPredicate predicateWithFormat:@"label == %@", @"image_picker_example_picked_image"]; + + XCUIElement* pickedImage = [self.app.images elementMatchingPredicate:predicateToFindPickedImage]; + if (![pickedImage waitForExistenceWithTimeout:30]) { + NSLog(@"%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find pickedImage with %@ seconds", @(30)); + } + + XCTAssertTrue(pickedImage.exists); +} + +@end diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/Info.plist b/packages/image_picker/image_picker/example/ios/RunnerUITests/Info.plist new file mode 100644 index 000000000000..64d65ca49577 --- /dev/null +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + 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 + + diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h new file mode 100644 index 000000000000..1ab8fefe8ca0 --- /dev/null +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h @@ -0,0 +1,17 @@ +// Copyright 2019 The Chromium 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 + +NS_ASSUME_NONNULL_BEGIN + +@interface RunnerUITestUtils : NSObject + +// Wait until finding the first element in `elements`, return that element if found. ++ (nullable XCUIElement *)waitForFirstExistence:(NSArray *)elements timeout:(NSTimeInterval)timeout; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m new file mode 100644 index 000000000000..2b7a865e7ea9 --- /dev/null +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m @@ -0,0 +1,25 @@ +// Copyright 2019 The Chromium 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 "RunnerUITestUtils.h" + +@implementation RunnerUITestUtils + ++ (XCUIElement *)waitForFirstExistence:(NSArray *)elements timeout:(NSTimeInterval)timeout { + if (elements.count == 0) { + return nil; + } + NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate]; + while ([NSDate timeIntervalSinceReferenceDate] - startTime < timeout) { + for (XCUIElement *element in elements) { + if (element.exists) { + return element; + } + } + } + return nil; +} + +@end diff --git a/packages/image_picker/image_picker/example/lib/main.dart b/packages/image_picker/image_picker/example/lib/main.dart index ece8c45d9c8e..3047ac13f235 100755 --- a/packages/image_picker/image_picker/example/lib/main.dart +++ b/packages/image_picker/image_picker/example/lib/main.dart @@ -156,7 +156,9 @@ class _MyHomePageState extends State { // See https://pub.dev/packages/image_picker#getting-ready-for-the-web-platform return Image.network(_imageFile.path); } else { - return Image.file(File(_imageFile.path)); + return Semantics( + child: Image.file(File(_imageFile.path)), + label: 'image_picker_example_picked_image'); } } else if (_pickImageError != null) { return Text( @@ -231,14 +233,17 @@ class _MyHomePageState extends State { floatingActionButton: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - FloatingActionButton( - onPressed: () { - isVideo = false; - _onImageButtonPressed(ImageSource.gallery, context: context); - }, - heroTag: 'image0', - tooltip: 'Pick Image from gallery', - child: const Icon(Icons.photo_library), + Semantics( + label: 'image_picker_example_from_gallery', + child: FloatingActionButton( + onPressed: () { + isVideo = false; + _onImageButtonPressed(ImageSource.gallery, context: context); + }, + heroTag: 'image0', + tooltip: 'Pick Image from gallery', + child: const Icon(Icons.photo_library), + ), ), Padding( padding: const EdgeInsets.only(top: 16.0), diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml index 711d2db1ba0f..2dcd7c137b7d 100755 --- a/packages/image_picker/image_picker/pubspec.yaml +++ b/packages/image_picker/image_picker/pubspec.yaml @@ -2,7 +2,7 @@ name: image_picker description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker -version: 0.6.7+13 +version: 0.6.7+14 flutter: plugin: From 480e86c55de621249fcae3e7376b06c70efc7a3b Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 6 Nov 2020 13:33:58 -0800 Subject: [PATCH 2/7] unskip image picker --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 8c632a076522..685dacae8f17 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -163,7 +163,7 @@ task: - name: build-ipas+drive-examples env: PATH: $PATH:/usr/local/bin - PLUGINS_TO_SKIP_XCTESTS: "battery/battery,camera,connectivity/connectivity,device_info/device_info,espresso,google_maps_flutter/google_maps_flutter,google_sign_in/google_sign_in,image_picker/image_picker,in_app_purchase,integration_test,ios_platform_images,local_auth,package_info,path_provider/path_provider,quick_actions,sensors,shared_preferences/shared_preferences,url_launcher/url_launcher,video_player/video_player,webview_flutter,wifi_info_flutter/wifi_info_flutter" + PLUGINS_TO_SKIP_XCTESTS: "battery/battery,camera,connectivity/connectivity,device_info/device_info,espresso,google_maps_flutter/google_maps_flutter,google_sign_in/google_sign_in,in_app_purchase,integration_test,ios_platform_images,local_auth,package_info,path_provider/path_provider,quick_actions,sensors,shared_preferences/shared_preferences,url_launcher/url_launcher,video_player/video_player,webview_flutter,wifi_info_flutter/wifi_info_flutter" matrix: PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4" PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4" From f0ab4d5ed1fc7b8049e815f58d93b3a9a0356c65 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 6 Nov 2020 15:01:39 -0800 Subject: [PATCH 3/7] format --- .../ImagePickerFromGalleryUITests.m | 50 +++++++++++-------- .../ios/RunnerUITests/RunnerUITestUtils.m | 1 - 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m index b55a6a5a8ce5..d1db779bd245 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -7,7 +7,7 @@ @interface ImagePickerFromGalleryUITests : XCTestCase -@property (nonatomic, strong) XCUIApplication *app; +@property(nonatomic, strong) XCUIApplication* app; @end @@ -18,19 +18,22 @@ - (void)setUp { self.continueAfterFailure = NO; self.app = [[XCUIApplication alloc] init]; - [self.app launch]; - [self addUIInterruptionMonitorWithDescription:@"Permission popups" handler:^BOOL(XCUIElement * _Nonnull interruptingElement) { - XCUIElement *ok = interruptingElement.buttons[@"OK"]; - if (ok.exists) { - [ok tap]; - } - // iOS 14. - XCUIElement *allPhotoPermission = interruptingElement.buttons[@"Allow Access to All Photos"]; - if (allPhotoPermission.exists) { - [allPhotoPermission tap]; - } - return YES; - }]; + [self.app launch]; + [self addUIInterruptionMonitorWithDescription:@"Permission popups" + handler:^BOOL(XCUIElement* _Nonnull interruptingElement) { + XCUIElement* ok = interruptingElement.buttons[@"OK"]; + if (ok.exists) { + [ok tap]; + } + // iOS 14. + XCUIElement* allPhotoPermission = + interruptingElement + .buttons[@"Allow Access to All Photos"]; + if (allPhotoPermission.exists) { + [allPhotoPermission tap]; + } + return YES; + }]; } - (void)testPickingFromGallery { @@ -66,14 +69,16 @@ - (void)launchPickerAndCancel { 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. + // 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 and tap on the `Cancel` button. NSPredicate* predicateToFindCancelButton = [NSPredicate predicateWithFormat:@"label == %@", @"Cancel"]; - XCUIElement* cancelButton = [self.app.buttons elementMatchingPredicate:predicateToFindCancelButton]; + XCUIElement* cancelButton = + [self.app.buttons elementMatchingPredicate:predicateToFindCancelButton]; if (![cancelButton waitForExistenceWithTimeout:30]) { NSLog(@"%@", self.app.debugDescription); XCTFail(@"Failed due to not able to find Cancel button with %@ seconds", @(30)); @@ -96,13 +101,12 @@ - (void)launchPickerAndCancel { } - (void)launchPickerAndPick { - // 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]; + [self.app.otherElements elementMatchingPredicate:predicateToFindImageFromGalleryButton]; if (![imageFromGalleryButton waitForExistenceWithTimeout:30]) { NSLog(@"%@", self.app.debugDescription); XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(30)); @@ -126,14 +130,18 @@ - (void)launchPickerAndPick { // Find an image and tap on it. (IOS 14 UI, images are showing direclty) XCUIElement* aImage = self.app.scrollViews.firstMatch.images.firstMatch; - XCUIElement* allPhotosCell = [self.app.cells elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"All Photos"]]; - XCUIElement *firstExist = [RunnerUITestUtils waitForFirstExistence:@[aImage, allPhotosCell] timeout:30]; + XCUIElement* allPhotosCell = [self.app.cells + elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"All Photos"]]; + XCUIElement* firstExist = [RunnerUITestUtils waitForFirstExistence:@[ aImage, allPhotosCell ] + timeout:30]; if (firstExist) { // For iOS 14 and below, we need to tap on the "All Photos" cell to get to the images page. // The image a11y info is also different. if (allPhotosCell.exists) { [allPhotosCell tap]; - aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView identifier:@"PhotosGridView"].cells.firstMatch; + aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView + identifier:@"PhotosGridView"] + .cells.firstMatch; } if (![aImage waitForExistenceWithTimeout:30]) { NSLog(@"%@", self.app.debugDescription); diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m index 2b7a865e7ea9..98c029ddd81e 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - #import "RunnerUITestUtils.h" @implementation RunnerUITestUtils From 6dfc47134c29ca90c3a525480e4cd6357dabc819 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 9 Nov 2020 08:56:43 -0800 Subject: [PATCH 4/7] reviews --- .../ImagePickerFromGalleryUITests.m | 88 +++++++++---------- .../ios/RunnerUITests/RunnerUITestUtils.h | 17 ---- .../ios/RunnerUITests/RunnerUITestUtils.m | 24 ----- 3 files changed, 44 insertions(+), 85 deletions(-) delete mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h delete mode 100644 packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m index d1db779bd245..3d3a5e02784c 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -3,8 +3,11 @@ // found in the LICENSE file. #import +#import #import "RunnerUITestUtils.h" +const int kElementWaitingTime = 30; + @interface ImagePickerFromGalleryUITests : XCTestCase @property(nonatomic, strong) XCUIApplication* app; @@ -48,9 +51,9 @@ - (void)launchPickerAndCancel { XCUIElement* imageFromGalleryButton = [self.app.otherElements elementMatchingPredicate:predicateToFindImageFromGalleryButton]; - if (![imageFromGalleryButton waitForExistenceWithTimeout:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(30)); + if (![imageFromGalleryButton waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(kElementWaitingTime)); } XCTAssertTrue(imageFromGalleryButton.exists); @@ -61,9 +64,9 @@ - (void)launchPickerAndCancel { [NSPredicate predicateWithFormat:@"label == %@", @"PICK"]; XCUIElement* pickButton = [self.app.buttons elementMatchingPredicate:predicateToFindPickButton]; - if (![pickButton waitForExistenceWithTimeout:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find pick button with %@ seconds", @(30)); + if (![pickButton waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find pick button with %@ seconds", @(kElementWaitingTime)); } XCTAssertTrue(pickButton.exists); @@ -79,9 +82,9 @@ - (void)launchPickerAndCancel { XCUIElement* cancelButton = [self.app.buttons elementMatchingPredicate:predicateToFindCancelButton]; - if (![cancelButton waitForExistenceWithTimeout:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find Cancel button with %@ seconds", @(30)); + if (![cancelButton waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find Cancel button with %@ seconds", @(kElementWaitingTime)); } XCTAssertTrue(cancelButton.exists); @@ -92,9 +95,9 @@ - (void)launchPickerAndCancel { elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"You have not yet picked an image."]]; - if (![imageNotPickedText waitForExistenceWithTimeout:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find imageNotPickedText with %@ seconds", @(30)); + if (![imageNotPickedText waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find imageNotPickedText with %@ seconds", @(kElementWaitingTime)); } XCTAssertTrue(imageNotPickedText.exists); @@ -107,9 +110,9 @@ - (void)launchPickerAndPick { XCUIElement* imageFromGalleryButton = [self.app.otherElements elementMatchingPredicate:predicateToFindImageFromGalleryButton]; - if (![imageFromGalleryButton waitForExistenceWithTimeout:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(30)); + if (![imageFromGalleryButton waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(kElementWaitingTime)); } XCTAssertTrue(imageFromGalleryButton.exists); @@ -120,48 +123,45 @@ - (void)launchPickerAndPick { [NSPredicate predicateWithFormat:@"label == %@", @"PICK"]; XCUIElement* pickButton = [self.app.buttons elementMatchingPredicate:predicateToFindPickButton]; - if (![pickButton waitForExistenceWithTimeout:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find pick button with %@ seconds", @(30)); + if (![pickButton waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find pick button with %@ seconds", @(kElementWaitingTime)); } XCTAssertTrue(pickButton.exists); [pickButton tap]; - // Find an image and tap on it. (IOS 14 UI, images are showing direclty) - XCUIElement* aImage = self.app.scrollViews.firstMatch.images.firstMatch; - XCUIElement* allPhotosCell = [self.app.cells - elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"All Photos"]]; - XCUIElement* firstExist = [RunnerUITestUtils waitForFirstExistence:@[ aImage, allPhotosCell ] - timeout:30]; - if (firstExist) { - // For iOS 14 and below, we need to tap on the "All Photos" cell to get to the images page. - // The image a11y info is also different. - if (allPhotosCell.exists) { - [allPhotosCell tap]; - aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView - identifier:@"PhotosGridView"] - .cells.firstMatch; - } - if (![aImage waitForExistenceWithTimeout:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find an image with %@ seconds", @(30)); - } - XCTAssertTrue(aImage.exists); - [aImage 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.firstMatch; } else { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find an image with %@ seconds", @(30)); + XCUIElement* allPhotosCell = [self.app.cells + elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"All Photos"]]; + if (![allPhotosCell waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find \"All Photos\" cell with %@ seconds", @(kElementWaitingTime)); + } + [allPhotosCell tap]; + aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView + identifier:@"PhotosGridView"] + .cells.firstMatch; + } + if (![aImage waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find an image with %@ seconds", @(kElementWaitingTime)); } + 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:30]) { - NSLog(@"%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find pickedImage with %@ seconds", @(30)); + if (![pickedImage waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find pickedImage with %@ seconds", @(kElementWaitingTime)); } XCTAssertTrue(pickedImage.exists); diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h deleted file mode 100644 index 1ab8fefe8ca0..000000000000 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2019 The Chromium 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 - -NS_ASSUME_NONNULL_BEGIN - -@interface RunnerUITestUtils : NSObject - -// Wait until finding the first element in `elements`, return that element if found. -+ (nullable XCUIElement *)waitForFirstExistence:(NSArray *)elements timeout:(NSTimeInterval)timeout; - -@end - -NS_ASSUME_NONNULL_END diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m deleted file mode 100644 index 98c029ddd81e..000000000000 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/RunnerUITestUtils.m +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 The Chromium 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 "RunnerUITestUtils.h" - -@implementation RunnerUITestUtils - -+ (XCUIElement *)waitForFirstExistence:(NSArray *)elements timeout:(NSTimeInterval)timeout { - if (elements.count == 0) { - return nil; - } - NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate]; - while ([NSDate timeIntervalSinceReferenceDate] - startTime < timeout) { - for (XCUIElement *element in elements) { - if (element.exists) { - return element; - } - } - } - return nil; -} - -@end From ca96ae1030bebae6d6e52b0e0a84d92004a9dd0f Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 9 Nov 2020 08:57:10 -0800 Subject: [PATCH 5/7] format --- .../ImagePickerFromGalleryUITests.m | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m index 3d3a5e02784c..80518638710e 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -53,7 +53,8 @@ - (void)launchPickerAndCancel { [self.app.otherElements elementMatchingPredicate:predicateToFindImageFromGalleryButton]; if (![imageFromGalleryButton waitForExistenceWithTimeout:kElementWaitingTime]) { os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(kElementWaitingTime)); + XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", + @(kElementWaitingTime)); } XCTAssertTrue(imageFromGalleryButton.exists); @@ -84,7 +85,8 @@ - (void)launchPickerAndCancel { [self.app.buttons elementMatchingPredicate:predicateToFindCancelButton]; if (![cancelButton waitForExistenceWithTimeout:kElementWaitingTime]) { os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find Cancel button with %@ seconds", @(kElementWaitingTime)); + XCTFail(@"Failed due to not able to find Cancel button with %@ seconds", + @(kElementWaitingTime)); } XCTAssertTrue(cancelButton.exists); @@ -97,7 +99,8 @@ - (void)launchPickerAndCancel { @"You have not yet picked an image."]]; if (![imageNotPickedText waitForExistenceWithTimeout:kElementWaitingTime]) { os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find imageNotPickedText with %@ seconds", @(kElementWaitingTime)); + XCTFail(@"Failed due to not able to find imageNotPickedText with %@ seconds", + @(kElementWaitingTime)); } XCTAssertTrue(imageNotPickedText.exists); @@ -112,7 +115,8 @@ - (void)launchPickerAndPick { [self.app.otherElements elementMatchingPredicate:predicateToFindImageFromGalleryButton]; if (![imageFromGalleryButton waitForExistenceWithTimeout:kElementWaitingTime]) { os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", @(kElementWaitingTime)); + XCTFail(@"Failed due to not able to find image from gallery button with %@ seconds", + @(kElementWaitingTime)); } XCTAssertTrue(imageFromGalleryButton.exists); @@ -132,7 +136,7 @@ - (void)launchPickerAndPick { [pickButton tap]; // Find an image and tap on it. (IOS 14 UI, images are showing directly) - XCUIElement *aImage; + XCUIElement* aImage; if (@available(iOS 14, *)) { aImage = self.app.scrollViews.firstMatch.images.firstMatch; } else { @@ -140,7 +144,8 @@ - (void)launchPickerAndPick { elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"All Photos"]]; if (![allPhotosCell waitForExistenceWithTimeout:kElementWaitingTime]) { os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find \"All Photos\" cell with %@ seconds", @(kElementWaitingTime)); + XCTFail(@"Failed due to not able to find \"All Photos\" cell with %@ seconds", + @(kElementWaitingTime)); } [allPhotosCell tap]; aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView From 616911bfad216526e1b9f34f7cc95f5f60040aef Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 9 Nov 2020 08:57:41 -0800 Subject: [PATCH 6/7] remove deleted file from xcodeproj --- .../example/ios/Runner.xcodeproj/project.pbxproj | 6 ------ 1 file changed, 6 deletions(-) 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 8e59418736f8..be3d55f406bf 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 @@ -14,7 +14,6 @@ 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 */; }; - 6801C8422555E0A7009DAF8D /* RunnerUITestUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 6801C8412555E0A7009DAF8D /* RunnerUITestUtils.m */; }; 68B9AF72243E4B3F00927CE4 /* ImagePickerPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */; }; 68F4B464228B3AB500C25614 /* PhotoAssetUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; @@ -72,8 +71,6 @@ 6801C8362555D726009DAF8D /* RunnerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromGalleryUITests.m; sourceTree = ""; }; 6801C83A2555D726009DAF8D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 6801C8402555E0A7009DAF8D /* RunnerUITestUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RunnerUITestUtils.h; sourceTree = ""; }; - 6801C8412555E0A7009DAF8D /* RunnerUITestUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RunnerUITestUtils.m; sourceTree = ""; }; 68B9AF71243E4B3F00927CE4 /* ImagePickerPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImagePickerPluginTests.m; path = ../../../ios/Tests/ImagePickerPluginTests.m; sourceTree = ""; }; 68F4B463228B3AB500C25614 /* PhotoAssetUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PhotoAssetUtilTests.m; path = ../../../ios/Tests/PhotoAssetUtilTests.m; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -149,8 +146,6 @@ children = ( 6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */, 6801C83A2555D726009DAF8D /* Info.plist */, - 6801C8402555E0A7009DAF8D /* RunnerUITestUtils.h */, - 6801C8412555E0A7009DAF8D /* RunnerUITestUtils.m */, ); path = RunnerUITests; sourceTree = ""; @@ -459,7 +454,6 @@ buildActionMask = 2147483647; files = ( 6801C8392555D726009DAF8D /* ImagePickerFromGalleryUITests.m in Sources */, - 6801C8422555E0A7009DAF8D /* RunnerUITestUtils.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 1342b54c1df579610c791e554bc7f35ed8de94e3 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Mon, 9 Nov 2020 09:37:57 -0800 Subject: [PATCH 7/7] remove unused imports --- .../example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m index 80518638710e..1ba8457c9709 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -4,7 +4,6 @@ #import #import -#import "RunnerUITestUtils.h" const int kElementWaitingTime = 30;