Add justify-content: space-evenly

Summary:
Adds new ```space-evenly``` for ```justify-content```.

Also adds a typofix in one of the other justify-content tests.

Fixes #657
Closes https://github.com/facebook/yoga/pull/658

Differential Revision: D6407996

Pulled By: emilsjolander

fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3
This commit is contained in:
Lukas Wöhrl
2017-11-27 03:40:01 -08:00
committed by Facebook Github Bot
parent 5e39f1a57c
commit 7e3be21811
17 changed files with 614 additions and 26 deletions

View File

@@ -16,5 +16,6 @@ namespace Facebook.Yoga
FlexEnd,
SpaceBetween,
SpaceAround,
SpaceEvenly,
}
}

View File

@@ -375,6 +375,7 @@ namespace Facebook.Yoga
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);
@@ -396,10 +397,10 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(102f, root_child1.LayoutWidth);
Assert.AreEqual(0f, root_child1.LayoutHeight);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(10f, root_child2.LayoutY);
Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(102f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
@@ -419,10 +420,10 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(102f, root_child1.LayoutWidth);
Assert.AreEqual(0f, root_child1.LayoutHeight);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(10f, root_child2.LayoutY);
Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(102f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
}
@@ -867,5 +868,142 @@ namespace Facebook.Yoga
Assert.AreEqual(20f, root_child0.LayoutHeight);
}
[Test]
public void Test_justify_content_column_space_evenly()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.JustifyContent = YogaJustify.SpaceEvenly;
root.Width = 102;
root.Height = 102;
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(102f, root.LayoutWidth);
Assert.AreEqual(102f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(18f, root_child0.LayoutY);
Assert.AreEqual(102f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(46f, root_child1.LayoutY);
Assert.AreEqual(102f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(74f, root_child2.LayoutY);
Assert.AreEqual(102f, 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(102f, root.LayoutWidth);
Assert.AreEqual(102f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(18f, root_child0.LayoutY);
Assert.AreEqual(102f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(46f, root_child1.LayoutY);
Assert.AreEqual(102f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(74f, root_child2.LayoutY);
Assert.AreEqual(102f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
}
[Test]
public void Test_justify_content_row_space_evenly()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.SpaceEvenly;
root.Width = 102;
root.Height = 102;
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(102f, root.LayoutWidth);
Assert.AreEqual(102f, root.LayoutHeight);
Assert.AreEqual(26f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(51f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(77f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(0f, 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(102f, root.LayoutWidth);
Assert.AreEqual(102f, root.LayoutHeight);
Assert.AreEqual(77f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(51f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(26f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(0f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
}
}
}