|
|
|
|
@@ -30,26 +30,26 @@
|
|
|
|
|
|
|
|
|
|
- (void)testBatchNullState {
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, CGRectZero, CGSizeZero, CGPointZero, 0.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, CGRectZero, CGSizeZero, CGPointZero, 0.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == NO, @"Should not fetch in the null state");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)testBatchAlreadyFetching {
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
[context beginBatchFetching];
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == NO, @"Should not fetch when context is already fetching");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)testUnsupportedScrollDirections {
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
BOOL fetchRight = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionRight, ASScrollDirectionHorizontalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0);
|
|
|
|
|
BOOL fetchRight = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionRight, ASScrollDirectionHorizontalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0, YES);
|
|
|
|
|
XCTAssert(fetchRight == YES, @"Should fetch for scrolling right");
|
|
|
|
|
BOOL fetchDown = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0);
|
|
|
|
|
BOOL fetchDown = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0, YES);
|
|
|
|
|
XCTAssert(fetchDown == YES, @"Should fetch for scrolling down");
|
|
|
|
|
BOOL fetchUp = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionUp, ASScrollDirectionVerticalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0);
|
|
|
|
|
BOOL fetchUp = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionUp, ASScrollDirectionVerticalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0, YES);
|
|
|
|
|
XCTAssert(fetchUp == NO, @"Should not fetch for scrolling up");
|
|
|
|
|
BOOL fetchLeft = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionLeft, ASScrollDirectionHorizontalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0);
|
|
|
|
|
BOOL fetchLeft = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionLeft, ASScrollDirectionHorizontalDirections, PASSING_RECT, PASSING_SIZE, PASSING_POINT, 1.0, YES);
|
|
|
|
|
XCTAssert(fetchLeft == NO, @"Should not fetch for scrolling left");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -57,7 +57,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// scroll to 1-screen top offset, height is 1 screen, so bottom is 1 screen away from end of content
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 3.0), VERTICAL_OFFSET(screen * 1.0), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 3.0), VERTICAL_OFFSET(screen * 1.0), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == YES, @"Fetch should begin when vertically scrolling to exactly 1 leading screen away");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -65,7 +65,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// 3 screens of content, scroll only 1/2 of one screen
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 3.0), VERTICAL_OFFSET(screen * 0.5), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 3.0), VERTICAL_OFFSET(screen * 0.5), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == NO, @"Fetch should not begin when vertically scrolling less than the leading distance away");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -73,7 +73,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// 3 screens of content, top offset to 3-screens, height 1 screen, so its 1 screen past the leading
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 3.0), VERTICAL_OFFSET(screen * 3.0), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 3.0), VERTICAL_OFFSET(screen * 3.0), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == YES, @"Fetch should begin when vertically scrolling past the content size");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -81,7 +81,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// scroll to 1-screen left offset, width is 1 screen, so right is 1 screen away from end of content
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionRight, ASScrollDirectionVerticalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 3.0), HORIZONTAL_OFFSET(screen * 1.0), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionRight, ASScrollDirectionVerticalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 3.0), HORIZONTAL_OFFSET(screen * 1.0), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == YES, @"Fetch should begin when horizontally scrolling to exactly 1 leading screen away");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -89,7 +89,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// 3 screens of content, scroll only 1/2 of one screen
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionLeft, ASScrollDirectionHorizontalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 3.0), HORIZONTAL_OFFSET(screen * 0.5), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionLeft, ASScrollDirectionHorizontalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 3.0), HORIZONTAL_OFFSET(screen * 0.5), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == NO, @"Fetch should not begin when horizontally scrolling less than the leading distance away");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -97,7 +97,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// 3 screens of content, left offset to 3-screens, width 1 screen, so its 1 screen past the leading
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionHorizontalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 3.0), HORIZONTAL_OFFSET(screen * 3.0), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionHorizontalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 3.0), HORIZONTAL_OFFSET(screen * 3.0), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == YES, @"Fetch should begin when vertically scrolling past the content size");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -105,7 +105,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// when the content size is < screen size, the target offset will always be 0
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 0.5), VERTICAL_OFFSET(0.0), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionDown, ASScrollDirectionVerticalDirections, VERTICAL_RECT(screen), VERTICAL_SIZE(screen * 0.5), VERTICAL_OFFSET(0.0), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == YES, @"Fetch should begin when the target is 0 and the content size is smaller than the scree");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -113,7 +113,7 @@
|
|
|
|
|
CGFloat screen = 1.0;
|
|
|
|
|
ASBatchContext *context = [[ASBatchContext alloc] init];
|
|
|
|
|
// when the content size is < screen size, the target offset will always be 0
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionRight, ASScrollDirectionHorizontalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 0.5), HORIZONTAL_OFFSET(0.0), 1.0);
|
|
|
|
|
BOOL shouldFetch = ASDisplayShouldFetchBatchForContext(context, ASScrollDirectionRight, ASScrollDirectionHorizontalDirections, HORIZONTAL_RECT(screen), HORIZONTAL_SIZE(screen * 0.5), HORIZONTAL_OFFSET(0.0), 1.0, YES);
|
|
|
|
|
XCTAssert(shouldFetch == YES, @"Fetch should begin when the target is 0 and the content size is smaller than the scree");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|