From 8b2e6c365d7c87b83aa3245f5eefd39a6d8b9076 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 26 Dec 2022 16:43:31 -0800 Subject: [PATCH] Add newer fixtures Summary: flexlayout has the same fixtures forked from Yoga, with some disabled, and some added. This syncs that list to Yoga, adding the fixes made to it along with new fixtures. One new test absolute_child_with_max_height_larger_shrinkable_grandchild is failing, along with two fixtures where Chrome had recently changed its behaviors. These are commented out at the moment before I do something smarter with the test runner to allow more fixtures. Differential Revision: D42242096 fbshipit-source-id: dad07c72101c32b48f7c5a5fa8f46d43d2637222 --- .../Facebook.Yoga/YGAbsolutePositionTest.cs | 293 +++++++++- .../tests/Facebook.Yoga/YGAlignContentTest.cs | 83 +++ .../tests/Facebook.Yoga/YGAlignItemsTest.cs | 527 +++++++++-------- csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs | 57 ++ csharp/tests/Facebook.Yoga/YGBorderTest.cs | 6 +- csharp/tests/Facebook.Yoga/YGDisplayTest.cs | 59 ++ .../Facebook.Yoga/YGFlexDirectionTest.cs | 67 +++ csharp/tests/Facebook.Yoga/YGFlexTest.cs | 192 ++++++ csharp/tests/Facebook.Yoga/YGMarginTest.cs | 59 +- .../Facebook.Yoga/YGMinMaxDimensionTest.cs | 361 ++++++++++++ csharp/tests/Facebook.Yoga/YGPaddingTest.cs | 6 +- .../tests/Facebook.Yoga/YGPercentageTest.cs | 177 ++++++ gentest/fixtures/YGAbsolutePositionTest.html | 49 +- gentest/fixtures/YGAlignContentTest.html | 12 +- gentest/fixtures/YGAlignItemsTest.html | 40 +- gentest/fixtures/YGAlignSelfTest.html | 5 + gentest/fixtures/YGBorderTest.html | 2 +- gentest/fixtures/YGDisplayTest.html | 5 + gentest/fixtures/YGFlexDirectionTest.html | 6 + gentest/fixtures/YGFlexTest.html | 18 + gentest/fixtures/YGMarginTest.html | 14 +- gentest/fixtures/YGMinMaxDimensionTest.html | 38 ++ gentest/fixtures/YGPaddingTest.html | 2 +- gentest/fixtures/YGPercentageTest.html | 21 +- .../facebook/yoga/YGAbsolutePositionTest.java | 288 ++++++++- .../com/facebook/yoga/YGAlignContentTest.java | 82 +++ .../com/facebook/yoga/YGAlignItemsTest.java | 521 +++++++++-------- .../com/facebook/yoga/YGAlignSelfTest.java | 56 ++ .../tests/com/facebook/yoga/YGBorderTest.java | 6 +- .../com/facebook/yoga/YGDisplayTest.java | 58 ++ .../facebook/yoga/YGFlexDirectionTest.java | 66 +++ java/tests/com/facebook/yoga/YGFlexTest.java | 189 ++++++ .../tests/com/facebook/yoga/YGMarginTest.java | 59 +- .../facebook/yoga/YGMinMaxDimensionTest.java | 353 ++++++++++++ .../com/facebook/yoga/YGPaddingTest.java | 6 +- .../com/facebook/yoga/YGPercentageTest.java | 174 ++++++ .../Facebook.Yoga/YGAbsolutePositionTest.js | 308 +++++++++- .../tests/Facebook.Yoga/YGAlignContentTest.js | 86 +++ .../tests/Facebook.Yoga/YGAlignItemsTest.js | 545 ++++++++++-------- .../tests/Facebook.Yoga/YGAlignSelfTest.js | 60 ++ .../tests/Facebook.Yoga/YGBorderTest.js | 6 +- .../tests/Facebook.Yoga/YGDisplayTest.js | 62 ++ .../Facebook.Yoga/YGFlexDirectionTest.js | 70 +++ javascript/tests/Facebook.Yoga/YGFlexTest.js | 201 +++++++ .../tests/Facebook.Yoga/YGMarginTest.js | 59 +- .../Facebook.Yoga/YGMinMaxDimensionTest.js | 385 +++++++++++++ .../tests/Facebook.Yoga/YGPaddingTest.js | 6 +- .../tests/Facebook.Yoga/YGPercentageTest.js | 186 ++++++ tests/YGAbsolutePositionTest.cpp | 293 +++++++++- tests/YGAlignContentTest.cpp | 83 +++ tests/YGAlignItemsTest.cpp | 527 +++++++++-------- tests/YGAlignSelfTest.cpp | 57 ++ tests/YGBorderTest.cpp | 6 +- tests/YGDisplayTest.cpp | 59 ++ tests/YGFlexDirectionTest.cpp | 67 +++ tests/YGFlexTest.cpp | 192 ++++++ tests/YGMarginTest.cpp | 59 +- tests/YGMinMaxDimensionTest.cpp | 361 ++++++++++++ tests/YGPaddingTest.cpp | 6 +- tests/YGPercentageTest.cpp | 177 ++++++ 60 files changed, 6614 insertions(+), 1204 deletions(-) diff --git a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs index 7ff003a2d7..58f64619eb 100644 --- a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs @@ -26,7 +26,6 @@ public void Test_absolute_layout_width_height_start_top() YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.Start = 10; root_child0.Top = 10; root_child0.Width = 10; root_child0.Height = 10; @@ -39,7 +38,7 @@ public void Test_absolute_layout_width_height_start_top() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -52,7 +51,7 @@ public void Test_absolute_layout_width_height_start_top() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(90f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -69,7 +68,6 @@ public void Test_absolute_layout_width_height_end_bottom() YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.End = 10; root_child0.Bottom = 10; root_child0.Width = 10; root_child0.Height = 10; @@ -82,7 +80,7 @@ public void Test_absolute_layout_width_height_end_bottom() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -95,7 +93,50 @@ public void Test_absolute_layout_width_height_end_bottom() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + } + + [Test] + public void Test_absolute_layout_row_width_height_end_bottom() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 100; + root.Height = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.Bottom = 10; + root_child0.Width = 10; + root_child0.Height = 10; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(80f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(90f, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -112,9 +153,7 @@ public void Test_absolute_layout_start_top_end_bottom() YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.Start = 10; root_child0.Top = 10; - root_child0.End = 10; root_child0.Bottom = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -125,9 +164,9 @@ public void Test_absolute_layout_start_top_end_bottom() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); - Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutHeight); root.StyleDirection = YogaDirection.RTL; @@ -138,9 +177,9 @@ public void Test_absolute_layout_start_top_end_bottom() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(100f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); - Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutHeight); } @@ -155,9 +194,7 @@ public void Test_absolute_layout_width_height_start_top_end_bottom() YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.Start = 10; root_child0.Top = 10; - root_child0.End = 10; root_child0.Bottom = 10; root_child0.Width = 10; root_child0.Height = 10; @@ -170,7 +207,7 @@ public void Test_absolute_layout_width_height_start_top_end_bottom() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -183,7 +220,7 @@ public void Test_absolute_layout_width_height_start_top_end_bottom() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(90f, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -202,7 +239,6 @@ public void Test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_ YogaNode root_child0 = new YogaNode(config); root_child0.PositionType = YogaPositionType.Absolute; - root_child0.Start = 0; root_child0.Top = 0; root.Insert(0, root_child0); @@ -1035,5 +1071,228 @@ public void Test_absolute_layout_in_wrap_reverse_row_container_flex_end() Assert.AreEqual(20f, root_child0.LayoutHeight); } + [Test] + public void Test_absolute_layout_percentage_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 200; + root.Height = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.Top = 10; + root_child0.Width = 10; + root_child0.Height = 50.Percent(); + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(190f, root_child0.LayoutX); + Assert.AreEqual(10f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + } + + [Test] + public void Test_absolute_child_with_cross_margin() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.JustifyContent = YogaJustify.SpaceBetween; + root.MinWidth = 311; + root.MaxWidth = 311; + root.MaxHeight = 3.68935e+19; + + YogaNode root_child0 = new YogaNode(config); + root_child0.FlexDirection = YogaFlexDirection.Row; + root_child0.AlignContent = YogaAlign.Stretch; + root_child0.Width = 28; + root_child0.Height = 27; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.FlexDirection = YogaFlexDirection.Row; + root_child1.AlignContent = YogaAlign.Stretch; + root_child1.PositionType = YogaPositionType.Absolute; + root_child1.FlexShrink = 1; + root_child1.MarginTop = 4; + root_child1.Width = 100.Percent(); + root_child1.Height = 15; + root.Insert(1, root_child1); + + YogaNode root_child2 = new YogaNode(config); + root_child2.FlexDirection = YogaFlexDirection.Row; + root_child2.AlignContent = YogaAlign.Stretch; + root_child2.Width = 25; + root_child2.Height = 27; + root.Insert(2, root_child2); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(311f, root.LayoutWidth); + Assert.AreEqual(27f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(28f, root_child0.LayoutWidth); + Assert.AreEqual(27f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(4f, root_child1.LayoutY); + Assert.AreEqual(311f, root_child1.LayoutWidth); + Assert.AreEqual(15f, root_child1.LayoutHeight); + + Assert.AreEqual(286f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(25f, root_child2.LayoutWidth); + Assert.AreEqual(27f, root_child2.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(311f, root.LayoutWidth); + Assert.AreEqual(27f, root.LayoutHeight); + + Assert.AreEqual(283f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(28f, root_child0.LayoutWidth); + Assert.AreEqual(27f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(4f, root_child1.LayoutY); + Assert.AreEqual(311f, root_child1.LayoutWidth); + Assert.AreEqual(15f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(25f, root_child2.LayoutWidth); + Assert.AreEqual(27f, root_child2.LayoutHeight); + } + + [Test] + public void Test_absolute_child_with_main_margin() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 20; + root.Height = 37; + + YogaNode root_child0 = new YogaNode(config); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.MarginLeft = 7; + root_child0.Width = 9; + root_child0.Height = 9; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(20f, root.LayoutWidth); + Assert.AreEqual(37f, root.LayoutHeight); + + Assert.AreEqual(7f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(9f, root_child0.LayoutWidth); + Assert.AreEqual(9f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(20f, root.LayoutWidth); + Assert.AreEqual(37f, root.LayoutHeight); + + Assert.AreEqual(11f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(9f, root_child0.LayoutWidth); + Assert.AreEqual(9f, root_child0.LayoutHeight); + } + + [Test] + public void Test_absolute_child_with_max_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 100; + root.Height = 200; + + YogaNode root_child0 = new YogaNode(config); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.Bottom = 20; + root_child0.MaxHeight = 100; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(config); + root_child0_child0.Width = 100; + root_child0_child0.Height = 30; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(150f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(30f, 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(30f, root_child0_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(150f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(30f, 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(30f, root_child0_child0.LayoutHeight); + } + } } diff --git a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs index 81969c99f6..566969afde 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignContentTest.cs @@ -1882,5 +1882,88 @@ public void Test_align_content_stretch_is_not_overriding_align_items() Assert.AreEqual(10f, root_child0_child0.LayoutHeight); } + [Test] + public void Test_align_content_not_stretch_with_align_items_stretch() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Wrap = YogaWrap.Wrap; + root.Width = 328; + root.Height = 52; + + YogaNode root_child0 = new YogaNode(config); + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(config); + root_child0_child0.Width = 272; + root_child0_child0.Height = 44; + root_child0.Insert(0, root_child0_child0); + + YogaNode root_child1 = new YogaNode(config); + root.Insert(1, root_child1); + + YogaNode root_child1_child0 = new YogaNode(config); + root_child1_child0.Width = 56; + root_child1_child0.Height = 44; + root_child1.Insert(0, root_child1_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(328f, root.LayoutWidth); + Assert.AreEqual(52f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(272f, root_child0.LayoutWidth); + Assert.AreEqual(44f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(272f, root_child0_child0.LayoutWidth); + Assert.AreEqual(44f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(272f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(56f, root_child1.LayoutWidth); + Assert.AreEqual(44f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0.LayoutX); + Assert.AreEqual(0f, root_child1_child0.LayoutY); + Assert.AreEqual(56f, root_child1_child0.LayoutWidth); + Assert.AreEqual(44f, root_child1_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(328f, root.LayoutWidth); + Assert.AreEqual(52f, root.LayoutHeight); + + Assert.AreEqual(56f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(272f, root_child0.LayoutWidth); + Assert.AreEqual(44f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(272f, root_child0_child0.LayoutWidth); + Assert.AreEqual(44f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(56f, root_child1.LayoutWidth); + Assert.AreEqual(44f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0.LayoutX); + Assert.AreEqual(0f, root_child1_child0.LayoutY); + Assert.AreEqual(56f, root_child1_child0.LayoutWidth); + Assert.AreEqual(44f, root_child1_child0.LayoutHeight); + } + } } diff --git a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs index 9a660aad1b..ea79ea21d1 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs @@ -54,6 +54,45 @@ public void Test_align_items_stretch() Assert.AreEqual(10f, root_child0.LayoutHeight); } + [Test] + public void Test_align_items_stretch_min_cross() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.MinWidth = 400; + root.MinHeight = 50; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Height = 36; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(400f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(400f, root_child0.LayoutWidth); + Assert.AreEqual(36f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(400f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(400f, root_child0.LayoutWidth); + Assert.AreEqual(36f, root_child0.LayoutHeight); + } + [Test] public void Test_align_items_center() { @@ -1233,240 +1272,6 @@ public void Test_align_baseline_multiline() Assert.AreEqual(50f, root_child3.LayoutHeight); } - [Test] - public void Test_align_baseline_multiline_column() - { - YogaConfig config = new YogaConfig(); - - YogaNode root = new YogaNode(config); - root.AlignItems = YogaAlign.Baseline; - root.Wrap = YogaWrap.Wrap; - root.Width = 100; - root.Height = 100; - - YogaNode root_child0 = new YogaNode(config); - root_child0.Width = 50; - root_child0.Height = 50; - root.Insert(0, root_child0); - - YogaNode root_child1 = new YogaNode(config); - root_child1.Width = 30; - root_child1.Height = 50; - root.Insert(1, root_child1); - - YogaNode root_child1_child0 = new YogaNode(config); - root_child1_child0.Width = 20; - root_child1_child0.Height = 20; - root_child1.Insert(0, root_child1_child0); - - YogaNode root_child2 = new YogaNode(config); - root_child2.Width = 40; - root_child2.Height = 70; - root.Insert(2, root_child2); - - YogaNode root_child2_child0 = new YogaNode(config); - root_child2_child0.Width = 10; - root_child2_child0.Height = 10; - root_child2.Insert(0, root_child2_child0); - - YogaNode root_child3 = new YogaNode(config); - root_child3.Width = 50; - root_child3.Height = 20; - root.Insert(3, root_child3); - root.StyleDirection = YogaDirection.LTR; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(0f, 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(50f, root_child0.LayoutWidth); - Assert.AreEqual(50f, root_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child1.LayoutX); - Assert.AreEqual(50f, root_child1.LayoutY); - Assert.AreEqual(30f, root_child1.LayoutWidth); - Assert.AreEqual(50f, root_child1.LayoutHeight); - - Assert.AreEqual(0f, root_child1_child0.LayoutX); - Assert.AreEqual(0f, root_child1_child0.LayoutY); - Assert.AreEqual(20f, root_child1_child0.LayoutWidth); - Assert.AreEqual(20f, root_child1_child0.LayoutHeight); - - Assert.AreEqual(50f, root_child2.LayoutX); - Assert.AreEqual(0f, root_child2.LayoutY); - Assert.AreEqual(40f, root_child2.LayoutWidth); - Assert.AreEqual(70f, root_child2.LayoutHeight); - - Assert.AreEqual(0f, root_child2_child0.LayoutX); - Assert.AreEqual(0f, root_child2_child0.LayoutY); - Assert.AreEqual(10f, root_child2_child0.LayoutWidth); - Assert.AreEqual(10f, root_child2_child0.LayoutHeight); - - Assert.AreEqual(50f, root_child3.LayoutX); - Assert.AreEqual(70f, root_child3.LayoutY); - Assert.AreEqual(50f, root_child3.LayoutWidth); - Assert.AreEqual(20f, root_child3.LayoutHeight); - - root.StyleDirection = YogaDirection.RTL; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(0f, root.LayoutY); - Assert.AreEqual(100f, root.LayoutWidth); - Assert.AreEqual(100f, root.LayoutHeight); - - Assert.AreEqual(50f, root_child0.LayoutX); - Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(50f, root_child0.LayoutWidth); - Assert.AreEqual(50f, root_child0.LayoutHeight); - - Assert.AreEqual(70f, root_child1.LayoutX); - Assert.AreEqual(50f, root_child1.LayoutY); - Assert.AreEqual(30f, root_child1.LayoutWidth); - Assert.AreEqual(50f, root_child1.LayoutHeight); - - Assert.AreEqual(10f, root_child1_child0.LayoutX); - Assert.AreEqual(0f, root_child1_child0.LayoutY); - Assert.AreEqual(20f, root_child1_child0.LayoutWidth); - Assert.AreEqual(20f, root_child1_child0.LayoutHeight); - - Assert.AreEqual(10f, root_child2.LayoutX); - Assert.AreEqual(0f, root_child2.LayoutY); - Assert.AreEqual(40f, root_child2.LayoutWidth); - Assert.AreEqual(70f, root_child2.LayoutHeight); - - Assert.AreEqual(30f, root_child2_child0.LayoutX); - Assert.AreEqual(0f, root_child2_child0.LayoutY); - Assert.AreEqual(10f, root_child2_child0.LayoutWidth); - Assert.AreEqual(10f, root_child2_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child3.LayoutX); - Assert.AreEqual(70f, root_child3.LayoutY); - Assert.AreEqual(50f, root_child3.LayoutWidth); - Assert.AreEqual(20f, root_child3.LayoutHeight); - } - - [Test] - public void Test_align_baseline_multiline_column2() - { - YogaConfig config = new YogaConfig(); - - YogaNode root = new YogaNode(config); - root.AlignItems = YogaAlign.Baseline; - root.Wrap = YogaWrap.Wrap; - root.Width = 100; - root.Height = 100; - - YogaNode root_child0 = new YogaNode(config); - root_child0.Width = 50; - root_child0.Height = 50; - root.Insert(0, root_child0); - - YogaNode root_child1 = new YogaNode(config); - root_child1.Width = 30; - root_child1.Height = 50; - root.Insert(1, root_child1); - - YogaNode root_child1_child0 = new YogaNode(config); - root_child1_child0.Width = 20; - root_child1_child0.Height = 20; - root_child1.Insert(0, root_child1_child0); - - YogaNode root_child2 = new YogaNode(config); - root_child2.Width = 40; - root_child2.Height = 70; - root.Insert(2, root_child2); - - YogaNode root_child2_child0 = new YogaNode(config); - root_child2_child0.Width = 10; - root_child2_child0.Height = 10; - root_child2.Insert(0, root_child2_child0); - - YogaNode root_child3 = new YogaNode(config); - root_child3.Width = 50; - root_child3.Height = 20; - root.Insert(3, root_child3); - root.StyleDirection = YogaDirection.LTR; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(0f, 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(50f, root_child0.LayoutWidth); - Assert.AreEqual(50f, root_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child1.LayoutX); - Assert.AreEqual(50f, root_child1.LayoutY); - Assert.AreEqual(30f, root_child1.LayoutWidth); - Assert.AreEqual(50f, root_child1.LayoutHeight); - - Assert.AreEqual(0f, root_child1_child0.LayoutX); - Assert.AreEqual(0f, root_child1_child0.LayoutY); - Assert.AreEqual(20f, root_child1_child0.LayoutWidth); - Assert.AreEqual(20f, root_child1_child0.LayoutHeight); - - Assert.AreEqual(50f, root_child2.LayoutX); - Assert.AreEqual(0f, root_child2.LayoutY); - Assert.AreEqual(40f, root_child2.LayoutWidth); - Assert.AreEqual(70f, root_child2.LayoutHeight); - - Assert.AreEqual(0f, root_child2_child0.LayoutX); - Assert.AreEqual(0f, root_child2_child0.LayoutY); - Assert.AreEqual(10f, root_child2_child0.LayoutWidth); - Assert.AreEqual(10f, root_child2_child0.LayoutHeight); - - Assert.AreEqual(50f, root_child3.LayoutX); - Assert.AreEqual(70f, root_child3.LayoutY); - Assert.AreEqual(50f, root_child3.LayoutWidth); - Assert.AreEqual(20f, root_child3.LayoutHeight); - - root.StyleDirection = YogaDirection.RTL; - root.CalculateLayout(); - - Assert.AreEqual(0f, root.LayoutX); - Assert.AreEqual(0f, root.LayoutY); - Assert.AreEqual(100f, root.LayoutWidth); - Assert.AreEqual(100f, root.LayoutHeight); - - Assert.AreEqual(50f, root_child0.LayoutX); - Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(50f, root_child0.LayoutWidth); - Assert.AreEqual(50f, root_child0.LayoutHeight); - - Assert.AreEqual(70f, root_child1.LayoutX); - Assert.AreEqual(50f, root_child1.LayoutY); - Assert.AreEqual(30f, root_child1.LayoutWidth); - Assert.AreEqual(50f, root_child1.LayoutHeight); - - Assert.AreEqual(10f, root_child1_child0.LayoutX); - Assert.AreEqual(0f, root_child1_child0.LayoutY); - Assert.AreEqual(20f, root_child1_child0.LayoutWidth); - Assert.AreEqual(20f, root_child1_child0.LayoutHeight); - - Assert.AreEqual(10f, root_child2.LayoutX); - Assert.AreEqual(0f, root_child2.LayoutY); - Assert.AreEqual(40f, root_child2.LayoutWidth); - Assert.AreEqual(70f, root_child2.LayoutHeight); - - Assert.AreEqual(30f, root_child2_child0.LayoutX); - Assert.AreEqual(0f, root_child2_child0.LayoutY); - Assert.AreEqual(10f, root_child2_child0.LayoutWidth); - Assert.AreEqual(10f, root_child2_child0.LayoutHeight); - - Assert.AreEqual(0f, root_child3.LayoutX); - Assert.AreEqual(70f, root_child3.LayoutY); - Assert.AreEqual(50f, root_child3.LayoutWidth); - Assert.AreEqual(20f, root_child3.LayoutHeight); - } - [Test] public void Test_align_baseline_multiline_row_and_column() { @@ -2162,5 +1967,259 @@ public void Test_align_flex_start_with_shrinking_children_with_stretch() Assert.AreEqual(0f, root_child0_child0_child0.LayoutHeight); } + [Test] + public void Test_align_items_center_justify_content_center() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 500; + root.Height = 500; + + YogaNode root_child0 = new YogaNode(config); + root_child0.JustifyContent = YogaJustify.Center; + root_child0.AlignItems = YogaAlign.Center; + root_child0.Height = 50; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(config); + root_child0_child0.JustifyContent = YogaJustify.Center; + root_child0_child0.AlignItems = YogaAlign.Center; + root_child0_child0.MarginLeft = 10; + root_child0_child0.MarginRight = 10; + root_child0_child0.Height = 100.Percent(); + root_child0.Insert(0, root_child0_child0); + + YogaNode root_child0_child0_child0 = new YogaNode(config); + root_child0_child0_child0.Width = 10; + root_child0_child0_child0.Height = 10; + root_child0_child0.Insert(0, root_child0_child0_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(500f, root.LayoutWidth); + Assert.AreEqual(500f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(500f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(245f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0_child0.LayoutX); + Assert.AreEqual(20f, root_child0_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0_child0_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(500f, root.LayoutWidth); + Assert.AreEqual(500f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(500f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(245f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0_child0.LayoutX); + Assert.AreEqual(20f, root_child0_child0_child0.LayoutY); + Assert.AreEqual(10f, root_child0_child0_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0_child0_child0.LayoutHeight); + } + + [Test] + public void Test_align_baseline_child_margin_percent() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.AlignItems = YogaAlign.Baseline; + root.Width = 100; + root.Height = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.MarginLeft = 5.Percent(); + root_child0.MarginTop = 5.Percent(); + root_child0.MarginRight = 5.Percent(); + root_child0.MarginBottom = 5.Percent(); + root_child0.Width = 50; + root_child0.Height = 50; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.Width = 50; + root_child1.Height = 20; + root.Insert(1, root_child1); + + YogaNode root_child1_child0 = new YogaNode(config); + root_child1_child0.MarginLeft = 1.Percent(); + root_child1_child0.MarginTop = 1.Percent(); + root_child1_child0.MarginRight = 1.Percent(); + root_child1_child0.MarginBottom = 1.Percent(); + root_child1_child0.Width = 50; + root_child1_child0.Height = 10; + root_child1.Insert(0, root_child1_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(5f, root_child0.LayoutX); + Assert.AreEqual(5f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(60f, root_child1.LayoutX); + Assert.AreEqual(45f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); + + Assert.AreEqual(1f, root_child1_child0.LayoutX); + Assert.AreEqual(1f, root_child1_child0.LayoutY); + Assert.AreEqual(50f, root_child1_child0.LayoutWidth); + Assert.AreEqual(10f, root_child1_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(45f, root_child0.LayoutX); + Assert.AreEqual(5f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(-10f, root_child1.LayoutX); + Assert.AreEqual(45f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(20f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0.LayoutX); + Assert.AreEqual(1f, root_child1_child0.LayoutY); + Assert.AreEqual(50f, root_child1_child0.LayoutWidth); + Assert.AreEqual(10f, root_child1_child0.LayoutHeight); + } + + [Test] + public void Test_align_baseline_nested_column() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.AlignItems = YogaAlign.Baseline; + root.Width = 100; + root.Height = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Width = 50; + root_child0.Height = 60; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root.Insert(1, root_child1); + + YogaNode root_child1_child0 = new YogaNode(config); + root_child1_child0.Width = 50; + root_child1_child0.Height = 80; + root_child1.Insert(0, root_child1_child0); + + YogaNode root_child1_child0_child0 = new YogaNode(config); + root_child1_child0_child0.Width = 50; + root_child1_child0_child0.Height = 30; + root_child1_child0.Insert(0, root_child1_child0_child0); + + YogaNode root_child1_child0_child1 = new YogaNode(config); + root_child1_child0_child1.Width = 50; + root_child1_child0_child1.Height = 40; + root_child1_child0.Insert(1, root_child1_child0_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, 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(50f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); + + Assert.AreEqual(50f, root_child1.LayoutX); + Assert.AreEqual(30f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(80f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0.LayoutX); + Assert.AreEqual(0f, root_child1_child0.LayoutY); + Assert.AreEqual(50f, root_child1_child0.LayoutWidth); + Assert.AreEqual(80f, root_child1_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child1_child0_child0.LayoutY); + Assert.AreEqual(50f, root_child1_child0_child0.LayoutWidth); + Assert.AreEqual(30f, root_child1_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0_child1.LayoutX); + Assert.AreEqual(30f, root_child1_child0_child1.LayoutY); + Assert.AreEqual(50f, root_child1_child0_child1.LayoutWidth); + Assert.AreEqual(40f, root_child1_child0_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(60f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(30f, root_child1.LayoutY); + Assert.AreEqual(50f, root_child1.LayoutWidth); + Assert.AreEqual(80f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0.LayoutX); + Assert.AreEqual(0f, root_child1_child0.LayoutY); + Assert.AreEqual(50f, root_child1_child0.LayoutWidth); + Assert.AreEqual(80f, root_child1_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child1_child0_child0.LayoutY); + Assert.AreEqual(50f, root_child1_child0_child0.LayoutWidth); + Assert.AreEqual(30f, root_child1_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1_child0_child1.LayoutX); + Assert.AreEqual(30f, root_child1_child0_child1.LayoutY); + Assert.AreEqual(50f, root_child1_child0_child1.LayoutWidth); + Assert.AreEqual(40f, root_child1_child0_child1.LayoutHeight); + } + } } diff --git a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs index 2477fd2bfa..fcd8275d1f 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignSelfTest.cs @@ -56,6 +56,63 @@ public void Test_align_self_center() Assert.AreEqual(10f, root_child0.LayoutHeight); } + [Test] + public void Test_align_self_center_undefined_max_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 280; + root.MinHeight = 52; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Width = 240; + root_child0.Height = 44; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.AlignSelf = YogaAlign.Center; + root_child1.Width = 40; + root_child1.Height = 56; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(280f, root.LayoutWidth); + Assert.AreEqual(56f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(240f, root_child0.LayoutWidth); + Assert.AreEqual(44f, root_child0.LayoutHeight); + + Assert.AreEqual(240f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(40f, root_child1.LayoutWidth); + Assert.AreEqual(56f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(280f, root.LayoutWidth); + Assert.AreEqual(56f, root.LayoutHeight); + + Assert.AreEqual(40f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(240f, root_child0.LayoutWidth); + Assert.AreEqual(44f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(40f, root_child1.LayoutWidth); + Assert.AreEqual(56f, root_child1.LayoutHeight); + } + [Test] public void Test_align_self_flex_end() { diff --git a/csharp/tests/Facebook.Yoga/YGBorderTest.cs b/csharp/tests/Facebook.Yoga/YGBorderTest.cs index 854bb59b98..d550cc3101 100644 --- a/csharp/tests/Facebook.Yoga/YGBorderTest.cs +++ b/csharp/tests/Facebook.Yoga/YGBorderTest.cs @@ -179,8 +179,6 @@ public void Test_border_center_child() YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; - root.BorderStartWidth = 10; - root.BorderEndWidth = 20; root.BorderBottomWidth = 20; root.Width = 100; root.Height = 100; @@ -197,7 +195,7 @@ public void Test_border_center_child() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(40f, root_child0.LayoutX); + Assert.AreEqual(45f, root_child0.LayoutX); Assert.AreEqual(35f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -210,7 +208,7 @@ public void Test_border_center_child() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(45f, root_child0.LayoutX); Assert.AreEqual(35f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); diff --git a/csharp/tests/Facebook.Yoga/YGDisplayTest.cs b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs index 4b0da55c29..90a171fdb7 100644 --- a/csharp/tests/Facebook.Yoga/YGDisplayTest.cs +++ b/csharp/tests/Facebook.Yoga/YGDisplayTest.cs @@ -376,5 +376,64 @@ public void Test_display_none_with_position_absolute() Assert.AreEqual(0f, root_child0.LayoutHeight); } + [Test] + public void Test_display_none_absolute_child() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 100; + root.Height = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.FlexGrow = 1; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.PositionType = YogaPositionType.Absolute; + root_child1.Left = 10; + root_child1.Top = 10; + root_child1.Width = 20; + root_child1.Height = 20; + root_child1.Display = YogaDisplay.None; + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, 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(100f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, 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(100f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(0f, root_child1.LayoutHeight); + } + } } diff --git a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs index 09b41dc0c2..0a0479cbaf 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexDirectionTest.cs @@ -419,5 +419,72 @@ public void Test_flex_direction_row_reverse() Assert.AreEqual(100f, root_child2.LayoutHeight); } + [Test] + public void Test_flex_direction_column_reverse_no_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.ColumnReverse; + root.Width = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Height = 10; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.Height = 10; + root.Insert(1, root_child1); + + YogaNode root_child2 = new YogaNode(config); + root_child2.Height = 10; + root.Insert(2, root_child2); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(30f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(20f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(10f, root_child1.LayoutY); + Assert.AreEqual(100f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(100f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); + } + } } diff --git a/csharp/tests/Facebook.Yoga/YGFlexTest.cs b/csharp/tests/Facebook.Yoga/YGFlexTest.cs index a8d3a0a630..4463f40a56 100644 --- a/csharp/tests/Facebook.Yoga/YGFlexTest.cs +++ b/csharp/tests/Facebook.Yoga/YGFlexTest.cs @@ -612,5 +612,197 @@ public void Test_flex_grow_less_than_factor_one() Assert.AreEqual(184f, root_child2.LayoutHeight); } + [Test] + public void Test_single_flex_child_after_absolute_child() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 428; + root.Height = 845; + + YogaNode root_child0 = new YogaNode(config); + root_child0.PositionType = YogaPositionType.Absolute; + root_child0.Width = 100.Percent(); + root_child0.Height = 100.Percent(); + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.FlexGrow = 1; + root_child1.FlexShrink = 1; + root.Insert(1, root_child1); + + YogaNode root_child2 = new YogaNode(config); + root_child2.FlexBasis = 174; + root.Insert(2, root_child2); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(428f, root.LayoutWidth); + Assert.AreEqual(845f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(428f, root_child0.LayoutWidth); + Assert.AreEqual(845f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(428f, root_child1.LayoutWidth); + Assert.AreEqual(671f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(671f, root_child2.LayoutY); + Assert.AreEqual(428f, root_child2.LayoutWidth); + Assert.AreEqual(174f, root_child2.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(428f, root.LayoutWidth); + Assert.AreEqual(845f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(428f, root_child0.LayoutWidth); + Assert.AreEqual(845f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(428f, root_child1.LayoutWidth); + Assert.AreEqual(671f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(671f, root_child2.LayoutY); + Assert.AreEqual(428f, root_child2.LayoutWidth); + Assert.AreEqual(174f, root_child2.LayoutHeight); + } + + [Test] + public void Test_flex_basis_zero_undefined_main_size() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + + YogaNode root_child0 = new YogaNode(config); + root_child0.FlexBasis = 0; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(config); + root_child0_child0.Width = 100; + root_child0_child0.Height = 50; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, 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(50f, root_child0_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(100f, root_child0.LayoutWidth); + Assert.AreEqual(50f, 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(50f, root_child0_child0.LayoutHeight); + } + + [Test] + public void Test_only_shrinkable_item_with_flex_basis_zero() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 480; + root.MaxHeight = 764; + + YogaNode root_child0 = new YogaNode(config); + root_child0.FlexShrink = 1; + root_child0.FlexBasis = 0; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.FlexBasis = 93; + root_child1.MarginBottom = 6; + root.Insert(1, root_child1); + + YogaNode root_child2 = new YogaNode(config); + root_child2.FlexBasis = 764; + root.Insert(2, root_child2); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(480f, root.LayoutWidth); + Assert.AreEqual(764f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(480f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(480f, root_child1.LayoutWidth); + Assert.AreEqual(93f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(99f, root_child2.LayoutY); + Assert.AreEqual(480f, root_child2.LayoutWidth); + Assert.AreEqual(764f, root_child2.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(480f, root.LayoutWidth); + Assert.AreEqual(764f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(480f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(480f, root_child1.LayoutWidth); + Assert.AreEqual(93f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(99f, root_child2.LayoutY); + Assert.AreEqual(480f, root_child2.LayoutWidth); + Assert.AreEqual(764f, root_child2.LayoutHeight); + } + } } diff --git a/csharp/tests/Facebook.Yoga/YGMarginTest.cs b/csharp/tests/Facebook.Yoga/YGMarginTest.cs index 4316af3bf8..78c5a9cf09 100644 --- a/csharp/tests/Facebook.Yoga/YGMarginTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMarginTest.cs @@ -26,7 +26,6 @@ public void Test_margin_start() root.Height = 100; YogaNode root_child0 = new YogaNode(config); - root_child0.MarginStart = 10; root_child0.Width = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -37,7 +36,7 @@ public void Test_margin_start() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); @@ -50,7 +49,7 @@ public void Test_margin_start() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(90f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); @@ -108,7 +107,6 @@ public void Test_margin_end() root.Height = 100; YogaNode root_child0 = new YogaNode(config); - root_child0.MarginEnd = 10; root_child0.Width = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; @@ -119,7 +117,7 @@ public void Test_margin_end() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(80f, root_child0.LayoutX); + Assert.AreEqual(90f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); @@ -132,7 +130,7 @@ public void Test_margin_end() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); @@ -191,8 +189,6 @@ public void Test_margin_and_flex_row() YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; - root_child0.MarginStart = 10; - root_child0.MarginEnd = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -202,9 +198,9 @@ public void Test_margin_and_flex_row() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); root.StyleDirection = YogaDirection.RTL; @@ -215,9 +211,9 @@ public void Test_margin_and_flex_row() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); } @@ -315,8 +311,6 @@ public void Test_margin_and_stretch_column() YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; - root_child0.MarginStart = 10; - root_child0.MarginEnd = 10; root.Insert(0, root_child0); root.StyleDirection = YogaDirection.LTR; root.CalculateLayout(); @@ -326,9 +320,9 @@ public void Test_margin_and_stretch_column() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); root.StyleDirection = YogaDirection.RTL; @@ -339,9 +333,9 @@ public void Test_margin_and_stretch_column() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(10f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(80f, root_child0.LayoutWidth); + Assert.AreEqual(100f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); } @@ -357,7 +351,6 @@ public void Test_margin_with_sibling_row() YogaNode root_child0 = new YogaNode(config); root_child0.FlexGrow = 1; - root_child0.MarginEnd = 10; root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(config); @@ -373,12 +366,12 @@ public void Test_margin_with_sibling_row() Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(45f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); - Assert.AreEqual(55f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutY); - Assert.AreEqual(45f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutHeight); root.StyleDirection = YogaDirection.RTL; @@ -389,14 +382,14 @@ public void Test_margin_with_sibling_row() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(55f, root_child0.LayoutX); + Assert.AreEqual(50f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); - Assert.AreEqual(45f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutY); - Assert.AreEqual(45f, root_child1.LayoutWidth); + Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutHeight); } @@ -959,8 +952,6 @@ public void Test_margin_auto_start_and_end_column() root.Height = 200; YogaNode root_child0 = new YogaNode(config); - root_child0.MarginStart = YogaValue.Auto(); - root_child0.MarginEnd = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); @@ -977,12 +968,12 @@ public void Test_margin_auto_start_and_end_column() Assert.AreEqual(200f, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutHeight); - Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(75f, root_child0.LayoutY); Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(150f, root_child1.LayoutX); + Assert.AreEqual(50f, root_child1.LayoutX); Assert.AreEqual(75f, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); @@ -995,12 +986,12 @@ public void Test_margin_auto_start_and_end_column() Assert.AreEqual(200f, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutHeight); - Assert.AreEqual(100f, root_child0.LayoutX); + Assert.AreEqual(150f, root_child0.LayoutX); Assert.AreEqual(75f, root_child0.LayoutY); Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutHeight); - Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(100f, root_child1.LayoutX); Assert.AreEqual(75f, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutHeight); @@ -1016,8 +1007,6 @@ public void Test_margin_auto_start_and_end() root.Height = 200; YogaNode root_child0 = new YogaNode(config); - root_child0.MarginStart = YogaValue.Auto(); - root_child0.MarginEnd = YogaValue.Auto(); root_child0.Width = 50; root_child0.Height = 50; root.Insert(0, root_child0); @@ -1034,7 +1023,7 @@ public void Test_margin_auto_start_and_end() Assert.AreEqual(200f, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutHeight); - Assert.AreEqual(75f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutHeight); @@ -1052,7 +1041,7 @@ public void Test_margin_auto_start_and_end() Assert.AreEqual(200f, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutHeight); - Assert.AreEqual(75f, root_child0.LayoutX); + Assert.AreEqual(150f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutHeight); diff --git a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs index a12bfdcb5f..867d4d9b8b 100644 --- a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs @@ -55,6 +55,87 @@ public void Test_max_width() Assert.AreEqual(10f, root_child0.LayoutHeight); } + [Test] + public void Test_min_width_larger_than_width() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 100; + root.Height = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Width = 25; + root_child0.MinWidth = 50; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, 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(50f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(50f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + } + + [Test] + public void Test_min_height_larger_than_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 100; + root.Height = 100; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Height = 25; + root_child0.MinHeight = 50; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, 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(0f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(100f, root.LayoutHeight); + + Assert.AreEqual(100f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(0f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + } + [Test] public void Test_max_height() { @@ -96,6 +177,66 @@ public void Test_max_height() Assert.AreEqual(50f, root_child0.LayoutHeight); } + [Test] + public void Test_min_height_with_nested_fixed_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.PaddingLeft = 16; + root.PaddingRight = 16; + root.Width = 320; + root.MinHeight = 44; + + YogaNode root_child0 = new YogaNode(config); + root_child0.AlignSelf = YogaAlign.FlexStart; + root_child0.MarginTop = 8; + root_child0.MarginBottom = 9; + root_child0.MinHeight = 28; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(config); + root_child0_child0.Width = 40; + root_child0_child0.Height = 40; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(320f, root.LayoutWidth); + Assert.AreEqual(57f, root.LayoutHeight); + + Assert.AreEqual(16f, root_child0.LayoutX); + Assert.AreEqual(8f, root_child0.LayoutY); + Assert.AreEqual(40f, root_child0.LayoutWidth); + Assert.AreEqual(40f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(40f, root_child0_child0.LayoutWidth); + Assert.AreEqual(40f, root_child0_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(320f, root.LayoutWidth); + Assert.AreEqual(57f, root.LayoutHeight); + + Assert.AreEqual(264f, root_child0.LayoutX); + Assert.AreEqual(8f, root_child0.LayoutY); + Assert.AreEqual(40f, root_child0.LayoutWidth); + Assert.AreEqual(40f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(40f, root_child0_child0.LayoutWidth); + Assert.AreEqual(40f, root_child0_child0.LayoutHeight); + } + [Test] public void Test_justify_content_min_max() { @@ -180,6 +321,52 @@ public void Test_align_items_min_max() Assert.AreEqual(60f, root_child0.LayoutHeight); } + [Test] + public void Test_align_items_center_min_max_with_padding() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.AlignItems = YogaAlign.Center; + root.PaddingTop = 8; + root.PaddingBottom = 8; + root.MinWidth = 320; + root.MaxWidth = 320; + root.MinHeight = 72; + root.MaxHeight = 504; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Width = 62; + root_child0.Height = 62; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(320f, root.LayoutWidth); + Assert.AreEqual(78f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(8f, root_child0.LayoutY); + Assert.AreEqual(62f, root_child0.LayoutWidth); + Assert.AreEqual(62f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(320f, root.LayoutWidth); + Assert.AreEqual(78f, root.LayoutHeight); + + Assert.AreEqual(258f, root_child0.LayoutX); + Assert.AreEqual(8f, root_child0.LayoutY); + Assert.AreEqual(62f, root_child0.LayoutWidth); + Assert.AreEqual(62f, root_child0.LayoutHeight); + } + [Test] public void Test_justify_content_overflow_min_max() { @@ -1192,5 +1379,179 @@ public void Test_min_max_percent_no_width_height() Assert.AreEqual(10f, root_child0.LayoutHeight); } + [Test] + public void Test_min_max_percent_different_width_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.AlignItems = YogaAlign.FlexStart; + root.Width = 100; + root.Height = 200; + + YogaNode root_child0 = new YogaNode(config); + root_child0.MinWidth = 10.Percent(); + root_child0.MaxWidth = 10.Percent(); + root_child0.MinHeight = 10.Percent(); + root_child0.MaxHeight = 10.Percent(); + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(100f, root.LayoutWidth); + Assert.AreEqual(200f, root.LayoutHeight); + + Assert.AreEqual(90f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(10f, root_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0.LayoutHeight); + } + + [Test] + public void Test_undefined_height_with_min_max() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 320; + + YogaNode root_child0 = new YogaNode(config); + root_child0.MaxHeight = 100; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(320f, root.LayoutWidth); + Assert.AreEqual(0f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(320f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(320f, root.LayoutWidth); + Assert.AreEqual(0f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(320f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + } + + [Test] + public void Test_undefined_width_with_min_max() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Height = 50; + + YogaNode root_child0 = new YogaNode(config); + root_child0.MaxWidth = 100; + root.Insert(0, root_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(0f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(0f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(0f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(0f, root_child0.LayoutWidth); + Assert.AreEqual(0f, root_child0.LayoutHeight); + } + + [Test] + public void Test_undefined_width_with_min_max_row() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Height = 50; + + YogaNode root_child0 = new YogaNode(config); + root_child0.MinWidth = 60; + root_child0.MaxWidth = 300; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(config); + root_child0_child0.Width = 30; + root_child0_child0.Height = 20; + root_child0.Insert(0, root_child0_child0); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(60f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(30f, root_child0_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0_child0.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(60f, root.LayoutWidth); + Assert.AreEqual(50f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(60f, root_child0.LayoutWidth); + Assert.AreEqual(50f, root_child0.LayoutHeight); + + Assert.AreEqual(30f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(30f, root_child0_child0.LayoutWidth); + Assert.AreEqual(20f, root_child0_child0.LayoutHeight); + } + } } diff --git a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs index 145cf0dbaa..f75e590693 100644 --- a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs @@ -179,8 +179,6 @@ public void Test_padding_center_child() YogaNode root = new YogaNode(config); root.JustifyContent = YogaJustify.Center; root.AlignItems = YogaAlign.Center; - root.PaddingStart = 10; - root.PaddingEnd = 20; root.PaddingBottom = 20; root.Width = 100; root.Height = 100; @@ -197,7 +195,7 @@ public void Test_padding_center_child() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(40f, root_child0.LayoutX); + Assert.AreEqual(45f, root_child0.LayoutX); Assert.AreEqual(35f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); @@ -210,7 +208,7 @@ public void Test_padding_center_child() Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutHeight); - Assert.AreEqual(50f, root_child0.LayoutX); + Assert.AreEqual(45f, root_child0.LayoutX); Assert.AreEqual(35f, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutHeight); diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs index 8dc2fae387..c63780506e 100644 --- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs @@ -598,6 +598,74 @@ public void Test_percentage_flex_basis_cross_min_width() Assert.AreEqual(150f, root_child1.LayoutHeight); } + [Test] + public void Test_percentage_main_max_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 71; + + YogaNode root_child0 = new YogaNode(config); + root_child0.AlignItems = YogaAlign.FlexStart; + root_child0.Height = 151; + root.Insert(0, root_child0); + + YogaNode root_child0_child0 = new YogaNode(config); + root_child0_child0.FlexBasis = 15; + root_child0.Insert(0, root_child0_child0); + + YogaNode root_child0_child1 = new YogaNode(config); + root_child0_child1.FlexBasis = 48; + root_child0_child1.MaxHeight = 33.Percent(); + root_child0.Insert(1, root_child0_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(71f, root.LayoutWidth); + Assert.AreEqual(151f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(71f, root_child0.LayoutWidth); + Assert.AreEqual(151f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(0f, root_child0_child0.LayoutWidth); + Assert.AreEqual(15f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child0_child1.LayoutX); + Assert.AreEqual(15f, root_child0_child1.LayoutY); + Assert.AreEqual(0f, root_child0_child1.LayoutWidth); + Assert.AreEqual(48f, root_child0_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(71f, root.LayoutWidth); + Assert.AreEqual(151f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(71f, root_child0.LayoutWidth); + Assert.AreEqual(151f, root_child0.LayoutHeight); + + Assert.AreEqual(71f, root_child0_child0.LayoutX); + Assert.AreEqual(0f, root_child0_child0.LayoutY); + Assert.AreEqual(0f, root_child0_child0.LayoutWidth); + Assert.AreEqual(15f, root_child0_child0.LayoutHeight); + + Assert.AreEqual(71f, root_child0_child1.LayoutX); + Assert.AreEqual(15f, root_child0_child1.LayoutY); + Assert.AreEqual(0f, root_child0_child1.LayoutWidth); + Assert.AreEqual(48f, root_child0_child1.LayoutHeight); + } + [Test] public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values() { @@ -1003,6 +1071,7 @@ public void Test_percentage_container_in_wrapping_container() YogaNode root_child0_child0 = new YogaNode(config); root_child0_child0.FlexDirection = YogaFlexDirection.Row; root_child0_child0.JustifyContent = YogaJustify.Center; + root_child0_child0.AlignItems = YogaAlign.Center; root_child0_child0.Width = 100.Percent(); root_child0.Insert(0, root_child0_child0); @@ -1143,5 +1212,113 @@ public void Test_percent_absolute_position() Assert.AreEqual(50f, root_child0_child1.LayoutHeight); } + [Test] + public void Test_percentage_different_width_height() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.Width = 200; + root.Height = 300; + + YogaNode root_child0 = new YogaNode(config); + root_child0.FlexGrow = 1; + root_child0.Height = 30.Percent(); + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.Height = 30.Percent(); + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(300f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(90f, root_child0.LayoutHeight); + + Assert.AreEqual(200f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(90f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(300f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(90f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(90f, root_child1.LayoutHeight); + } + + [Test] + public void Test_percentage_different_width_height_column() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.Width = 200; + root.Height = 300; + + YogaNode root_child0 = new YogaNode(config); + root_child0.FlexGrow = 1; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.Height = 30.Percent(); + root.Insert(1, root_child1); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(300f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(210f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(210f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(90f, root_child1.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(200f, root.LayoutWidth); + Assert.AreEqual(300f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(200f, root_child0.LayoutWidth); + Assert.AreEqual(210f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(210f, root_child1.LayoutY); + Assert.AreEqual(200f, root_child1.LayoutWidth); + Assert.AreEqual(90f, root_child1.LayoutHeight); + } + } } diff --git a/gentest/fixtures/YGAbsolutePositionTest.html b/gentest/fixtures/YGAbsolutePositionTest.html index 39f8e980d4..cc6b74b27d 100644 --- a/gentest/fixtures/YGAbsolutePositionTest.html +++ b/gentest/fixtures/YGAbsolutePositionTest.html @@ -1,21 +1,25 @@
-
+
-
+
+
+ +
+
-
+
-
+
-
+
@@ -67,9 +71,9 @@
-
-
-
+
+
+
@@ -88,3 +92,32 @@
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+ + + diff --git a/gentest/fixtures/YGAlignContentTest.html b/gentest/fixtures/YGAlignContentTest.html index 3cecdf8d54..50ba4a0695 100644 --- a/gentest/fixtures/YGAlignContentTest.html +++ b/gentest/fixtures/YGAlignContentTest.html @@ -147,4 +147,14 @@
- \ No newline at end of file + + +
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/YGAlignItemsTest.html b/gentest/fixtures/YGAlignItemsTest.html index 57bafc0f74..6808c1c220 100644 --- a/gentest/fixtures/YGAlignItemsTest.html +++ b/gentest/fixtures/YGAlignItemsTest.html @@ -2,6 +2,10 @@
+
+
+
+
@@ -111,7 +115,8 @@
-
+ + -
+ +
@@ -207,3 +213,29 @@
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/YGAlignSelfTest.html b/gentest/fixtures/YGAlignSelfTest.html index c2f656ed37..e9fc0f32e5 100644 --- a/gentest/fixtures/YGAlignSelfTest.html +++ b/gentest/fixtures/YGAlignSelfTest.html @@ -2,6 +2,11 @@
+
+
+
+
+
diff --git a/gentest/fixtures/YGBorderTest.html b/gentest/fixtures/YGBorderTest.html index 9a65dc168b..3f64af6d88 100644 --- a/gentest/fixtures/YGBorderTest.html +++ b/gentest/fixtures/YGBorderTest.html @@ -13,6 +13,6 @@
-
+
diff --git a/gentest/fixtures/YGDisplayTest.html b/gentest/fixtures/YGDisplayTest.html index f11533f88c..862790cc4f 100644 --- a/gentest/fixtures/YGDisplayTest.html +++ b/gentest/fixtures/YGDisplayTest.html @@ -29,3 +29,8 @@
+ +
+
+
+
diff --git a/gentest/fixtures/YGFlexDirectionTest.html b/gentest/fixtures/YGFlexDirectionTest.html index 69dc552731..5e3e7d3909 100644 --- a/gentest/fixtures/YGFlexDirectionTest.html +++ b/gentest/fixtures/YGFlexDirectionTest.html @@ -33,3 +33,9 @@
+ +
+
+
+
+
diff --git a/gentest/fixtures/YGFlexTest.html b/gentest/fixtures/YGFlexTest.html index 9985c3cbfb..e299cbfea6 100644 --- a/gentest/fixtures/YGFlexTest.html +++ b/gentest/fixtures/YGFlexTest.html @@ -51,3 +51,21 @@
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
diff --git a/gentest/fixtures/YGMarginTest.html b/gentest/fixtures/YGMarginTest.html index 3258c1fcf6..5282f9fa13 100644 --- a/gentest/fixtures/YGMarginTest.html +++ b/gentest/fixtures/YGMarginTest.html @@ -1,5 +1,5 @@
-
+
@@ -7,7 +7,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -27,11 +27,11 @@
-
+
-
+
@@ -83,12 +83,12 @@
-
+
-
+
diff --git a/gentest/fixtures/YGMinMaxDimensionTest.html b/gentest/fixtures/YGMinMaxDimensionTest.html index f083d9085e..6974e1b98e 100644 --- a/gentest/fixtures/YGMinMaxDimensionTest.html +++ b/gentest/fixtures/YGMinMaxDimensionTest.html @@ -2,10 +2,24 @@
+
+
+
+ +
+
+
+
+
+
+
+
+
+