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

Fix issue with elements not becoming first responder fast enough #1100

Merged
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
13 changes: 9 additions & 4 deletions Classes/KIFUITestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ - (void)tapViewWithAccessibilityLabel:(NSString *)label value:(NSString *)value

- (void)tapAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView *)view
{
BOOL wasAccessibilityElementOnscreen = ((id)element != view) && !CGRectEqualToRect([element accessibilityFrame], CGRectZero);

[self runBlock:^KIFTestStepResult(NSError **error) {

KIFTestWaitCondition(view.isUserInteractionActuallyEnabled, error, @"View is not enabled for interaction: %@", view);

CGPoint tappablePointInElement = [self tappablePointInElement:element andView:view];
Expand All @@ -336,14 +337,18 @@ - (void)tapAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView
return KIFTestStepResultSuccess;
}];

[self waitForAnimationsToFinish];

// Controls might not synchronously become first-responders. Sometimes custom controls
// may need to spin the runloop before reporting as the first responder.
[self runBlock:^KIFTestStepResult(NSError *__autoreleasing *error) {
KIFTestWaitCondition(![view canBecomeFirstResponder] || [view isDescendantOfFirstResponder], error, @"Failed to make the view into the first responder: %@", view);
// When we're interacting with an accessibility element, it might go offscreen before we're able to do this check
BOOL isAccessibilityElementOffscreen = ((id)element != view) && CGRectEqualToRect([element accessibilityFrame], CGRectZero);
BOOL accessibilityElementDisappeared = wasAccessibilityElementOnscreen && isAccessibilityElementOffscreen;

KIFTestWaitCondition(![view canBecomeFirstResponder] || ![view isProbablyTappable] || [view isDescendantOfFirstResponder] || accessibilityElementDisappeared, error, @"Failed to make the view into the first responder: %@", view);
return KIFTestStepResultSuccess;
} timeout:0.5];

[self waitForAnimationsToFinish];
}

- (void)tapScreenAtPoint:(CGPoint)screenPoint
Expand Down