mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[ASDisplayNode] Proper handling of constrainedSize (#2505)
* Check in ASLayout if size is valid for sizing instead of valid for layout * Return constrainedSize from calculateSizeThatFits: Remove invalid constrainedSize check within ASNetworkImageNode. Furthermore as ASDisplayNode does not return CGSizeZero anymore we have to give the display nodes we use in tests and are involving a stack spec an intrinsic content size. * Remove extra constrainedSize handling in ASNetworkImageNode handling * Change test to use FLT_MAX
This commit is contained in:
committed by
GitHub
parent
e4a2637804
commit
fb92b448e0
@@ -2151,4 +2151,21 @@ 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