Skip to content

Commit

Permalink
Merge pull request #1213 from dostrander/dostrander/add-first-respond…
Browse files Browse the repository at this point in the history
…er-timeout

Add first responder timeout
  • Loading branch information
dostrander authored Feb 23, 2021
2 parents 25747aa + 5362b9a commit e725243
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Sources/KIF/Classes/KIFTestActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ typedef void (^KIFTestCompletionBlock)(KIFTestStepResult result, NSError *error)
*/
+ (void)setStepDelay:(NSTimeInterval)newStepDelay;

/*!
@method firstResponderTimeout
@abstract The maximum amount of time that we wait on views becoming first responders.
@discussion To change the default value of the first responder timeout property, call +firstResponderTimeout: with a different value.
*/
+ (NSTimeInterval)firstResponderTimeout;

/*!
@method setStepDelay:
@abstract Sets the amount of time that execution blocks use before trying again to met desired conditions.
*/
+ (void)setFirstResponderTimeout:(NSTimeInterval)firstResponderTimeout;

/*!
@abstract Fails the test.
@discussion Mostly useful for test debugging or as a placeholder when building new tests.
Expand Down
13 changes: 13 additions & 0 deletions Sources/KIF/Classes/KIFTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ - (void)runBlock:(KIFTestExecutionBlock)executionBlock
static NSTimeInterval KIFTestStepDefaultMainThreadDispatchStabilizationTimeout = 0.5;
static NSTimeInterval KIFTestStepDefaultTimeout = 10.0;
static NSTimeInterval KIFTestStepDelay = 0.1;
static NSTimeInterval KIFTestStepFirstResponderTimeout = 0.5;


+ (NSTimeInterval)defaultAnimationWaitingTimeout
{
Expand Down Expand Up @@ -188,6 +190,17 @@ + (void)setStepDelay:(NSTimeInterval)newStepDelay;
KIFTestStepDelay = newStepDelay;
}

+ (NSTimeInterval)firstResponderTimeout;
{
return KIFTestStepFirstResponderTimeout;
}

+ (void)setFirstResponderTimeout:(NSTimeInterval)firstResponderTimeout;
{
KIFTestStepFirstResponderTimeout = firstResponderTimeout;
}


#pragma mark Generic tests

- (void)fail
Expand Down
2 changes: 1 addition & 1 deletion Sources/KIF/Classes/KIFUITestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ - (void)tapAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView

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

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

0 comments on commit e725243

Please sign in to comment.