-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify end position for -scrollToObject #196
Changes from 6 commits
5c55701
634d2ea
dfe8f02
6c9df5e
d2f4f5f
4a7db32
73ab8d9
d6e5846
17497d7
08c08aa
f7c5b60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -532,14 +532,18 @@ - (void)test_whenScrollVerticallyToItem { | |
self.dataSource.objects = @[@1, @2, @3, @4, @5, @6]; | ||
[self.adapter reloadDataWithCompletion:nil]; | ||
XCTAssertEqual([self.collectionView numberOfSections], 6); | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 0); | ||
[self.adapter scrollToObject:@2 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@2 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 10); | ||
[self.adapter scrollToObject:@3 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@3 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 30); | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 150); | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 105); | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionBottom animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 60); | ||
} | ||
|
||
- (void)test_whenScrollHorizontallyToItem { | ||
|
@@ -548,13 +552,17 @@ - (void)test_whenScrollHorizontallyToItem { | |
self.layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; | ||
[self.adapter reloadDataWithCompletion:nil]; | ||
XCTAssertEqual([self.collectionView numberOfSections], 6); | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal animated:NO]; | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 0); | ||
[self.adapter scrollToObject:@2 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal animated:NO]; | ||
[self.adapter scrollToObject:@2 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 100, 0); | ||
[self.adapter scrollToObject:@3 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal animated:NO]; | ||
[self.adapter scrollToObject:@3 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 200, 0); | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal animated:NO]; | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 500, 0); | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 500, 0); | ||
[self.adapter scrollToObject:@6 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionHorizontal atScrollPosition:UICollectionViewScrollPositionRight animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 500, 0); | ||
self.layout.scrollDirection = UICollectionViewScrollDirectionVertical; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized that these tests don't actually test the position since items are full width. We almost need a new test suite to actually cover these scenarios. @jessesquires what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep 😂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rnystrom lol. yeah, lets:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
@@ -574,9 +582,9 @@ - (void)test_whenScrollToItem_thatSupplementarySourceSupportsSingleHeader { | |
[self.adapter performUpdatesAnimated:NO completion:nil]; | ||
|
||
XCTAssertNotNil([self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionHeader atIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]); | ||
[self.adapter scrollToObject:@1 supplementaryKinds:@[UICollectionElementKindSectionHeader] scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@1 supplementaryKinds:@[UICollectionElementKindSectionHeader] scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 0); | ||
[self.adapter scrollToObject:@2 supplementaryKinds:@[UICollectionElementKindSectionHeader] scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@2 supplementaryKinds:@[UICollectionElementKindSectionHeader] scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 20); | ||
} | ||
|
||
|
@@ -596,17 +604,17 @@ - (void)test_whenScrollToItem_thatSupplementarySourceSupportsHeaderAndFooter { | |
|
||
XCTAssertNotNil([self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionHeader atIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]); | ||
XCTAssertNotNil([self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionFooter atIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]); | ||
[self.adapter scrollToObject:@1 supplementaryKinds:@[UICollectionElementKindSectionHeader, UICollectionElementKindSectionFooter] scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@1 supplementaryKinds:@[UICollectionElementKindSectionHeader, UICollectionElementKindSectionFooter] scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 0); | ||
[self.adapter scrollToObject:@2 supplementaryKinds:@[UICollectionElementKindSectionHeader, UICollectionElementKindSectionFooter] scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@2 supplementaryKinds:@[UICollectionElementKindSectionHeader, UICollectionElementKindSectionFooter] scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 30); | ||
} | ||
|
||
- (void)test_whenScrollVerticallyToItem_thatFeedIsEmpty { | ||
self.dataSource.objects = @[]; | ||
[self.adapter reloadDataWithCompletion:nil]; | ||
XCTAssertEqual([self.collectionView numberOfSections], 0); | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 0); | ||
} | ||
|
||
|
@@ -615,13 +623,13 @@ - (void)test_whenScrollVerticallyToItem_thatItemNotInFeed { | |
self.dataSource.objects = @[@1, @2, @3, @4]; | ||
[self.adapter reloadDataWithCompletion:nil]; | ||
XCTAssertEqual([self.collectionView numberOfSections], 4); | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@1 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 0); | ||
[self.adapter scrollToObject:@5 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@5 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 0); | ||
[self.adapter scrollToObject:@2 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@2 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 10); | ||
[self.adapter scrollToObject:@5 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical animated:NO]; | ||
[self.adapter scrollToObject:@5 supplementaryKinds:nil scrollDirection:UICollectionViewScrollDirectionVertical atScrollPosition:UICollectionViewScrollPositionNone animated:NO]; | ||
IGAssertEqualPoint([self.collectionView contentOffset], 0, 10); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: Can we remove the
ScrollToObject
formatting and just start w/ "Scrolling method changed from"