有关如何使用KIF测试实现pull刷新的任何想法?

时间:2013-03-22 13:39:07

标签: ios5 kif-framework

这是非常开放的。

有没有人知道如何在KIF测试中测试pull-to-refresh功能?

2 个答案:

答案 0 :(得分:3)

只需从屏幕顶部向下拖动到屏幕底部就可以了,对吗? KIF在UIView-KIFAdditions类别中实现了以下方法:

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

我继续为简单的拖动操作创建了以下测试步骤:

+ (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;
    }];
}

希望有所帮助!

答案 1 :(得分:0)

发布此问题一段时间后,KIF开发了内置的“拉动刷新”功能。请参阅KIFUITestActor

中的以下方法
- (void)pullToRefreshViewWithAccessibilityLabel:(NSString *)label pullDownDuration:(KIFPullToRefreshTiming) pullDownDuration;
- (void)pullToRefreshViewWithAccessibilityLabel:(NSString *)label value:(NSString *)value;
- (void)pullToRefreshAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView *)viewToSwipe pullDownDuration:(KIFPullToRefreshTiming) pullDownDuration;