Add Sizing API that doesn't change view's frame.

Summary: This exposes an API so people can find out the resulting size of a layout calculation without changing the frame of the view.

Reviewed By: emilsjolander

Differential Revision: D4124630

fbshipit-source-id: f2b28d8a5474857cb1c92e021a1f161806826cda
This commit is contained in:
Dustin Shahidehpour
2016-11-03 13:00:02 -07:00
committed by Facebook Github Bot
parent 630ae0972b
commit b938017ccf
3 changed files with 40 additions and 8 deletions

View File

@@ -58,4 +58,24 @@
XCTAssertFalse([view css_usesFlexbox]);
}
- (void)testSizeThatFitsAsserts
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertThrows([view css_sizeThatFits:CGSizeZero]);
dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){
XCTAssertThrows([view css_sizeThatFits:CGSizeZero]);
});
}
- (void)testSizeThatFitsSmoke
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view css_setUsesFlexbox:YES];
const CGSize constrainedSize = CGSizeMake(50, 50);
const CGSize actualSize = [view css_sizeThatFits:constrainedSize];
XCTAssertTrue(CGSizeEqualToSize(constrainedSize, actualSize), @"Actual Size: %@", NSStringFromCGSize(actualSize));
}
@end