Yoga test failure for flexing with min stack dimension

Summary: Test fails when we have flexible child and min/max layout dimension. Yoga should flex the child to minimal size, while in reality Yoga flexes it to maximal size

Reviewed By: emilsjolander

Differential Revision: D4558653

fbshipit-source-id: 06b38d7ed43aee063cc881f38b84558641f043f3
This commit is contained in:
Georgiy Kassabli
2017-02-28 16:27:18 -08:00
committed by Facebook Github Bot
parent 4372aa16d3
commit 3ef2970032
11 changed files with 485 additions and 7 deletions

View File

@@ -348,6 +348,121 @@ namespace Facebook.Yoga
Assert.AreEqual(50f, root_child2.LayoutHeight);
}
[Test]
public void Test_flex_grow_to_min()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
YogaNode root = new YogaNode();
root.Width = 100;
root.MinHeight = 100;
root.MaxHeight = 500;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexShrink = 1;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 50;
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(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50f, 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(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, false);
}
[Test]
public void Test_flex_grow_in_at_most_container()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.FlexStart;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexBasis = 0;
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(100f, 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);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(0f, root_child0_child0.LayoutWidth);
Assert.AreEqual(0f, 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(100f, root.LayoutHeight);
Assert.AreEqual(100f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(0f, 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(0f, root_child0_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.MinFlexFix, false);
}
[Test]
public void Test_flex_grow_within_max_width()
{