Skip to content

Commit b9b5426

Browse files
author
Justin Martin
committed
Stabilize the pull to refresh tests
1 parent c3cc4cc commit b9b5426

6 files changed

+95
-85
lines changed

KIF Tests/AccessibilityIdentifierPullToRefreshTests.m

+14-18
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,27 @@ @interface AccessibilityIdentifierPullToRefreshTests : KIFTestCase
1515

1616
@implementation AccessibilityIdentifierPullToRefreshTests
1717

18-
-(void) testPullToRefreshByAccessibilityIdentifier
18+
- (void)afterEach
1919
{
20-
UITableView *tableView;
21-
[tester waitForAccessibilityElement:NULL view:&tableView withIdentifier:@"Test Suite TableView" tappable:NO];
22-
23-
[tester tapViewWithAccessibilityLabel:@"Reset Refresh Control"];
24-
[tester pullToRefreshViewWithAccessibilityIdentifier:@"Test Suite TableView"];
25-
[tester waitForViewWithAccessibilityLabel:@"Bingo!"];
26-
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
20+
// Once #1296 is landed, use that on the `waitForView...` calls below.
21+
// The issue is that implicit scrolling the table view when searching for label is causing "Bingo!" to immediately disappear.
22+
[tester waitForTimeInterval:3.0];
2723
}
2824

29-
-(void) testPullToRefreshByAccessibilityIdentifierWithDuration
25+
- (void)testPullToRefreshByAccessibilityIdentifier
3026
{
31-
UITableView *tableView;
32-
[tester waitForAccessibilityElement:NULL view:&tableView withIdentifier:@"Test Suite TableView" tappable:NO];
33-
34-
[tester tapViewWithAccessibilityLabel:@"Reset Refresh Control"];
35-
[tester pullToRefreshViewWithAccessibilityIdentifier:@"Test Suite TableView" pullDownDuration:KIFPullToRefreshInAboutThreeSeconds];
36-
[tester waitForViewWithAccessibilityLabel:@"Bingo!"];
37-
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
27+
[tester waitForViewWithAccessibilityIdentifier:@"Test Suite TableView"];
28+
[tester pullToRefreshViewWithAccessibilityIdentifier:@"Test Suite TableView"];
29+
[tester waitForViewWithAccessibilityLabel:@"Bingo!"];
30+
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
3831
}
3932

40-
- (void)afterEach
33+
- (void)testPullToRefreshByAccessibilityIdentifierWithDuration
4134
{
42-
[tester waitForAnimationsToFinish];
35+
[tester waitForViewWithAccessibilityIdentifier:@"Test Suite TableView"];
36+
[tester pullToRefreshViewWithAccessibilityIdentifier:@"Test Suite TableView" pullDownDuration:KIFPullToRefreshInAboutAHalfSecond];
37+
[tester waitForViewWithAccessibilityLabel:@"Bingo!"];
38+
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
4339
}
4440

4541
@end

KIF Tests/PullToRefreshTests.m

+13-11
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,32 @@ @interface PullToRefreshTests : KIFTestCase
1515

1616
@implementation PullToRefreshTests
1717

18-
-(void) testPullToRefreshByAccessibilityLabelWithDuration
18+
- (void)afterEach
1919
{
20-
UITableView *tableView;
21-
[tester waitForAccessibilityElement:NULL view:&tableView withIdentifier:@"Test Suite TableView" tappable:NO];
22-
23-
[tester pullToRefreshViewWithAccessibilityLabel:@"Table View" pullDownDuration:KIFPullToRefreshInAboutThreeSeconds];
24-
[tester waitForViewWithAccessibilityLabel:@"Bingo!"];
25-
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
20+
// Once #1296 is landed, use that on the `waitForView...` calls below.
21+
// The issue is that implicit scrolling the table view when searching for label is causing "Bingo!" to immediately disappear.
22+
[tester waitForTimeInterval:3.0];
23+
}
2624

27-
[tester waitForTimeInterval:5.0f]; //make sure the PTR is finished.
25+
- (void)testPullToRefreshByAccessibilityLabelWithDuration
26+
{
27+
[tester waitForViewWithAccessibilityIdentifier:@"Test Suite TableView"];
28+
[tester pullToRefreshViewWithAccessibilityLabel:@"Table View" pullDownDuration:KIFPullToRefreshInAboutAHalfSecond];
29+
[tester waitForViewWithAccessibilityLabel:@"Bingo!"];
30+
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
2831
}
2932

30-
-(void) testPullToRefreshWithBigContentSize
33+
- (void)testPullToRefreshWithBigContentSize
3134
{
3235
UITableView *tableView;
3336
[tester waitForAccessibilityElement:NULL view:&tableView withIdentifier:@"Test Suite TableView" tappable:NO];
3437
CGSize originalSize = tableView.contentSize;
3538
tableView.contentSize = CGSizeMake(1000, 10000);
3639

37-
[tester pullToRefreshViewWithAccessibilityLabel:@"Table View" pullDownDuration:KIFPullToRefreshInAboutThreeSeconds];
40+
[tester pullToRefreshViewWithAccessibilityLabel:@"Table View" pullDownDuration:KIFPullToRefreshInAboutAHalfSecond];
3841
[tester waitForViewWithAccessibilityLabel:@"Bingo!"];
3942
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
4043

41-
[tester waitForTimeInterval:5.0f]; //make sure the PTR is finished.
4244
tableView.contentSize = originalSize;
4345
}
4446

KIF Tests/PullToRefreshTests_ViewTestActor.m

+11-6
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,31 @@ @interface PullToRefreshTests_ViewTestActor : KIFTestCase
1515

1616
@implementation PullToRefreshTests_ViewTestActor
1717

18-
-(void) testPullToRefreshByAccessibilityLabelWithDuration
18+
- (void)afterEach
19+
{
20+
// Once #1296 is landed, use that on the `waitForView...` calls below.
21+
// The issue is that implicit scrolling the table view when searching for label is causing "Bingo!" to immediately disappear.
22+
[tester waitForTimeInterval:3.0];
23+
}
24+
25+
- (void)testPullToRefreshByAccessibilityLabelWithDuration
1926
{
2027
[[viewTester usingIdentifier:@"Test Suite TableView"] waitForView];
21-
[[viewTester usingLabel:@"Table View"] pullToRefreshWithDuration:KIFPullToRefreshInAboutOneSecond];
28+
[[viewTester usingLabel:@"Table View"] pullToRefreshWithDuration:KIFPullToRefreshInAboutAHalfSecond];
2229
[[viewTester usingLabel:@"Bingo!"] waitForView];
2330
[[viewTester usingLabel:@"Bingo!"] waitForAbsenceOfView];
24-
[viewTester waitForTimeInterval:1.0f];
2531
}
2632

27-
-(void) testPullToRefreshWithBigContentSize
33+
- (void)testPullToRefreshWithBigContentSize
2834
{
2935

3036
UITableView *tableView = (id)[[viewTester usingIdentifier:@"Test Suite TableView"] waitForView];
3137
CGSize originalSize = tableView.contentSize;
3238
tableView.contentSize = CGSizeMake(1000, 10000);
3339

34-
[[viewTester usingLabel:@"Table View"] pullToRefreshWithDuration:KIFPullToRefreshInAboutOneSecond];
40+
[[viewTester usingLabel:@"Table View"] pullToRefreshWithDuration:KIFPullToRefreshInAboutAHalfSecond];
3541
[[viewTester usingLabel:@"Bingo!"] waitForView];
3642
[[viewTester usingLabel:@"Bingo!"] waitForAbsenceOfView];
37-
[viewTester waitForTimeInterval:1.0f];
3843

3944
tableView.contentSize = originalSize;
4045
}

Sources/KIF/Classes/KIFUITestActor.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,8 @@ - (void)pullToRefreshAccessibilityElement:(UIAccessibilityElement *)element inVi
13301330
// Can handle only the touchable space.
13311331
CGRect elementFrame = [viewToSwipe convertRect:viewToSwipe.bounds toView:[UIApplication sharedApplication].keyWindow.rootViewController.view];
13321332
CGPoint swipeStart = CGPointCenteredInRect(elementFrame);
1333-
CGPoint swipeDisplacement = CGPointMake(CGRectGetMidX(elementFrame), CGRectGetMaxY(elementFrame));
1333+
swipeStart.y = swipeStart.y - CGRectGetMaxY(elementFrame) / 4.0;
1334+
CGPoint swipeDisplacement = CGPointMake(0, CGRectGetMaxY(elementFrame) / 2.0);
13341335

13351336
[viewToSwipe dragFromPoint:swipeStart displacement:swipeDisplacement steps:kNumberOfPointsInSwipePath];
13361337
}

0 commit comments

Comments
 (0)