Add unit test. Fix the layout for non-UIView subclasses
This commit is contained in:
@@ -306,7 +306,8 @@ static YGSize YGMeasureView(
|
|||||||
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
|
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
|
||||||
CGSize sizeThatFits = CGSizeZero;
|
CGSize sizeThatFits = CGSizeZero;
|
||||||
|
|
||||||
if ([view.subviews count] > 0) {
|
// Fix for https://github.com/facebook/yoga/issues/606
|
||||||
|
if (![view isMemberOfClass:[UIView class]] || [view.subviews count] > 0) {
|
||||||
sizeThatFits = [view sizeThatFits:(CGSize) {
|
sizeThatFits = [view sizeThatFits:(CGSize) {
|
||||||
.width = constrainedWidth,
|
.width = constrainedWidth,
|
||||||
.height = constrainedHeight,
|
.height = constrainedHeight,
|
||||||
|
@@ -129,6 +129,16 @@
|
|||||||
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
|
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)testSizeThatFitsEmptyView
|
||||||
|
{
|
||||||
|
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
|
||||||
|
view.yoga.isEnabled = YES;
|
||||||
|
|
||||||
|
const CGSize viewSize = view.yoga.intrinsicSize;
|
||||||
|
XCTAssertEqual(viewSize.height, 0);
|
||||||
|
XCTAssertEqual(viewSize.width, 0);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)testPreservingOrigin
|
- (void)testPreservingOrigin
|
||||||
{
|
{
|
||||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];
|
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];
|
||||||
|
Reference in New Issue
Block a user