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 Oct 5, 2023
1 parent a56af86 commit 159bf86
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions CommonLib/Additions/NSObject+GREYCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ - (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 +194,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 +228,26 @@ - (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 159bf86

Please sign in to comment.