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
This commit is contained in:
Nick Gerleman
2022-12-26 16:43:31 -08:00
committed by Facebook GitHub Bot
parent 894142d589
commit 8b2e6c365d
60 changed files with 6614 additions and 1204 deletions

View File

@@ -26,7 +26,6 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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);
}
}
}

View File

@@ -1882,5 +1882,88 @@ namespace Facebook.Yoga
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);
}
}
}

View File

@@ -54,6 +54,45 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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);
}
}
}

View File

@@ -56,6 +56,63 @@ namespace Facebook.Yoga
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()
{

View File

@@ -179,8 +179,6 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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);

View File

@@ -376,5 +376,64 @@ namespace Facebook.Yoga
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);
}
}
}

View File

@@ -419,5 +419,72 @@ namespace Facebook.Yoga
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);
}
}
}

View File

@@ -612,5 +612,197 @@ namespace Facebook.Yoga
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);
}
}
}

View File

@@ -26,7 +26,6 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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);

View File

@@ -55,6 +55,87 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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);
}
}
}

View File

@@ -179,8 +179,6 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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);

View File

@@ -598,6 +598,74 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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 @@ namespace Facebook.Yoga
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);
}
}
}