Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Commit Uploaded #1854

Open
wants to merge 1 commit into
base: earlgrey2
Choose a base branch
from
Open
Changes from all commits
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
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