Test fixing double insert crash

Summary: Looking at crash logs, the new high-firing crash has 2 item inserts in it. Test deduping the insert. Testing b/c I want to make sure there aren't any weird side effects.

Differential Revision: D6605474

fbshipit-source-id: 522120074aed2ed4995104443d48d8254ddb4fec
This commit is contained in:
Ryan Nystrom 2017-12-20 06:22:18 -08:00 committed by Facebook Github Bot
parent ae7f36f5c2
commit 8ae6013d0e
4 changed files with 28 additions and 0 deletions

View file

@ -35,6 +35,8 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
- Check object type on lookup to prevent crossing types if different objects collide with their identifiers. [Ryan Nystrom](https://github.com/rnystrom) [(#tbd)](https://github.com/Instagram/IGListKit/pull/tbd)
- Testing a fix that removes duplicate item-level updates. [Ryan Nystrom](https://github.com/rnystrom) (tbd)
3.1.1
-----

View file

@ -24,6 +24,8 @@ typedef NS_OPTIONS (NSInteger, IGListExperiment) {
IGListExperimentReloadDataFallback = 1 << 3,
/// Test a faster way to return visible section controllers.
IGListExperimentFasterVisibleSectionController = 1 << 4,
/// Test deduping item-level updates.
IGListExperimentDedupeItemUpdates = 1 << 5,
};
/**

View file

@ -309,6 +309,11 @@ void convertReloadToDeleteInsert(NSMutableIndexSet *reloads,
[itemDeletes addObjectsFromArray:[reloadDeletePaths allObjects]];
[itemInserts addObjectsFromArray:[reloadInsertPaths allObjects]];
if (IGListExperimentEnabled(self.experiments, IGListExperimentDedupeItemUpdates)) {
itemDeletes = [[[NSSet setWithArray:itemDeletes] allObjects] mutableCopy];
itemInserts = [[[NSSet setWithArray:itemInserts] allObjects] mutableCopy];
}
IGListBatchUpdateData *updateData = [[IGListBatchUpdateData alloc] initWithInsertSections:inserts
deleteSections:deletes
moveSections:moves

View file

@ -1786,4 +1786,23 @@
[self waitForExpectationsWithTimeout:30 handler:nil];
}
- (void)test_whenInsertingItemTwice_withDedupeExperiment_thatSecondInsertGetsDropped {
((IGListAdapterUpdater*)self.updater).experiments = IGListExperimentDedupeItemUpdates;
IGTestObject *object = genTestObject(@1, @1);
[self setupWithObjects:@[object]];
IGTestDelegateController *controller = [self.adapter sectionControllerForObject:self.dataSource.objects.firstObject];
XCTestExpectation *expectation = genExpectation;
[controller.collectionContext performBatchAnimated:YES updates:^(id<IGListBatchContext> _Nonnull batchContext) {
object.value = @2;
[batchContext insertInSectionController:controller atIndexes:[NSIndexSet indexSetWithIndex:0]];
[batchContext insertInSectionController:controller atIndexes:[NSIndexSet indexSetWithIndex:0]];
} completion:^(BOOL finished) {
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:30 handler:nil];
}
@end