diff --git a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs index cc3a74ab..7b150568 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs @@ -1815,148 +1815,5 @@ namespace Facebook.Yoga Assert.AreEqual(72f, root_child0_child0.LayoutHeight); } - [Test] - public void Test_align_center_should_size_based_on_content() - { - YogaConfig config = new YogaConfig(); - - YogaNode root = new YogaNode(config); - root.AlignItems = YogaAlign.Center; - root.MarginTop = 20; - root.Width = 100; - root.Height = 100; - - YogaNode root_child0 = new YogaNode(config); - root_child0.JustifyContent = YogaJustify.Center; - root_child0.FlexShrink = 1; - root.Insert(0, root_child0); - - YogaNode root_child0_child0 = new YogaNode(config); - root_child0_child0.FlexGrow = 1; - root_child0_child0.FlexShrink = 1; - root_child0.Insert(0, root_child0_child0); - - YogaNode root_child0_child0_child0 = new YogaNode(config); - root_child0_child0_child0.Width = 20; - root_child0_child0_child0.Height = 20; - root_child0_child0.Insert(0, root_child0_child0_child0); - root.StyleDirection = YogaDirection.LTR; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(20f, root.LayoutY); - Assert.AreEqual(100f, root.LayoutWidth); - Assert.AreEqual(100f, root.LayoutHeight); - - Assert.AreEqual(40f, root_child0.LayoutX); - Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(20f, root_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0.LayoutY); - Assert.AreEqual(20f, root_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child0_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0_child0.LayoutY); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight); - - root.StyleDirection = YogaDirection.RTL; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(20f, root.LayoutY); - Assert.AreEqual(100f, root.LayoutWidth); - Assert.AreEqual(100f, root.LayoutHeight); - - Assert.AreEqual(40f, root_child0.LayoutX); - Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(20f, root_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0.LayoutY); - Assert.AreEqual(20f, root_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child0_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0_child0.LayoutY); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight); - } - - [Test] - public void Test_align_strech_should_size_based_on_parent() - { - YogaConfig config = new YogaConfig(); - - YogaNode root = new YogaNode(config); - root.MarginTop = 20; - root.Width = 100; - root.Height = 100; - - YogaNode root_child0 = new YogaNode(config); - root_child0.JustifyContent = YogaJustify.Center; - root_child0.FlexShrink = 1; - root.Insert(0, root_child0); - - YogaNode root_child0_child0 = new YogaNode(config); - root_child0_child0.FlexGrow = 1; - root_child0_child0.FlexShrink = 1; - root_child0.Insert(0, root_child0_child0); - - YogaNode root_child0_child0_child0 = new YogaNode(config); - root_child0_child0_child0.Width = 20; - root_child0_child0_child0.Height = 20; - root_child0_child0.Insert(0, root_child0_child0_child0); - root.StyleDirection = YogaDirection.LTR; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(20f, root.LayoutY); - Assert.AreEqual(100f, root.LayoutWidth); - Assert.AreEqual(100f, root.LayoutHeight); - - Assert.AreEqual(0f, root_child0.LayoutX); - Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(100f, root_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0.LayoutY); - Assert.AreEqual(100f, root_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child0_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0_child0.LayoutY); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight); - - root.StyleDirection = YogaDirection.RTL; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(20f, root.LayoutY); - Assert.AreEqual(100f, root.LayoutWidth); - Assert.AreEqual(100f, root.LayoutHeight); - - Assert.AreEqual(0f, root_child0.LayoutX); - Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(100f, root_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0.LayoutY); - Assert.AreEqual(100f, root_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0.LayoutHeight); - - Assert.AreEqual(80f, root_child0_child0_child0.LayoutX); - Assert.AreEqual(0f, root_child0_child0_child0.LayoutY); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutWidth); - Assert.AreEqual(20f, root_child0_child0_child0.LayoutHeight); - } - } } diff --git a/gentest/fixtures/YGAlignItemsTest.html b/gentest/fixtures/YGAlignItemsTest.html index c7b3df1a..2c88c306 100644 --- a/gentest/fixtures/YGAlignItemsTest.html +++ b/gentest/fixtures/YGAlignItemsTest.html @@ -167,20 +167,3 @@
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
- diff --git a/java/tests/com/facebook/yoga/YGAlignItemsTest.java b/java/tests/com/facebook/yoga/YGAlignItemsTest.java index 15d7d842..cea82fb5 100644 --- a/java/tests/com/facebook/yoga/YGAlignItemsTest.java +++ b/java/tests/com/facebook/yoga/YGAlignItemsTest.java @@ -1791,145 +1791,4 @@ public class YGAlignItemsTest { assertEquals(72f, root_child0_child0.getLayoutHeight(), 0.0f); } - @Test - public void test_align_center_should_size_based_on_content() { - YogaConfig config = new YogaConfig(); - - final YogaNode root = new YogaNode(config); - root.setAlignItems(YogaAlign.CENTER); - root.setMargin(YogaEdge.TOP, 20f); - root.setWidth(100f); - root.setHeight(100f); - - final YogaNode root_child0 = new YogaNode(config); - root_child0.setJustifyContent(YogaJustify.CENTER); - root_child0.setFlexShrink(1f); - root.addChildAt(root_child0, 0); - - final YogaNode root_child0_child0 = new YogaNode(config); - root_child0_child0.setFlexGrow(1f); - root_child0_child0.setFlexShrink(1f); - root_child0.addChildAt(root_child0_child0, 0); - - final YogaNode root_child0_child0_child0 = new YogaNode(config); - root_child0_child0_child0.setWidth(20f); - root_child0_child0_child0.setHeight(20f); - root_child0_child0.addChildAt(root_child0_child0_child0, 0); - root.setDirection(YogaDirection.LTR); - root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); - - assertEquals(0f, root.getLayoutX(), 0.0f); - assertEquals(20f, root.getLayoutY(), 0.0f); - assertEquals(100f, root.getLayoutWidth(), 0.0f); - assertEquals(100f, root.getLayoutHeight(), 0.0f); - - assertEquals(40f, root_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f); - - root.setDirection(YogaDirection.RTL); - root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); - - assertEquals(0f, root.getLayoutX(), 0.0f); - assertEquals(20f, root.getLayoutY(), 0.0f); - assertEquals(100f, root.getLayoutWidth(), 0.0f); - assertEquals(100f, root.getLayoutHeight(), 0.0f); - - assertEquals(40f, root_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f); - } - - @Test - public void test_align_strech_should_size_based_on_parent() { - YogaConfig config = new YogaConfig(); - - final YogaNode root = new YogaNode(config); - root.setMargin(YogaEdge.TOP, 20f); - root.setWidth(100f); - root.setHeight(100f); - - final YogaNode root_child0 = new YogaNode(config); - root_child0.setJustifyContent(YogaJustify.CENTER); - root_child0.setFlexShrink(1f); - root.addChildAt(root_child0, 0); - - final YogaNode root_child0_child0 = new YogaNode(config); - root_child0_child0.setFlexGrow(1f); - root_child0_child0.setFlexShrink(1f); - root_child0.addChildAt(root_child0_child0, 0); - - final YogaNode root_child0_child0_child0 = new YogaNode(config); - root_child0_child0_child0.setWidth(20f); - root_child0_child0_child0.setHeight(20f); - root_child0_child0.addChildAt(root_child0_child0_child0, 0); - root.setDirection(YogaDirection.LTR); - root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); - - assertEquals(0f, root.getLayoutX(), 0.0f); - assertEquals(20f, root.getLayoutY(), 0.0f); - assertEquals(100f, root.getLayoutWidth(), 0.0f); - assertEquals(100f, root.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0.getLayoutY(), 0.0f); - assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f); - - root.setDirection(YogaDirection.RTL); - root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); - - assertEquals(0f, root.getLayoutX(), 0.0f); - assertEquals(20f, root.getLayoutY(), 0.0f); - assertEquals(100f, root.getLayoutWidth(), 0.0f); - assertEquals(100f, root.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0.getLayoutY(), 0.0f); - assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); - - assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); - assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); - - assertEquals(80f, root_child0_child0_child0.getLayoutX(), 0.0f); - assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f); - assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f); - } - } diff --git a/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js b/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js index 28a9a980..3a95b980 100644 --- a/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js +++ b/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js @@ -1878,152 +1878,3 @@ it("align_items_flex_end_child_without_margin_bigger_than_parent", function () { config.free(); } }); -it("align_center_should_size_based_on_content", function () { - var config = Yoga.Config.create(); - - try { - var root = Yoga.Node.create(config); - root.setAlignItems(Yoga.ALIGN_CENTER); - root.setMargin(Yoga.EDGE_TOP, 20); - root.setWidth(100); - root.setHeight(100); - - var root_child0 = Yoga.Node.create(config); - root_child0.setJustifyContent(Yoga.JUSTIFY_CENTER); - root_child0.setFlexShrink(1); - root.insertChild(root_child0, 0); - - var root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - - var root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(20); - root_child0_child0_child0.setHeight(20); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); - - console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); - console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")"); - console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); - console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); - - console.assert(40 === root_child0.getComputedLeft(), "40 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); - console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); - - console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")"); - console.assert(20 === root_child0_child0.getComputedWidth(), "20 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")"); - - console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")"); - - root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL); - - console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); - console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")"); - console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); - console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); - - console.assert(40 === root_child0.getComputedLeft(), "40 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); - console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); - - console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")"); - console.assert(20 === root_child0_child0.getComputedWidth(), "20 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")"); - - console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")"); - } finally { - if (typeof root !== "undefined") { - root.freeRecursive(); - } - - config.free(); - } -}); -it("align_strech_should_size_based_on_parent", function () { - var config = Yoga.Config.create(); - - try { - var root = Yoga.Node.create(config); - root.setMargin(Yoga.EDGE_TOP, 20); - root.setWidth(100); - root.setHeight(100); - - var root_child0 = Yoga.Node.create(config); - root_child0.setJustifyContent(Yoga.JUSTIFY_CENTER); - root_child0.setFlexShrink(1); - root.insertChild(root_child0, 0); - - var root_child0_child0 = Yoga.Node.create(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.insertChild(root_child0_child0, 0); - - var root_child0_child0_child0 = Yoga.Node.create(config); - root_child0_child0_child0.setWidth(20); - root_child0_child0_child0.setHeight(20); - root_child0_child0.insertChild(root_child0_child0_child0, 0); - root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); - - console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); - console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")"); - console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); - console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); - - console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); - console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); - - console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")"); - console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")"); - - console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")"); - - root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL); - - console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); - console.assert(20 === root.getComputedTop(), "20 === root.getComputedTop() (" + root.getComputedTop() + ")"); - console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); - console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); - - console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); - console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); - - console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")"); - console.assert(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")"); - - console.assert(80 === root_child0_child0_child0.getComputedLeft(), "80 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")"); - console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedWidth(), "20 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")"); - console.assert(20 === root_child0_child0_child0.getComputedHeight(), "20 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")"); - } finally { - if (typeof root !== "undefined") { - root.freeRecursive(); - } - - config.free(); - } -}); diff --git a/tests/YGAlignItemsTest.cpp b/tests/YGAlignItemsTest.cpp index 33eaab9c..8fe2deff 100644 --- a/tests/YGAlignItemsTest.cpp +++ b/tests/YGAlignItemsTest.cpp @@ -1809,146 +1809,3 @@ TEST(YogaTest, align_items_flex_end_child_without_margin_bigger_than_parent) { YGConfigFree(config); } - -TEST(YogaTest, align_center_should_size_based_on_content) { - const YGConfigRef config = YGConfigNew(); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetAlignItems(root, YGAlignCenter); - YGNodeStyleSetMargin(root, YGEdgeTop, 20); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); - YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetFlexShrink(root_child0_child0, 1); - YGNodeInsertChild(root_child0, root_child0_child0, 0); - - const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0_child0_child0, 20); - YGNodeStyleSetHeight(root_child0_child0_child0, 20); - YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0_child0)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0_child0)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, align_strech_should_size_based_on_parent) { - const YGConfigRef config = YGConfigNew(); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetMargin(root, YGEdgeTop, 20); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); - YGNodeStyleSetFlexShrink(root_child0, 1); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexGrow(root_child0_child0, 1); - YGNodeStyleSetFlexShrink(root_child0_child0, 1); - YGNodeInsertChild(root_child0, root_child0_child0, 0); - - const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0_child0_child0, 20); - YGNodeStyleSetHeight(root_child0_child0_child0, 20); - YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0_child0)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0_child0)); - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0_child0)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} diff --git a/yoga/Yoga.c b/yoga/Yoga.c index e8155ebe..e70cb5f8 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -2189,7 +2189,6 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If the main dimension size isn't known, it is computed based on // the line length, so there's no more space left to distribute. - bool sizeBasedOnContent = false; // If we don't measure with exact main dimension we want to ensure we don't violate min and max if (measureModeMainDim != YGMeasureModeExactly) { if (!YGFloatIsUndefined(minInnerMainDim) && sizeConsumedOnCurrentLine < minInnerMainDim) { @@ -2200,14 +2199,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, // If we don't have any children to flex or we can't flex the node itself, // space we've used is all space we need availableInnerMainDim = sizeConsumedOnCurrentLine; - sizeBasedOnContent = true; - } else { - sizeBasedOnContent = true; } } float remainingFreeSpace = 0; - if (!sizeBasedOnContent && !YGFloatIsUndefined(availableInnerMainDim)) { + if (!YGFloatIsUndefined(availableInnerMainDim)) { remainingFreeSpace = availableInnerMainDim - sizeConsumedOnCurrentLine; } else if (sizeConsumedOnCurrentLine < 0) { // availableInnerMainDim is indefinite which means the node is being sized