diff --git a/packages/react-native/ReactCommon/yoga/test/BaselineTest.cpp b/packages/react-native/ReactCommon/yoga/test/BaselineTest.cpp index be93bd6cfdeb..367db4e0986e 100644 --- a/packages/react-native/ReactCommon/yoga/test/BaselineTest.cpp +++ b/packages/react-native/ReactCommon/yoga/test/BaselineTest.cpp @@ -446,12 +446,11 @@ TEST(MinContentTest, testWalkClonesOnlyTheChildrenItWritesTo) { MeasureCalls paddedCalls; MeasureCalls stableCalls; YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetWidth(root, 300); YGNodeStyleSetHeight(root, 100); YGNodeRef item = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(item, 50); - YGNodeStyleSetHeight(item, 200); + YGNodeStyleSetFlexBasis(item, 100); YGNodeStyleSetFlexShrink(item, 1); YGNodeInsertChild(root, item, 0); YGNodeRef padded = YGNodeNewWithConfig(config); @@ -469,24 +468,28 @@ TEST(MinContentTest, testWalkClonesOnlyTheChildrenItWritesTo) { YGNodeInsertChild(item, absolute, 3); YGNodeRef staticLeaf = YGNodeNewWithConfig(config); YGNodeSetMeasureFunc(staticLeaf, measureUncounted); - YGNodeSetMinContentWidth(staticLeaf, 20); + YGNodeSetMinContentWidth(staticLeaf, 100); YGNodeSetMinContentHeight(staticLeaf, 5); YGNodeInsertChild(item, staticLeaf, 4); YGNodeRef empty = YGNodeNewWithConfig(config); YGNodeInsertChild(item, empty, 5); YGNodeRef sibling = YGNodeNewWithConfig(config); - YGNodeStyleSetHeight(sibling, 200); + YGNodeStyleSetFlexBasis(sibling, 300); YGNodeStyleSetFlexShrink(sibling, 1); YGNodeInsertChild(root, sibling, 1); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - // Only `padded`'s memo is keyed on the width, so a narrower second tree walks - // it again and only reads the item's other children and `padded`'s leaf. + // The static leaf keeps the item 100 wide in a narrower second tree, so the + // item's layout comes from cache and only the walk reaches its children. + // The width walk resolves `padded`'s percentage against the root's width, so + // only its memo is keyed on that width: the walk walks it again and only + // reads the item's other children and `padded`'s leaf. YGNodeRef rootCopy = YGNodeClone(root); YGNodeStyleSetWidth(rootCopy, 290); YGNodeCalculateLayout(rootCopy, YGUndefined, YGUndefined, YGDirectionLTR); const YGNodeRef itemCopy = YGNodeGetChild(rootCopy, 0); + EXPECT_FLOAT_EQ(100.0f, YGNodeLayoutGetWidth(itemCopy)); EXPECT_NE(padded, YGNodeGetChild(itemCopy, 0)); EXPECT_EQ(paddedLeaf, YGNodeGetChild(YGNodeGetChild(itemCopy, 0), 0)); EXPECT_EQ(stable, YGNodeGetChild(itemCopy, 1));