这是非常开放的。
有没有人知道如何在KIF测试中测试pull-to-refresh功能?
答案 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;