ios5kif-framework

Any ideas on how to implement pull to refresh with KIF Tests?


This is pretty open-ended.

Does anyone have an idea as to how to test pull-to-refresh functionality in KIF Tests?


Solution

  • Simply dragging from the top of the screen down to the bottom of the screen would do that, right? KIF has the following method implemented in the UIView-KIFAdditions category:

    - (void)dragFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint;
    

    I went ahead and created the following test step for simple dragging operations:

    + (id)stepToDragFromStartPoint:(CGPoint)startPoint toEndPoint:(CGPoint)endPoint
    {
        NSString *description = [NSString stringWithFormat:@"Simulate dragging finger from point %.1f,%.1f to point %.1f,%.1f", startPoint.x, startPoint.y, endPoint.x, endPoint.y];
        return [KIFTestStep stepWithDescription:description executionBlock:^(KIFTestStep *step, NSError **error) {
            UIView *viewToSwipe = [UIApplication sharedApplication].keyWindow.subviews.lastObject;
    
            [viewToSwipe dragFromPoint:startPoint toPoint:endPoint];
    
            return KIFTestStepResultSuccess;
        }];
    }
    

    Hope that helps!