Refine and add code coverage for trait collection in collection context

Summary:
Now that the inconsistency exception is being wrapped up, I'm going to move forward with a public release some more. I'm going to go through and make sure everything is up-to-date in the GitHub repo.

This diff adds code coverage to the new trait collection exposure API in `IGListCollectionContext`. It also adds document-generating compatible commenting and positions it at a more appropriate ordering in the header.

Reviewed By: zats

Differential Revision: D51146049

fbshipit-source-id: 2d7ecc8fa042006ef4fd70451b9ab7ba6d0a66bb
This commit is contained in:
Tim Oliver 2023-11-13 09:50:13 -08:00 committed by Facebook GitHub Bot
parent b7f309727d
commit a4bae43471
3 changed files with 12 additions and 3 deletions

View file

@ -978,7 +978,7 @@ typedef struct OffsetRange {
return self.collectionView.bounds.size;
}
- (UITraitCollection *_Nullable)traitCollection {
- (UITraitCollection *)traitCollection {
return self.collectionView.traitCollection;
}

View file

@ -26,8 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
NS_SWIFT_NAME(ListCollectionContext)
@protocol IGListCollectionContext <NSObject>
@property (nonatomic, nullable, readonly) UITraitCollection *traitCollection;
/**
The size of the collection view. You can use this for sizing cells.
*/
@ -53,6 +51,11 @@ NS_SWIFT_NAME(ListCollectionContext)
*/
@property (nonatomic, readonly) CGPoint containerContentOffset;
/**
The trait collection of the collection view.
*/
@property (nonatomic, nullable, readonly) UITraitCollection *traitCollection;
/**
The current scrolling traits of the underlying collection view.
*/

View file

@ -1736,6 +1736,12 @@
XCTAssertEqual(size.height, 0.0);
}
- (void)test_whenQueryingTraitCollection_thatMatchesCollectionView {
self.dataSource.objects = @[@2];
[self.adapter reloadDataWithCompletion:nil];
XCTAssertEqual(self.adapter.traitCollection, self.collectionView.traitCollection);
}
- (void)test_whenQueryingContainerInset_thatMatchesCollectionView {
self.dataSource.objects = @[@2];
[self.adapter reloadDataWithCompletion:nil];