[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:
Michael Schneider
2016-10-28 15:39:03 -07:00
committed by GitHub
parent e4a2637804
commit fb92b448e0
6 changed files with 37 additions and 20 deletions

View File

@@ -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