From 3cf7e3e95c2c63f06a518abf9dc52b0ef9d87153 Mon Sep 17 00:00:00 2001 From: Jeremy Lawrence Date: Wed, 29 Aug 2018 14:21:10 -0700 Subject: [PATCH] Add test for IGListAdapter dequeue method Summary: Adding a test to catch the bug that caused the crash in T33376364. In that bug, dequeueing two cells of the same class, but with different reuse identifiers, would cause a crash. Here in the test, if the same bug were to occur the dequeuing of the second cell would throw an exception and the test would fail. Differential Revision: D9560911 fbshipit-source-id: 9310839aaf441e919b5d443feaa44c71e991d146 --- Tests/IGListAdapterTests.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/IGListAdapterTests.m b/Tests/IGListAdapterTests.m index 273ba858..42a969c7 100644 --- a/Tests/IGListAdapterTests.m +++ b/Tests/IGListAdapterTests.m @@ -157,6 +157,21 @@ XCTAssertEqualObjects(identifier, @"IGNibNameUICollectionViewCell"); } +- (void)test_whenDequeueingTwoCellsOfTheSameClassWithDifferentReuseIdentifiers_thatBothReuseIdentifiersReturnCells { + self.dataSource.objects = @[@1, @2]; + [self.adapter reloadDataWithCompletion:nil]; + UICollectionViewCell *cell1 = [self.adapter dequeueReusableCellOfClass:[UICollectionViewCell class] + withReuseIdentifier:@"reuse-1" + forSectionController:[self.adapter sectionControllerForObject:@1] + atIndex:0]; + UICollectionViewCell *cell2 = [self.adapter dequeueReusableCellOfClass:[UICollectionViewCell class] + withReuseIdentifier:@"reuse-2" + forSectionController:[self.adapter sectionControllerForObject:@1] + atIndex:0]; + XCTAssertNotNil(cell1); + XCTAssertNotNil(cell2); +} + - (void)test_whenDataSourceChanges_thatBackgroundViewVisibilityChanges { self.dataSource.objects = @[@1]; UIView *background = [[UIView alloc] init];