Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 2 additions & 0 deletions Source/ASCollectionNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ - (instancetype)init
_flags.inverted = NO;
_contentInset = UIEdgeInsetsZero;
_contentOffset = CGPointZero;
_leadingScreensForBatching = 2.0;
_flags.animatesContentOffset = NO;
_flags.showsVerticalScrollIndicator = YES;
_flags.showsHorizontalScrollIndicator = YES;
Expand Down Expand Up @@ -323,6 +324,7 @@ - (void)didLoad
view.layoutInspector = pendingState.layoutInspector;
view.showsVerticalScrollIndicator = pendingState.showsVerticalScrollIndicator;
view.showsHorizontalScrollIndicator = pendingState.showsHorizontalScrollIndicator;
view.leadingScreensForBatching = pendingState.leadingScreensForBatching;
#if !TARGET_OS_TV
view.pagingEnabled = pendingState.pagingEnabled;
#endif
Expand Down
1 change: 1 addition & 0 deletions Source/ASTableNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ - (void)didLoad
view.allowsMultipleSelection = pendingState.allowsMultipleSelection;
view.allowsMultipleSelectionDuringEditing = pendingState.allowsMultipleSelectionDuringEditing;
view.automaticallyAdjustsContentOffset = pendingState.automaticallyAdjustsContentOffset;
view.leadingScreensForBatching = pendingState.leadingScreensForBatching;
#if !TARGET_OS_TV
view.pagingEnabled = pendingState.pagingEnabled;
#endif
Expand Down
59 changes: 59 additions & 0 deletions Tests/ASCollectionViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1299,4 +1299,63 @@ - (void)DISABLED_testThatAutomaticallyManagedSubnodesGetPreloadCallBeforeDisplay

}

- (void)testAllPendingStatePropertiesTransferredToView {
// Create node without loading view
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
ASCollectionNode *node = [[ASCollectionNode alloc] initWithFrame:CGRectZero
collectionViewLayout:layout];

XCTAssertFalse(node.isNodeLoaded, @"View should not be loaded before setting properties");

// Set pending state properties before view loads
node.leadingScreensForBatching = 3.6;
node.inverted = YES;
node.allowsMultipleSelection = YES;
node.alwaysBounceVertical = YES;
node.alwaysBounceHorizontal = YES;
node.pagingEnabled = YES;
node.showsVerticalScrollIndicator = NO;
node.showsHorizontalScrollIndicator = NO;
UIEdgeInsets testInsets = UIEdgeInsetsMake(10, 20, 30, 40);
node.contentInset = testInsets;
CGPoint testOffset = CGPointMake(50, 60);
node.contentOffset = testOffset;
ASCollectionViewTestDelegate *delegate = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:10 numberOfItemsInSection:10];
node.delegate = delegate;
ASCollectionViewTestDelegate *dataSource = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:20 numberOfItemsInSection:20];
node.dataSource = dataSource;


// Load the view (triggers pending state transfer)
ASCollectionView *view = node.view;

XCTAssertTrue(node.isNodeLoaded, @"View should be loaded after accessing node.view");

// Verify properties were transferred correctly
XCTAssertEqual(view.leadingScreensForBatching, 3.6,
@"leadingScreensForBatching should transfer from pending state");
XCTAssertEqual(view.inverted, YES,
@"inverted should transfer from pending state");
XCTAssertEqual(view.allowsMultipleSelection, YES,
@"allowsMultipleSelection should transfer from pending state");
XCTAssertEqual(view.alwaysBounceVertical, YES,
@"alwaysBounceVertical should transfer from pending state");
XCTAssertEqual(view.alwaysBounceHorizontal, YES,
@"alwaysBounceHorizontal should transfer from pending state");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(view.contentInset, testInsets),
@"contentInset should transfer from pending state");
XCTAssertTrue(CGPointEqualToPoint(view.contentOffset, testOffset),
@"contentOffset should transfer from pending state");
XCTAssertEqual(view.showsVerticalScrollIndicator, NO,
@"showsVerticalScrollIndicator should transfer from pending state");
XCTAssertEqual(view.showsHorizontalScrollIndicator, NO,
@"showsHorizontalScrollIndicator should transfer from pending state");
XCTAssertEqual(view.pagingEnabled, YES,
@"pagingEnabled should transfer from pending state");
XCTAssertEqual(view.asyncDelegate, delegate,
@"delegate should transfer from pending state");
XCTAssertEqual(view.asyncDataSource, dataSource,
@"dataSource should transfer from pending state");
}

@end
53 changes: 53 additions & 0 deletions Tests/ASTableViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1049,4 +1049,57 @@ - (void)testTintColorIsPropagatedToTableViewCell
XCTAssertTrue(areColorsEqual);
}

- (void)testAllPendingStatePropertiesTransferredToView {
// Create node without loading view
ASTableNode *node = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];

XCTAssertFalse(node.isNodeLoaded, @"View should not be loaded before setting properties");

// Set pending state properties before view loads
node.leadingScreensForBatching = 3.6;
node.inverted = YES;
node.allowsSelectionDuringEditing = YES;
node.allowsMultipleSelection = YES;
node.allowsMultipleSelectionDuringEditing = YES;
node.pagingEnabled = YES;
node.automaticallyAdjustsContentOffset = NO;
UIEdgeInsets testInsets = UIEdgeInsetsMake(10, 20, 30, 40);
node.contentInset = testInsets;
CGPoint testOffset = CGPointMake(50, 60);
node.contentOffset = testOffset;
ASTableViewFilledDelegate *delegate = [ASTableViewFilledDelegate new];
node.delegate = delegate;
ASTableViewFilledDataSource *dataSource = [ASTableViewFilledDataSource new];
node.dataSource = dataSource;

// Load the view (triggers pending state transfer)
ASTableView *view = node.view;

XCTAssertTrue(node.isNodeLoaded, @"View should be loaded after accessing node.view");

// Verify properties were transferred correctly
XCTAssertEqual(view.leadingScreensForBatching, 3.6,
@"leadingScreensForBatching should transfer from pending state");
XCTAssertEqual(view.inverted, YES,
@"inverted should transfer from pending state");
XCTAssertEqual(view.allowsSelectionDuringEditing, YES,
@"allowsSelectionDuringEditing should transfer from pending state");
XCTAssertEqual(view.allowsMultipleSelection, YES,
@"allowsMultipleSelection should transfer from pending state");
XCTAssertEqual(view.allowsMultipleSelectionDuringEditing, YES,
@"allowsMultipleSelectionDuringEditing should transfer from pending state");
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(view.contentInset, testInsets),
@"contentInset should transfer from pending state");
XCTAssertTrue(CGPointEqualToPoint(view.contentOffset, testOffset),
@"contentOffset should transfer from pending state");
XCTAssertEqual(view.automaticallyAdjustsContentOffset, NO,
@"automaticallyAdjustsContentOffset should transfer from pending state");
XCTAssertEqual(view.pagingEnabled, YES,
@"pagingEnabled should transfer from pending state");
XCTAssertEqual(view.asyncDelegate, delegate,
@"delegate should transfer from pending state");
XCTAssertEqual(view.asyncDataSource, dataSource,
@"dataSource should transfer from pending state");
}

@end
Loading