Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7d711f0
Completed the test suite for the visibility tracker
TimOliver Jan 27, 2026
7d53022
Added more test coverage for list update classes
TimOliver Jan 27, 2026
1bb222d
Updated list adapter integration with UIViewController tests
TimOliver Jan 27, 2026
46de7c0
Covered the ‘removeListener’ code for the delegate announcer
TimOliver Jan 27, 2026
b9d69ed
Added more E2E tests to cover QOS path
TimOliver Jan 27, 2026
7114273
Adds more test coverage to IGListBindingSectionControllerTests
TimOliver Jan 27, 2026
c3abd12
Added unit test for covering nil states in context menu configuration
TimOliver Jan 27, 2026
47333d7
Added IGListPerformDiffTests file for PerformDiff edge cases
TimOliver Jan 27, 2026
344fd38
Added more test coverage to UIViewController adapter tests
TimOliver Jan 27, 2026
9dbd763
Added debug details coverage
TimOliver Jan 27, 2026
186faa5
Fixed missing header import
TimOliver Jan 27, 2026
94549e0
Added additional coverage to list adapter updater
TimOliver Jan 27, 2026
992d8e4
Added more coverage to IGListSectionMapTests
TimOliver Jan 27, 2026
9b8ed03
Added coverage for nil check in IGListUpdateTransactionBuilder behavior
TimOliver Jan 27, 2026
5b59c68
Added more coverage for list adapter
TimOliver Jan 27, 2026
a808907
Fixed failing tests
TimOliver Jan 27, 2026
9104135
Added edge case for NO return in IGListUpdateCoalescer tests
TimOliver Jan 27, 2026
ab29771
Added more tests to cover error handling in IGListSectionMap
TimOliver Jan 27, 2026
21930a1
Added documentation to the willCrashWithCollectionView protocol defines
TimOliver Jan 27, 2026
ea55325
Fixed crash dealing with immutable array in tests
TimOliver Jan 27, 2026
11450fd
Added more test coverage to list section controller class
TimOliver Jan 27, 2026
65f39a7
Cleared up cache state between tests
TimOliver Jan 27, 2026
cbe2b6c
Added test to ensure crash logic is correct
TimOliver Jan 27, 2026
52342de
Added tests for verifying error handling when NaN frame sizes provided
TimOliver Jan 27, 2026
fa26ac3
Removed NaN test since it corrupts internal state around other tests
TimOliver Jan 27, 2026
36ea8ef
Removed other test causing invalid state in surrounding tests
TimOliver Jan 27, 2026
6adc5cd
Adds check for the cell crash detection delegate
TimOliver Jan 27, 2026
5b15894
Hardened the test for checking if the cell crash delegate is working
TimOliver Jan 27, 2026
e37b4e3
Gated out test that is unsupported on tvOS
TimOliver Jan 27, 2026
a22c2d8
Increase the UI timeout to 5 seconds.
TimOliver Jan 27, 2026
aca9b2e
Fixed unit test falling through on internal builds
TimOliver Jan 28, 2026
77c8df4
Removed internal failing test for now
TimOliver Jan 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ final class DemosViewControllerUITests: UITestCase {
let exactBar = app.navigationBars[title]
let compactBar = app.navigationBars[title.replacingOccurrences(of: " ", with: "")]

waitToAppear(element: exactBar, timeout: 2)
waitToAppear(element: exactBar, timeout: 5)

if !exactBar.exists {
waitToAppear(element: compactBar, timeout: 2)
waitToAppear(element: compactBar, timeout: 5)
}

XCTAssertTrue(
Expand Down
32 changes: 31 additions & 1 deletion IGListKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
16B71CEE22B0A08400FE96ED /* IGTestInvalidateLayoutDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 16B71CE822B0A08300FE96ED /* IGTestInvalidateLayoutDataSource.m */; };
16B71CEF22B0A08400FE96ED /* IGTestInvalidateLayoutObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 16B71CEA22B0A08300FE96ED /* IGTestInvalidateLayoutObject.m */; };
16B71CF022B0A08400FE96ED /* IGTestInvalidateLayoutObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 16B71CEA22B0A08300FE96ED /* IGTestInvalidateLayoutObject.m */; };
22907ABD2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907ABC2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m */; };
22907ABE2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907ABC2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m */; };
22907AC12F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC02F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m */; };
22907AC22F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC02F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m */; };
22907AC42F2866160015F3D0 /* IGListUpdateCoalescerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC32F2866160015F3D0 /* IGListUpdateCoalescerTests.m */; };
22907AC52F2866160015F3D0 /* IGListUpdateCoalescerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC32F2866160015F3D0 /* IGListUpdateCoalescerTests.m */; };
22907AC72F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC62F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m */; };
22907AC82F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC62F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m */; };
22907ACA2F2870020015F3D0 /* IGListPerformDiffTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC92F2870020015F3D0 /* IGListPerformDiffTests.m */; };
22907ACB2F2870020015F3D0 /* IGListPerformDiffTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 22907AC92F2870020015F3D0 /* IGListPerformDiffTests.m */; };
26271C8A1DAE94E40073E116 /* IGTestSingleNibItemDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 26271C891DAE94E40073E116 /* IGTestSingleNibItemDataSource.m */; };
26271C8C1DAE96740073E116 /* IGListSingleNibItemControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 26271C8B1DAE96740073E116 /* IGListSingleNibItemControllerTests.m */; };
290DF3771E9323E6009FE456 /* IGListDebuggerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 290DF3761E9323E6009FE456 /* IGListDebuggerTests.m */; };
Expand Down Expand Up @@ -639,6 +649,11 @@
16B71CE822B0A08300FE96ED /* IGTestInvalidateLayoutDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGTestInvalidateLayoutDataSource.m; sourceTree = "<group>"; };
16B71CE922B0A08300FE96ED /* IGTestInvalidateLayoutObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGTestInvalidateLayoutObject.h; sourceTree = "<group>"; };
16B71CEA22B0A08300FE96ED /* IGTestInvalidateLayoutObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGTestInvalidateLayoutObject.m; sourceTree = "<group>"; };
22907ABC2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IGListViewVisibilityTrackerTests.m; sourceTree = "<group>"; };
22907AC02F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IGListItemUpdatesCollectorTests.m; sourceTree = "<group>"; };
22907AC32F2866160015F3D0 /* IGListUpdateCoalescerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IGListUpdateCoalescerTests.m; sourceTree = "<group>"; };
22907AC62F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIViewControllerIGListAdapterTests.m; sourceTree = "<group>"; };
22907AC92F2870020015F3D0 /* IGListPerformDiffTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IGListPerformDiffTests.m; sourceTree = "<group>"; };
26271C881DAE94E40073E116 /* IGTestSingleNibItemDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGTestSingleNibItemDataSource.h; sourceTree = "<group>"; };
26271C891DAE94E40073E116 /* IGTestSingleNibItemDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGTestSingleNibItemDataSource.m; sourceTree = "<group>"; };
26271C8B1DAE96740073E116 /* IGListSingleNibItemControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListSingleNibItemControllerTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1357,7 +1372,9 @@
88144EE91D870EDC007C7F66 /* IGListDisplayHandlerTests.m */,
29DA5CA21EA7C72400113926 /* IGListGenericSectionControllerTests.m */,
F1ED68AE29E9B3B9003744F8 /* IGListInteractiveMovingTests.m */,
22907AC02F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m */,
88144EEB1D870EDC007C7F66 /* IGListKitTests-Bridging-Header.h */,
22907AC92F2870020015F3D0 /* IGListPerformDiffTests.m */,
F18CC76529EFBC3800DC3B9A /* IGListReloadDataUpdaterTests.m */,
F1E6302229EA43080060B4D6 /* IGListSectionControllerTests.m */,
829D7BA81DD1816400549816 /* IGListSectionMapTests.m */,
Expand All @@ -1368,7 +1385,10 @@
29DA5CA61EA7D37000113926 /* IGListTestCase.m */,
29DA5CAA1EA7D3FF00113926 /* IGListTestHelpers.h */,
F1ED68B029E9B3B9003744F8 /* IGListTransactionTests.m */,
22907AC32F2866160015F3D0 /* IGListUpdateCoalescerTests.m */,
88144EEF1D870EDC007C7F66 /* IGListWorkingRangeHandlerTests.m */,
22907ABC2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m */,
22907AC62F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m */,
887D0B571D870E1E009E01F7 /* Info.plist */,
88144EF01D870EDC007C7F66 /* Objects */,
);
Expand Down Expand Up @@ -1861,7 +1881,7 @@
BuildIndependentTargetsInParallel = YES;
CLASSPREFIX = IG;
LastSwiftUpdateCheck = 1120;
LastUpgradeCheck = 2600;
LastUpgradeCheck = 2620;
ORGANIZATIONNAME = Instagram;
TargetAttributes = {
7A02D01C2361520200B49FAE = {
Expand Down Expand Up @@ -2188,6 +2208,7 @@
828540511DE40D2D00118B94 /* IGListTestAdapterHorizontalDataSource.m in Sources */,
885FE2371DC51B76009CE2B4 /* IGListWorkingRangeHandlerTests.m in Sources */,
8285404D1DE40C6E00118B94 /* IGListTestHorizontalSection.m in Sources */,
22907ACA2F2870020015F3D0 /* IGListPerformDiffTests.m in Sources */,
298DDA061E3AE2B000F76F50 /* IGTestNumberBindableCell.m in Sources */,
885FE2381DC51B86009CE2B4 /* IGListTestAdapterDataSource.m in Sources */,
F1ED68B529E9B3B9003744F8 /* IGListDebugDescriptionTests.m in Sources */,
Expand All @@ -2197,9 +2218,11 @@
F1ED68B729E9B3B9003744F8 /* IGListTransactionTests.m in Sources */,
F1ED68BE29E9B41A003744F8 /* IGListContentInsetTests.m in Sources */,
5766613F2CB5A72500E20F73 /* IGListAdapterDelegateAnnouncerTests.m in Sources */,
22907ABD2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m in Sources */,
885FE2421DC51B86009CE2B4 /* IGTestSingleStoryboardItemDataSource.m in Sources */,
885FE2301DC51B76009CE2B4 /* IGListDiffTests.m in Sources */,
885FE22E1DC51B76009CE2B4 /* IGListBatchUpdateDataTests.m in Sources */,
22907AC72F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m in Sources */,
298DDA3C1E3B170300F76F50 /* IGLayoutTestSection.m in Sources */,
298DDA0A1E3AE31E00F76F50 /* IGTestDiffingSectionController.m in Sources */,
29C4748D1DDF45F900AE68CE /* IGListAdapterProxyTests.m in Sources */,
Expand All @@ -2219,7 +2242,9 @@
885FE2431DC51B86009CE2B4 /* IGTestStoryboardViewController.m in Sources */,
F1ED68BC29E9B411003744F8 /* IGListDebuggerTests.m in Sources */,
885FE23A1DC51B86009CE2B4 /* IGListTestSection.m in Sources */,
22907AC52F2866160015F3D0 /* IGListUpdateCoalescerTests.m in Sources */,
29C579301DE0DA8A003A149B /* IGListTestStoryboardSection.m in Sources */,
22907AC22F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m in Sources */,
885FE23E1DC51B86009CE2B4 /* IGTestDelegateDataSource.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -2314,6 +2339,7 @@
13DF01771FA1000E0092A320 /* IGTestReorderableSection.m in Sources */,
829D7BAA1DD1819000549816 /* IGListSectionMapTests.m in Sources */,
F1ED68BD29E9B415003744F8 /* IGListDebugDescriptionTests.m in Sources */,
22907ACB2F2870020015F3D0 /* IGListPerformDiffTests.m in Sources */,
E56B7B3420A9D7100071010C /* IGListCollectionScrollingTraitsTests.m in Sources */,
16B71CEB22B0A08400FE96ED /* IGTestInvalidateLayoutSectionController.m in Sources */,
29C5792E1DE0DA89003A149B /* IGTestNibSupplementaryView.m in Sources */,
Expand All @@ -2323,9 +2349,11 @@
821BC4D31DB981AB00172ED0 /* IGTestSingleStoryboardItemDataSource.m in Sources */,
298DDA3D1E3B170400F76F50 /* IGLayoutTestSection.m in Sources */,
5766613E2CB5A72500E20F73 /* IGListAdapterDelegateAnnouncerTests.m in Sources */,
22907ABE2F2862830015F3D0 /* IGListViewVisibilityTrackerTests.m in Sources */,
298DDA091E3AE31D00F76F50 /* IGTestDiffingSectionController.m in Sources */,
88144F151D870EDC007C7F66 /* IGListTestSection.m in Sources */,
82914C5B1E6E2DEC0066C2F8 /* IGListTestContainerSizeSection.m in Sources */,
22907AC82F28679B0015F3D0 /* UIViewControllerIGListAdapterTests.m in Sources */,
29DA5CA71EA7D37000113926 /* IGListTestCase.m in Sources */,
88144F1D1D870EDC007C7F66 /* IGTestSupplementarySource.m in Sources */,
F18CC76629EFBC3800DC3B9A /* IGListReloadDataUpdaterTests.m in Sources */,
Expand All @@ -2345,7 +2373,9 @@
F18CC75C29EFBB9400DC3B9A /* IGListCollectionViewTests.m in Sources */,
8240C7F81DC2F3FB00B3AAE7 /* IGListTestStoryboardSection.m in Sources */,
F18CC76329EFBBE200DC3B9A /* IGTestBindingSingleItemDataSource.m in Sources */,
22907AC42F2866160015F3D0 /* IGListUpdateCoalescerTests.m in Sources */,
26271C8A1DAE94E40073E116 /* IGTestSingleNibItemDataSource.m in Sources */,
22907AC12F2864450015F3D0 /* IGListItemUpdatesCollectorTests.m in Sources */,
6A9EB3611F841E5D0070C572 /* IGTestSingleWithoutDeselectionDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
LastUpgradeVersion = "2620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
LastUpgradeVersion = "2620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
LastUpgradeVersion = "2620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 9 additions & 1 deletion Source/IGListKit/IGListAdapterUpdaterDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,16 @@ willPerformBatchUpdatesWithCollectionView:(UICollectionView *)collectionView
diffResult:(IGListIndexSetResult *)diffResult
updates:(IGListBatchUpdateData *)updates;

/**
Notifies the delegate that the updater detected an imminent crash, such as when a section controller returns a nil cell.
This provides an opportunity to log diagnostic information before the crash occurs.

@param listAdapterUpdater The adapter updater that detected the issue.
@param collectionView The collection view involved in the crash.
@param sectionControllerClass The class of the section controller that caused the issue, if available.
*/
- (void) listAdapterUpdater:(IGListAdapterUpdater *)listAdapterUpdater
willCrashWithCollectionView:collectionView
willCrashWithCollectionView:(UICollectionView *)collectionView
sectionControllerClass:(nullable Class)sectionControllerClass;

/**
Expand Down
7 changes: 7 additions & 0 deletions Source/IGListKit/IGListUpdatingDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ NS_SWIFT_NAME(ListUpdatingDelegate)
*/
- (BOOL)isInDataUpdateBlock;

/**
Called when the updater detects an imminent crash, such as when a section controller returns a nil cell.
This provides an opportunity to log diagnostic information before the crash occurs.

@param collectionView The collection view involved in the crash.
@param sectionControllerClass The class of the section controller that caused the issue, if available.
*/
- (void)willCrashWithCollectionView:(UICollectionView *)collectionView
sectionControllerClass:(nullable Class)sectionControllerClass;

Expand Down
25 changes: 25 additions & 0 deletions Tests/IGListAdapterDelegateAnnouncerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@ - (void)test_whenRemovignOneItem_withTwoListeners_withOneAdapter_thatBothListene
[self waitForExpectationsWithTimeout:30 handler:nil];
}

#pragma mark - Remove listener

- (void)test_whenRemovingListener_thatListenerDoesNotReceiveCallbacks {
[self setupAdapter1WithObjects:@[]];

IGTestObject *const object = genTestObject(@1, @1);
self.dataSource1.objects = @[object];

id mockDisplayHandler = [OCMockObject mockForProtocol:@protocol(IGListAdapterDelegate)];
[self.announcer addListener:mockDisplayHandler];
[self.announcer removeListener:mockDisplayHandler];

// Listener was removed, so it should NOT receive any callbacks
[[mockDisplayHandler reject] listAdapter:[OCMArg any] willDisplayObject:[OCMArg any] atIndex:0];
[[mockDisplayHandler reject] listAdapter:[OCMArg any] willDisplayObject:[OCMArg any] cell:[OCMArg any] atIndexPath:[OCMArg any]];

XCTestExpectation *expectation = genExpectation;
[self.adapter1 performUpdatesAnimated:NO completion:^(BOOL finished) {
[mockDisplayHandler verify];
XCTAssertTrue(finished);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:30 handler:nil];
}

#pragma mark - Two adapters, single listener

- (void)test_whenShowingTwoItems_withOneListeners_withTwoAdapters_thatBothItemsSendWillDisplay {
Expand Down
112 changes: 112 additions & 0 deletions Tests/IGListAdapterE2ETests.m
Original file line number Diff line number Diff line change
Expand Up @@ -2727,4 +2727,116 @@ - (void)test_whenPerformingUpdates_withAdaptiveCoalescing_thatCollectionViewCoun
[self waitForExpectationsWithTimeout:30 handler:nil];
}

- (void)test_whenPerformingUpdates_withAdaptiveDiffingHigherQOS_thatCollectionViewUpdates {
IGListAdapterUpdater *updater = (IGListAdapterUpdater *)self.updater;
updater.allowsBackgroundDiffing = YES;
updater.adaptiveDiffingExperimentConfig = (IGListAdaptiveDiffingExperimentConfig) {
.enabled = YES,
.higherQOSEnabled = YES,
.maxItemCountToRunOnMain = 0,
.lowerPriorityWhenViewNotVisible = NO
};

[self setupWithObjects:@[
genTestObject(@1, @1),
genTestObject(@2, @2),
]];

self.dataSource.objects = @[
genTestObject(@2, @2),
genTestObject(@3, @3),
];

XCTestExpectation *expectation = genExpectation;
[self.adapter performUpdatesAnimated:YES completion:^(BOOL finished) {
XCTAssertEqual([self.collectionView numberOfSections], 2);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:30 handler:nil];
}

- (void)test_whenPerformingUpdates_withAdaptiveDiffingLowerPriorityWhenNotVisible_thatCollectionViewUpdates {
IGListAdapterUpdater *updater = (IGListAdapterUpdater *)self.updater;
updater.allowsBackgroundDiffing = YES;
updater.adaptiveDiffingExperimentConfig = (IGListAdaptiveDiffingExperimentConfig) {
.enabled = YES,
.higherQOSEnabled = NO,
.maxItemCountToRunOnMain = 0,
.lowerPriorityWhenViewNotVisible = YES
};

// Remove from window to make it "not visible"
[self.collectionView removeFromSuperview];

[self setupWithObjects:@[
genTestObject(@1, @1),
genTestObject(@2, @2),
]];

self.dataSource.objects = @[
genTestObject(@2, @2),
genTestObject(@3, @3),
];

XCTestExpectation *expectation = genExpectation;
[self.adapter performUpdatesAnimated:NO completion:^(BOOL finished) {
XCTAssertEqual([self.collectionView numberOfSections], 2);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:30 handler:nil];
}

- (void)test_whenPerformingUpdates_withAdaptiveDiffingSmallItemCount_thatDiffRunsOnMain {
IGListAdapterUpdater *updater = (IGListAdapterUpdater *)self.updater;
updater.allowsBackgroundDiffing = YES;
updater.adaptiveDiffingExperimentConfig = (IGListAdaptiveDiffingExperimentConfig) {
.enabled = YES,
.higherQOSEnabled = NO,
.maxItemCountToRunOnMain = 100, // Item count is under this threshold
.lowerPriorityWhenViewNotVisible = NO
};

[self setupWithObjects:@[
genTestObject(@1, @1),
]];

self.dataSource.objects = @[
genTestObject(@1, @1),
genTestObject(@2, @2),
];

XCTestExpectation *expectation = genExpectation;
[self.adapter performUpdatesAnimated:YES completion:^(BOOL finished) {
XCTAssertEqual([self.collectionView numberOfSections], 2);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:30 handler:nil];
}

- (void)test_whenPerformingUpdates_withAdaptiveDiffingBackgroundDisabled_thatDiffRunsOnMain {
IGListAdapterUpdater *updater = (IGListAdapterUpdater *)self.updater;
updater.allowsBackgroundDiffing = NO;
updater.adaptiveDiffingExperimentConfig = (IGListAdaptiveDiffingExperimentConfig) {
.enabled = YES,
.higherQOSEnabled = YES,
.maxItemCountToRunOnMain = 0,
.lowerPriorityWhenViewNotVisible = YES
};

[self setupWithObjects:@[
genTestObject(@1, @1),
]];

self.dataSource.objects = @[
genTestObject(@2, @2),
];

XCTestExpectation *expectation = genExpectation;
[self.adapter performUpdatesAnimated:YES completion:^(BOOL finished) {
XCTAssertEqual([self.collectionView numberOfSections], 1);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:30 handler:nil];
}

@end
Loading