Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[image_picker] Set up XCUITests #3254

Merged
merged 7 commits into from
Nov 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format
Chris Yang committed Nov 9, 2020
commit ca96ae1030bebae6d6e52b0e0a84d92004a9dd0f
Original file line number Diff line number Diff line change
@@ -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,15 +136,16 @@ - (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 {
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));
XCTFail(@"Failed due to not able to find \"All Photos\" cell with %@ seconds",
@(kElementWaitingTime));
}
[allPhotosCell tap];
aImage = [self.app.collectionViews elementMatchingType:XCUIElementTypeCollectionView