From 312e0a03ba9de60483ba09e6bd0267888e2fce6a Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Fri, 6 Oct 2023 03:08:34 -0700 Subject: [PATCH] Add coverage for testing initial and final layout attributes without a transitioning delegate Summary: Duplicates an existing test and tests the same circumstances without a section controller `transitionDelegate` set. This causes all the logic to no-op and return the same instance of the original layout attributes object. Differential Revision: D49900561 fbshipit-source-id: 8f768a998308c1aff73e8195aacdfd70579be601 --- Tests/IGListAdapterE2ETests.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Tests/IGListAdapterE2ETests.m b/Tests/IGListAdapterE2ETests.m index 7a6562d4..e5979d50 100644 --- a/Tests/IGListAdapterE2ETests.m +++ b/Tests/IGListAdapterE2ETests.m @@ -1734,6 +1734,24 @@ IGAssertEqualPoint(finalAttribute.center, attribute.center.x + offset.x ,attribute.center.y + offset.y); } +- (void)test_whenModifyingInitialAndFinalAttribute_withoutTransitionDelegate_thatLayoutIsCorrect { + // set up the custom layout + IGListCollectionViewLayout *layout = [[IGListCollectionViewLayout alloc] initWithStickyHeaders:NO topContentInset:0 stretchToEdge:YES]; + self.collectionView.collectionViewLayout = layout; + + IGTestObject *object = genTestObject(@1, @2); + [self setupWithObjects:@ [object]]; + + // When no transition delegate is set, the initial and final layout methods no-op, so these values should all match + NSIndexPath *indexPath = genIndexPath(0, 0); + UICollectionViewLayoutAttributes *attribute = [layout layoutAttributesForItemAtIndexPath:indexPath]; + UICollectionViewLayoutAttributes *initialAttribute = [layout initialLayoutAttributesForAppearingItemAtIndexPath:indexPath]; + UICollectionViewLayoutAttributes *finalAttribute = [layout finalLayoutAttributesForDisappearingItemAtIndexPath:indexPath]; + + IGAssertEqualPoint(attribute.center, initialAttribute.center.x, initialAttribute.center.y); + IGAssertEqualPoint(attribute.center, finalAttribute.center.x, finalAttribute.center.y); +} + - (void)test_whenSwappingCollectionViewsAfterUpdate_thatUpdatePerformedOnTheCorrectCollectionView { // BEGIN: setup of FIRST adapter+dataSource+collectionView IGListAdapter *adapter1 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:nil];