Skip to content

Commit

Permalink
cleanup docs, add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Nystrom committed Feb 12, 2017
1 parent 04d7792 commit 6635283
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 16 deletions.
32 changes: 16 additions & 16 deletions Source/Internal/IGListDisplayHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ IGLK_SUBCLASSING_RESTRICTED
/**
Tells the handler that a cell will be displayed in the IGListAdapter.
@param cell A cell that will display.
@param listAdapter The adapter managing the infra.
@param sectionController The section controller the cell is in.
@param object The object associated with the section controller.
@param cell A cell that will be displayed.
@param listAdapter The adapter the cell will display in.
@param sectionController The section controller that manages the cell.
@param object The object that powers the section controller.
@param indexPath The index path of the cell in the UICollectionView.
*/
- (void)willDisplayCell:(UICollectionViewCell *)cell
Expand All @@ -39,9 +39,9 @@ IGLK_SUBCLASSING_RESTRICTED
/**
Tells the handler that a cell did end display in the IGListAdapter.
@param cell A cell that did end display.
@param listAdapter The adapter managing the infra.
@param sectionController The section controller the cell is in.
@param cell A cell that will be displayed.
@param listAdapter The adapter the cell will display in.
@param sectionController The section controller that manages the cell.
@param indexPath The index path of the cell in the UICollectionView.
*/
- (void)didEndDisplayingCell:(UICollectionViewCell *)cell
Expand All @@ -53,11 +53,11 @@ IGLK_SUBCLASSING_RESTRICTED
/**
Tells the handler that a supplementary view will be displayed in the IGListAdapter.
@param view A supplementary view that will display.
@param listAdapter The adapter managing the infra.
@param sectionController The section controller the view is in.
@param object The object associated with the section controller.
@param indexPath The index path of the supplementary view.
@param view A supplementary view that will be displayed.
@param listAdapter The adapter the supplementary view will display in.
@param sectionController The section controller that manages the supplementary view.
@param object The object that powers the section controller.
@param indexPath The index path of the supplementary view in the UICollectionView.
*/
- (void)willDisplaySupplementaryView:(UICollectionReusableView *)view
forListAdapter:(IGListAdapter *)listAdapter
Expand All @@ -69,10 +69,10 @@ IGLK_SUBCLASSING_RESTRICTED
/**
Tells the handler that a supplementary view did end display in the IGListAdapter.
@param view A supplementary view that did end display
@param listAdapter The adapter managing the infra.
@param sectionController The section controller the view is in.
@param indexPath The index path of the supplementary view.
@param view A supplementary view that will be displayed.
@param listAdapter The adapter the supplementary view will display in.
@param sectionController The section controller that manages the supplementary view.
@param indexPath The index path of the supplementary view in the UICollectionView.
*/
- (void)didEndDisplayingSupplementaryView:(UICollectionReusableView *)view
forListAdapter:(IGListAdapter *)listAdapter
Expand Down
30 changes: 30 additions & 0 deletions Tests/IGListAdapterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1051,4 +1051,34 @@ - (void)test_whenEndingDisplayOfSectionController_withOnlySupplementaryView_that
[mockDisplayDelegate verify];
}

- (void)test_whenWillDisplaySupplementaryView_thatCollectionViewDelegateReceivesEvents {
// silence display handler asserts
self.dataSource.objects = @[@1, @2];
[self.adapter reloadDataWithCompletion:nil];

id mockDelegate = [OCMockObject mockForProtocol:@protocol(UICollectionViewDelegate)];
self.adapter.collectionViewDelegate = mockDelegate;
UICollectionReusableView *view = [UICollectionReusableView new];
NSString *kind = @"kind";
NSIndexPath *path = [NSIndexPath indexPathForItem:0 inSection:0];
[[mockDelegate expect] collectionView:self.collectionView willDisplaySupplementaryView:view forElementKind:kind atIndexPath:path];
[self.adapter collectionView:self.collectionView willDisplaySupplementaryView:view forElementKind:kind atIndexPath:path];
[mockDelegate verify];
}

- (void)test_whenEndDisplayingSupplementaryView_thatCollectionViewDelegateReceivesEvents {
// silence display handler asserts
self.dataSource.objects = @[@1, @2];
[self.adapter reloadDataWithCompletion:nil];

id mockDelegate = [OCMockObject mockForProtocol:@protocol(UICollectionViewDelegate)];
self.adapter.collectionViewDelegate = mockDelegate;
UICollectionReusableView *view = [UICollectionReusableView new];
NSString *kind = @"kind";
NSIndexPath *path = [NSIndexPath indexPathForItem:0 inSection:0];
[[mockDelegate expect] collectionView:self.collectionView didEndDisplayingSupplementaryView:view forElementOfKind:kind atIndexPath:path];
[self.adapter collectionView:self.collectionView didEndDisplayingSupplementaryView:view forElementOfKind:kind atIndexPath:path];
[mockDelegate verify];
}

@end
47 changes: 47 additions & 0 deletions Tests/IGListDisplayHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,51 @@ - (void)test_whenCellInserted_withDisplayedCellExistingAtPath_thatDisplayHandler
[self.mockDisplayDelegate verify];
}

- (void)test_whenWillDisplaySupplementaryView_withCellDisplayedAfter_thatDisplayHandlerReceivesOneEvent {
NSIndexPath *path = [NSIndexPath indexPathForItem:0 inSection:0];
UICollectionReusableView *view = [UICollectionReusableView new];
UICollectionViewCell *cell = [UICollectionViewCell new];

self.list.displayDelegate = self.mockDisplayDelegate;
self.adapter.delegate = self.mockAdapterDelegate;

[[self.mockDisplayDelegate expect] listAdapter:self.adapter willDisplaySectionController:self.list];
[[self.mockAdapterDelegate expect] listAdapter:self.adapter willDisplayObject:self.object atIndex:path.section];

[self.displayHandler willDisplaySupplementaryView:view forListAdapter:self.adapter sectionController:self.list object:self.object indexPath:path];

[self.mockDisplayDelegate verify];
[self.mockAdapterDelegate verify];

[[self.mockDisplayDelegate expect] listAdapter:self.adapter willDisplaySectionController:self.list cell:cell atIndex:path.item];
[[self.mockAdapterDelegate reject] listAdapter:self.adapter willDisplayObject:self.list atIndex:path.item];
[[self.mockDisplayDelegate reject] listAdapter:self.adapter willDisplaySectionController:self.list];

[self.displayHandler willDisplayCell:cell forListAdapter:self.adapter sectionController:self.list object:self.object indexPath:path];
}

- (void)test_whenEndDisplayingSupplementaryView_withEndDisplayingTwice_thatDisplayHandlerReceivesOneEvent {
NSIndexPath *path = [NSIndexPath indexPathForItem:0 inSection:0];
UICollectionReusableView *view = [UICollectionReusableView new];

[self.displayHandler willDisplaySupplementaryView:view forListAdapter:self.adapter sectionController:self.list object:self.object indexPath:path];

[[self.mockDisplayDelegate expect] listAdapter:self.adapter didEndDisplayingSectionController:self.list];
[[self.mockAdapterDelegate expect] listAdapter:self.adapter didEndDisplayingObject:self.object atIndex:path.section];

[[self.mockDisplayDelegate reject] listAdapter:self.adapter didEndDisplayingSectionController:self.list];
[[self.mockDisplayDelegate reject] listAdapter:self.adapter didEndDisplayingSectionController:self.list cell:[OCMArg any] atIndex:path.item];
[[self.mockAdapterDelegate reject] listAdapter:self.adapter didEndDisplayingObject:self.object atIndex:path.section];

self.list.displayDelegate = self.mockDisplayDelegate;
self.adapter.delegate = self.mockAdapterDelegate;
//first call
[self.displayHandler didEndDisplayingSupplementaryView:view forListAdapter:self.adapter sectionController:self.list indexPath:path];
//second call
[self.displayHandler didEndDisplayingSupplementaryView:view forListAdapter:self.adapter sectionController:self.list indexPath:path];

[self.mockDisplayDelegate verify];
[self.mockAdapterDelegate verify];
}

@end

0 comments on commit 6635283

Please sign in to comment.