mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 04:08:07 +00:00
Test relayout caused by a different constrained size for each and every node. All nodes, including loading ones, must be re-measured.
This commit is contained in:
parent
60cf43766b
commit
3e5d5c44cb
@ -202,4 +202,44 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)testRelayoutAllRows
|
||||||
|
{
|
||||||
|
// Initial width of the table view is 0 and all nodes are measured with this size.
|
||||||
|
ASTestTableView *tableView = [[ASTestTableView alloc] initWithFrame:CGRectMake(0, 0, 0, 500)
|
||||||
|
style:UITableViewStylePlain
|
||||||
|
asyncDataFetching:YES];
|
||||||
|
CGSize tableViewFinalSize = CGSizeMake(100, 500);
|
||||||
|
|
||||||
|
ASTableViewFilledDataSource *dataSource = [ASTableViewFilledDataSource new];
|
||||||
|
|
||||||
|
tableView.asyncDelegate = dataSource;
|
||||||
|
tableView.asyncDataSource = dataSource;
|
||||||
|
|
||||||
|
[tableView reloadData];
|
||||||
|
|
||||||
|
[tableView beginUpdates];
|
||||||
|
|
||||||
|
tableView.frame = CGRectMake(0, 0, tableViewFinalSize.width, tableViewFinalSize.height);
|
||||||
|
[tableView layoutIfNeeded];
|
||||||
|
|
||||||
|
XCTestExpectation *nodesMeasuredUsingNewConstrainedSizeExpectation = [self expectationWithDescription:@"nodesMeasuredUsingNewConstrainedSize"];
|
||||||
|
|
||||||
|
[tableView endUpdatesAnimated:NO completion:^(BOOL completed) {
|
||||||
|
for (int section = 0; section < NumberOfSections; section++) {
|
||||||
|
for (int row = 0; row < NumberOfRowsPerSection; row++) {
|
||||||
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
|
||||||
|
ASCellNode *node = [tableView nodeForRowAtIndexPath:indexPath];
|
||||||
|
XCTAssertEqual(node.constrainedSizeForCalculatedLayout.max.width, tableViewFinalSize.width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[nodesMeasuredUsingNewConstrainedSizeExpectation fulfill];
|
||||||
|
}];
|
||||||
|
|
||||||
|
[self waitForExpectationsWithTimeout:5 handler:^(NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
XCTFail(@"Expectation failed: %@", error);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user