mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Add assertion for invalid constrainedSize in calculateSizeThatFits: (#2507)
This commit is contained in:
committed by
Adlai Holler
parent
09168ceee0
commit
c4451edab1
@@ -2151,21 +2151,4 @@ static bool stringContainsPointer(NSString *description, id p) {
|
||||
XCTAssertThrowsSpecificNamed([node calculateLayoutThatFits:ASSizeRangeMake(CGSizeMake(100, 100))], NSException, NSInternalInconsistencyException);
|
||||
}
|
||||
|
||||
- (void)testThatLayoutWithInvalidSizeCausesException
|
||||
{
|
||||
ASDisplayNode *displayNode = [[ASDisplayNode alloc] init];
|
||||
ASDisplayNode *node = [[ASDisplayNode alloc] init];
|
||||
node.layoutSpecBlock = ^ASLayoutSpec *(ASDisplayNode *node, ASSizeRange constrainedSize) {
|
||||
return [ASWrapperLayoutSpec wrapperWithLayoutElement:displayNode];
|
||||
};
|
||||
|
||||
XCTAssertThrows([node layoutThatFits:ASSizeRangeMake(CGSizeMake(0, FLT_MAX))]);
|
||||
|
||||
// This dance is necessary as we would assert in case we create an ASDimension that is not real numbers
|
||||
ASDimension width = displayNode.style.width;
|
||||
width.value = INFINITY;
|
||||
displayNode.style.width = width;
|
||||
XCTAssertThrows([node layoutThatFits:ASSizeRangeMake(CGSizeMake(0, 0), CGSizeMake(INFINITY, INFINITY))]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user