Skip to content

Commit

Permalink
Before searching for a tappable point on a rect, ensure the rect has …
Browse files Browse the repository at this point in the history
…been converted in the coordinate-space of a window with an identity transform.
  • Loading branch information
Brian Gorby committed Feb 8, 2012
1 parent 7d78430 commit 25fecde
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Classes/KIFTestStep.m
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,24 @@ + (id)stepToTapViewWithAccessibilityLabel:(NSString *)label value:(NSString *)va
return KIFTestStepResultWait;
}

CGRect elementFrame = [view.window convertRect:element.accessibilityFrame toView:view];
// Need to convert the element's accessibilityFrame in the coordinate-space of a window with an identity transform. This allows for discovery of a tappable point in an UIAlertView button when the current orientation is not portrait, since UIAlertViews are presented in a separate window with an applied CGAffineTransform based on device rotation.
UIWindow *identityTransformWindow = nil;
if (CGAffineTransformIsIdentity(view.window.transform)) {
identityTransformWindow = view.window;
}
else {
for (UIWindow *window in [[[UIApplication sharedApplication] windows] reverseObjectEnumerator]) {
if (CGAffineTransformIsIdentity(window.transform)){
identityTransformWindow = window;
break;
}
}
}

KIFTestWaitCondition(identityTransformWindow, error, @"Failed to find window with level UIWindowLevelNormal");

CGRect elementFrame = [identityTransformWindow convertRect:element.accessibilityFrame toView:view];

CGPoint tappablePointInElement = [view tappablePointInRect:elementFrame];

// This is mostly redundant of the test in _accessibilityElementWithLabel:
Expand Down

0 comments on commit 25fecde

Please sign in to comment.