Skip to content

Commit

Permalink
Internal Commit Uploaded
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 465432740
  • Loading branch information
mobile-devx-github-bot committed Nov 24, 2022
1 parent ca6a67f commit 404967b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CommonLib/Additions/NSObject+GREYCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ - (NSString *)grey_description {
[description appendFormat:@"; isAccessible=%@", self.isAccessibilityElement ? @"Y" : @"N"];
}

// IsAccessibilityElement.
if ([self respondsToSelector:@selector(accessibilityViewIsModal)]) {
[description appendFormat:@"; accessibilityViewIsModal=%@", self.accessibilityViewIsModal ? @"Y" : @"N"];
}

// AccessibilityIdentifier from UIAccessibilityIdentification.
if ([self respondsToSelector:@selector(accessibilityIdentifier)]) {
NSString *value = [self performSelector:@selector(accessibilityIdentifier)];
Expand Down Expand Up @@ -188,6 +193,27 @@ - (NSString *)grey_description {
return description;
}

- (id)viewCoveringByViewIsModal {
if (![self respondsToSelector:@selector(superview)]) {
return nil;
}
id superview = [(id)self superview];
if (![superview respondsToSelector:@selector(subviews)]) {
return nil;
}
NSArray<id> *subviews = (NSArray<id> *)[(id)superview subviews];
for (id subview in subviews) {
if (subview == self || ![subview respondsToSelector:@selector(accessibilityViewIsModal)]) {
continue;
}
BOOL isModal = [(id)subview accessibilityViewIsModal];
if (isModal) {
return subview;
}
}
return [(id)superview viewCoveringByViewIsModal];
}

- (NSString *)grey_shortDescription {
NSMutableString *description = [[NSMutableString alloc] init];

Expand All @@ -201,6 +227,21 @@ - (NSString *)grey_shortDescription {
[description appendString:axIdentifierDescription];
}

if ([self respondsToSelector:@selector(accessibilityViewIsModal)]) {
NSString *accessibilityViewIsModal = (BOOL)[self performSelector:@selector(accessibilityViewIsModal)] ? @"Y" : @"N";
NSString *axViewIsModalDescription =
[self grey_formattedDescriptionOrEmptyStringForValue:accessibilityViewIsModal
withPrefix:@"; AX.viewIsModal="];
[description appendString:axViewIsModalDescription];
}

id coveringView = [self viewCoveringByViewIsModal];
NSString *coveringViewDesc = (coveringView == nil) ? @"nil" : [NSString stringWithFormat:@"%@ %p", NSStringFromClass([coveringView class]), coveringView];
NSString *coveringViewDescription =
[self grey_formattedDescriptionOrEmptyStringForValue:coveringViewDesc
withPrefix:@"; AX.coveredBy="];
[description appendString:coveringViewDescription];

if ([self respondsToSelector:@selector(accessibilityLabel)]) {
NSString *axLabelDescription =
[self grey_formattedDescriptionOrEmptyStringForValue:self.accessibilityLabel
Expand Down

0 comments on commit 404967b

Please sign in to comment.