Fix percentage calculation when parent size is undefined
Summary: If parent size was undefined and node specified percentage size it would pass does an exact measure mode with an undefined value which broke an assertion. Reviewed By: gkassabli Differential Revision: D4494265 fbshipit-source-id: 9efef9e39a1b66af2d0f144575a96c919d60dbf7
This commit is contained in:
committed by
Facebook Github Bot
parent
4227e36ca5
commit
cfeac79130
@@ -917,3 +917,37 @@ TEST(YogaTest, percentage_absolute_position) {
|
||||
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
TEST(YogaTest, percentage_width_height_undefined_parent_size) {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeStyleSetWidthPercent(root_child0, 50);
|
||||
YGNodeStyleSetHeightPercent(root_child0, 50);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
}
|
||||
|
Reference in New Issue
Block a user