Skip to content

Commit

Permalink
chore: remove old iOS/Xcode related test code and errors (#890)
Browse files Browse the repository at this point in the history
* chore: remove old Xcode 12 and below stuff

* keep comment

* cleanup more

* remove included ones

* Update XCUIElementFBFindTests.m
  • Loading branch information
KazuCocoa authored Apr 20, 2024
1 parent 99c01bb commit 2fd0dea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 66 deletions.
8 changes: 0 additions & 8 deletions WebDriverAgentLib/Commands/FBElementCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,6 @@ + (NSArray *)routes
{
FBElementCache *elementCache = request.session.elementCache;
XCUIElement *element = [self targetFromRequest:request];
if (![element respondsToSelector:@selector(pressForDuration:thenDragToElement:withVelocity:thenHoldForDuration:)]) {
return FBResponseWithStatus([FBCommandStatus unsupportedOperationErrorWithMessage:@"This method is only supported in Xcode 12 and above"
traceback:nil]);
}
[element pressForDuration:[request.arguments[@"pressDuration"] doubleValue]
thenDragToElement:[elementCache elementForUUID:(NSString *)request.arguments[@"toElement"]]
withVelocity:[request.arguments[@"velocity"] doubleValue]
Expand All @@ -370,10 +366,6 @@ + (NSArray *)routes
(CGFloat)[request.arguments[@"fromY"] doubleValue]);
XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset
element:session.activeApplication];
if (![startCoordinate respondsToSelector:@selector(pressForDuration:thenDragToCoordinate:withVelocity:thenHoldForDuration:)]) {
return FBResponseWithStatus([FBCommandStatus unsupportedOperationErrorWithMessage:@"This method is only supported in Xcode 12 and above"
traceback:nil]);
}
CGVector endOffset = CGVectorMake((CGFloat)[request.arguments[@"toX"] doubleValue],
(CGFloat)[request.arguments[@"toY"] doubleValue]);
XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithOffset:endOffset
Expand Down
11 changes: 3 additions & 8 deletions WebDriverAgentTests/IntegrationTests/FBElementAttributeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,9 @@ - (void)testContainerAccessibilityAttributes
XCUIElement *inaccessibleButtonElement = self.testedApplication.buttons[@"not_accessible"];
XCTAssertTrue(inaccessibleButtonElement.exists);
XCTAssertFalse(inaccessibleButtonElement.fb_isAccessibilityElement);
if (@available(iOS 13.0, *)) {
// FIXME: Xcode 11 environment returns false even if iOS 12
// We must fix here to XCTAssertTrue if Xcode version will return the value properly
XCTAssertFalse(inaccessibleButtonElement.isWDAccessibilityContainer);
} else {
// Xcode 10 and the below works fine
XCTAssertTrue(inaccessibleButtonElement.isWDAccessibilityContainer);
}
// FIXME: Xcode 11 environment returns false even if iOS 12
// We must fix here to XCTAssertTrue if Xcode version will return the value properly
XCTAssertFalse(inaccessibleButtonElement.isWDAccessibilityContainer);
}

- (void)testIgnoredAccessibilityAttributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ - (void)disabled_testIconsFromSearchDashboard

- (void)testTableViewCells
{
if (SYSTEM_VERSION_GREATER_THAN(@"12.0")) {
// The test is flacky on iOS 12+ in Travis env
return;
}

[self launchApplication];
[self goToScrollPageWithCells:YES];
for (int i = 0 ; i < 10 ; i++) {
Expand Down
60 changes: 15 additions & 45 deletions WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ - (void)testDescendantsWithIdentifier
{
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingIdentifier:@"Alerts"
shouldReturnAfterFirstMatch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand Down Expand Up @@ -162,10 +159,7 @@ - (void)testDescendantsWithComplexXPathQuery
{
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingXPathQuery:@"//*[@label='Scrolling']/preceding::*[boolean(string(@label))]"
shouldReturnAfterFirstMatch:NO];
int snapshotsCount = 3;
if (@available(iOS 13.0, *)) {
snapshotsCount = 6;
}
int snapshotsCount = 6;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
}

Expand Down Expand Up @@ -198,10 +192,7 @@ - (void)testDescendantsWithPredicateString
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"label = 'Alerts'"];
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingPredicate:predicate
shouldReturnAfterFirstMatch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand Down Expand Up @@ -243,10 +234,7 @@ - (void)testDescendantsWithPropertyStrict
partialSearch:NO];
XCTAssertEqual(matchingSnapshots.count, 0);
matchingSnapshots = [self.testedView fb_descendantsMatchingProperty:@"label" value:@"Alerts" partialSearch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand All @@ -259,10 +247,7 @@ - (void)testGlobalWithPropertyStrict
partialSearch:NO];
XCTAssertEqual(matchingSnapshots.count, 0);
matchingSnapshots = [self.testedApplication fb_descendantsMatchingProperty:@"label" value:@"Alerts" partialSearch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand All @@ -273,10 +258,7 @@ - (void)testDescendantsWithPropertyPartial
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingProperty:@"label"
value:@"Alerts"
partialSearch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand All @@ -297,19 +279,13 @@ - (void)testDescendantsWithClassChain
- (void)testDescendantsWithClassChainWithIndex
{
NSArray<XCUIElement *> *matchingSnapshots;
NSString *queryString = @"XCUIElementTypeWindow/*/*[2]/*/*/XCUIElementTypeButton";
if (@available(iOS 13.0, *)) {
// iPhone
queryString = @"XCUIElementTypeWindow/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
if (matchingSnapshots.count == 0) {
// iPad
queryString = @"XCUIElementTypeWindow/*/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
}
} else {
// iPhone
NSString *queryString = @"XCUIElementTypeWindow/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
if (matchingSnapshots.count == 0) {
// iPad
queryString = @"XCUIElementTypeWindow/*/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
}
Expand Down Expand Up @@ -444,21 +420,15 @@ - (void)setUp

- (void)testNestedQueryWithClassChain
{
NSString *queryString = @"XCUIElementTypeOther";
if (@available(iOS 13.0, *)) {
queryString = @"XCUIElementTypePicker";
}
NSString *queryString = @"XCUIElementTypePicker";
FBAssertWaitTillBecomesTrue(self.testedApplication.buttons[@"Button"].fb_isVisible);
XCUIElement *datePicker = [self.testedApplication
descendantsMatchingType:XCUIElementTypeDatePicker].allElementsBoundByIndex.firstObject;
NSArray<XCUIElement *> *matches = [datePicker fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
XCTAssertEqual(matches.count, 1);

XCUIElementType expectedType = XCUIElementTypeOther;
if (@available(iOS 13.0, *)) {
expectedType = XCUIElementTypePicker;
}
XCUIElementType expectedType = XCUIElementTypePicker;
XCTAssertEqual([matches firstObject].elementType, expectedType);
}

Expand Down

0 comments on commit 2fd0dea

Please sign in to comment.