From e2cd7c27e544187b313b75ce0b4c49cafd3d9388 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 10 Dec 2020 09:51:28 -0800 Subject: [PATCH 1/4] fix image picker test --- .../image_picker/image_picker/CHANGELOG.md | 6 +++ .../ImagePickerFromGalleryUITests.m | 38 ++++++++++++++----- .../image_picker/image_picker/pubspec.yaml | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md index 26e8b100cd20..970ddf1ed7ed 100644 --- a/packages/image_picker/image_picker/CHANGELOG.md +++ b/packages/image_picker/image_picker/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.6.7+15 + +* Fix element type in XCUITests to look for staticText type when searching for texts. + * See https://github.com/flutter/flutter/issues/71927 +* Minor update in XCUITests to search for different elements on iOS 14 and above. + ## 0.6.7+14 * Set up XCUITests. 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 1ba8457c9709..5025dababda0 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -21,18 +21,27 @@ - (void)setUp { 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* ok = interruptingElement.buttons[@"OK"]; - if (ok.exists) { - [ok tap]; - } - // iOS 14. - XCUIElement* allPhotoPermission = - interruptingElement - .buttons[@"Allow Access to All Photos"]; - if (allPhotoPermission.exists) { + if (@available(iOS 14, *)) { + XCUIElement* allPhotoPermission = + interruptingElement + .buttons[@"Allow Access to All Photos"]; + if (![allPhotoPermission waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find allPhotoPermission button with %@ seconds", + @(kElementWaitingTime)); + } [allPhotoPermission tap]; + } else { + XCUIElement* ok = interruptingElement.buttons[@"OK"]; + if (![ok waitForExistenceWithTimeout:kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); + XCTFail(@"Failed due to not able to find ok button with %@ seconds", + @(kElementWaitingTime)); + } + [ok tap]; } return YES; }]; @@ -92,10 +101,19 @@ - (void)launchPickerAndCancel { [cancelButton tap]; // Find the "not picked image text". - XCUIElement* imageNotPickedText = [self.app.otherElements + XCUIElement* imageNotPickedText = [self.app.staticTexts elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", @"You have not yet picked an image."]]; + if (![imageNotPickedText waitForExistenceWithTimeout:kElementWaitingTime]) { + // Before https://github.com/flutter/engine/pull/22811 the label's a11y type was otherElements. + // TODO(cyanglaz): Remove this after https://github.com/flutter/flutter/commit/057e8230743ec96f33b73948ccd6b80081e3615e rolled to stable + // https://github.com/flutter/flutter/issues/71927 + imageNotPickedText = [self.app.otherElements + elementMatchingPredicate:[NSPredicate + predicateWithFormat:@"label == %@", + @"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", diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml index 2dcd7c137b7d..226602a99403 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+14 +version: 0.6.7+15 flutter: plugin: From a1c13e669692601fb87bb6ad1bbcdca35586af7b Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 10 Dec 2020 09:54:04 -0800 Subject: [PATCH 2/4] format --- .../ImagePickerFromGalleryUITests.m | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 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 5025dababda0..9a42d360f328 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -28,17 +28,23 @@ - (void)setUp { XCUIElement* allPhotoPermission = interruptingElement .buttons[@"Allow Access to All Photos"]; - if (![allPhotoPermission waitForExistenceWithTimeout:kElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find allPhotoPermission button with %@ seconds", + if (![allPhotoPermission waitForExistenceWithTimeout: + kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", + self.app.debugDescription); + XCTFail(@"Failed due to not able to find " + @"allPhotoPermission button with %@ seconds", @(kElementWaitingTime)); } [allPhotoPermission tap]; } else { XCUIElement* ok = interruptingElement.buttons[@"OK"]; - if (![ok waitForExistenceWithTimeout:kElementWaitingTime]) { - os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription); - XCTFail(@"Failed due to not able to find ok button with %@ seconds", + if (![ok waitForExistenceWithTimeout: + kElementWaitingTime]) { + os_log_error(OS_LOG_DEFAULT, "%@", + self.app.debugDescription); + XCTFail(@"Failed due to not able to find ok button " + @"with %@ seconds", @(kElementWaitingTime)); } [ok tap]; @@ -107,8 +113,9 @@ - (void)launchPickerAndCancel { @"You have not yet picked an image."]]; if (![imageNotPickedText waitForExistenceWithTimeout:kElementWaitingTime]) { // Before https://github.com/flutter/engine/pull/22811 the label's a11y type was otherElements. - // TODO(cyanglaz): Remove this after https://github.com/flutter/flutter/commit/057e8230743ec96f33b73948ccd6b80081e3615e rolled to stable - // https://github.com/flutter/flutter/issues/71927 + // TODO(cyanglaz): Remove this after + // https://github.com/flutter/flutter/commit/057e8230743ec96f33b73948ccd6b80081e3615e rolled to + // stable https://github.com/flutter/flutter/issues/71927 imageNotPickedText = [self.app.otherElements elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@", From 4fbbcdccae80c102cd6c14e8b9f9195ab6cfbe25 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 10 Dec 2020 10:01:55 -0800 Subject: [PATCH 3/4] integration test --- packages/integration_test/CHANGELOG.md | 4 ++++ packages/integration_test/lib/common.dart | 4 ++-- packages/integration_test/pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/integration_test/CHANGELOG.md b/packages/integration_test/CHANGELOG.md index a46fd4eab8b2..dea41e3744f6 100644 --- a/packages/integration_test/CHANGELOG.md +++ b/packages/integration_test/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.3+1 + +* Remove usages of deprecated `List` constructor. + ## 0.9.3 * Update README to mention that only `testWidgets` is supported for declaring tests. diff --git a/packages/integration_test/lib/common.dart b/packages/integration_test/lib/common.dart index 53714a8e97ee..da93b3b51450 100644 --- a/packages/integration_test/lib/common.dart +++ b/packages/integration_test/lib/common.dart @@ -86,7 +86,7 @@ class Response { /// Create a list of Strings from [_failureDetails]. List _failureDetailsAsString() { - final List list = List(); + final List list = []; if (_failureDetails == null || _failureDetails.isEmpty) { return list; } @@ -100,7 +100,7 @@ class Response { /// Creates a [Failure] list using a json response. static List _failureDetailsFromJson(List list) { - final List failureList = List(); + final List failureList = []; list.forEach((s) { final String failure = s as String; failureList.add(Failure.fromJsonString(failure)); diff --git a/packages/integration_test/pubspec.yaml b/packages/integration_test/pubspec.yaml index 94839dbcbb9a..b56a2d3aebba 100644 --- a/packages/integration_test/pubspec.yaml +++ b/packages/integration_test/pubspec.yaml @@ -1,6 +1,6 @@ name: integration_test description: Runs tests that use the flutter_test API as integration tests. -version: 0.9.3 +version: 0.9.3+1 homepage: https://github.com/flutter/plugins/tree/master/packages/integration_test environment: From 9783a04156ffc096e20081b030341447fbbac77b Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 10 Dec 2020 10:34:16 -0800 Subject: [PATCH 4/4] fix format --- .../example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m | 3 ++- 1 file changed, 2 insertions(+), 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 9a42d360f328..74df795a3df3 100644 --- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m +++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m @@ -115,7 +115,8 @@ - (void)launchPickerAndCancel { // Before https://github.com/flutter/engine/pull/22811 the label's a11y type was otherElements. // TODO(cyanglaz): Remove this after // https://github.com/flutter/flutter/commit/057e8230743ec96f33b73948ccd6b80081e3615e rolled to - // stable https://github.com/flutter/flutter/issues/71927 + // stable. + // https://github.com/flutter/flutter/issues/71927 imageNotPickedText = [self.app.otherElements elementMatchingPredicate:[NSPredicate predicateWithFormat:@"label == %@",