Skip to content

Commit

Permalink
keep legacyStretchBehaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
woehrl01 committed Sep 21, 2017
1 parent eb4f7c5 commit d32ff55
Show file tree
Hide file tree
Showing 7 changed files with 621 additions and 6 deletions.
139 changes: 138 additions & 1 deletion csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,144 @@ public void Test_align_strech_should_size_based_on_parent()
}

[Test]
public void Test_align_flex_start_with_shrinkin_children()
public void Test_align_flex_start_with_shrinking_children()
{
YogaConfig config = new YogaConfig();

YogaNode root = new YogaNode(config);
root.Width = 500;
root.Height = 500;

YogaNode root_child0 = new YogaNode(config);
root_child0.AlignItems = YogaAlign.FlexStart;
root.Insert(0, root_child0);

YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexShrink = 1;
root_child0.Insert(0, root_child0_child0);

YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.FlexGrow = 1;
root_child0_child0_child0.FlexShrink = 1;
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(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);

Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(0f, 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(0f, root_child0.LayoutHeight);

Assert.AreEqual(500f, 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);

Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutHeight);
}

[Test]
public void Test_align_flex_start_with_stretching_children()
{
YogaConfig config = new YogaConfig();

YogaNode root = new YogaNode(config);
root.Width = 500;
root.Height = 500;

YogaNode root_child0 = new YogaNode(config);
root.Insert(0, root_child0);

YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexShrink = 1;
root_child0.Insert(0, root_child0_child0);

YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.FlexGrow = 1;
root_child0_child0_child0.FlexShrink = 1;
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(0f, root_child0.LayoutHeight);

Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(500f, root_child0_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);

Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(500f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(0f, 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(0f, root_child0.LayoutHeight);

Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(500f, root_child0_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0_child0.LayoutHeight);

Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(500f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutHeight);
}

[Test]
public void Test_align_flex_start_with_shrinking_children_with_stretch()
{
YogaConfig config = new YogaConfig();

Expand Down
18 changes: 17 additions & 1 deletion gentest/fixtures/YGAlignItemsTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,26 @@
</div>
</div>

<div id="align_flex_start_with_shrinkin_children" style="height: 500px; width: 500px">
<div id="align_flex_start_with_shrinking_children" style="height: 500px; width: 500px">
<div style="align-items: flex-start;">
<div style="flex-grow: 1; flex-shrink: 1;">
<div style="flex-grow: 1; flex-shrink: 1;"></div>
</div>
</div>
</div>

<div id="align_flex_start_with_stretching_children" style="height: 500px; width: 500px">
<div style="align-items: strech;">
<div style="flex-grow: 1; flex-shrink: 1;">
<div style="flex-grow: 1; flex-shrink: 1;"></div>
</div>
</div>
</div>

<div id="align_flex_start_with_shrinking_children_with_stretch" style="height: 500px; width: 500px">
<div style="align-items: flex-start;">
<div style="flex-grow: 1; flex-shrink: 1; align-items: stretch;">
<div style="flex-grow: 1; flex-shrink: 1;"></div>
</div>
</div>
</div>
137 changes: 136 additions & 1 deletion java/tests/com/facebook/yoga/YGAlignItemsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,142 @@ public void test_align_strech_should_size_based_on_parent() {
}

@Test
public void test_align_flex_start_with_shrinkin_children() {
public void test_align_flex_start_with_shrinking_children() {
YogaConfig config = new YogaConfig();

final YogaNode root = new YogaNode(config);
root.setWidth(500f);
root.setHeight(500f);

final YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignItems(YogaAlign.FLEX_START);
root.addChildAt(root_child0, 0);

final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1f);
root_child0.addChildAt(root_child0_child0, 0);

final YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.setFlexGrow(1f);
root_child0_child0_child0.setFlexShrink(1f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);

assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);

root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);

assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);

assertEquals(500f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
}

@Test
public void test_align_flex_start_with_stretching_children() {
YogaConfig config = new YogaConfig();

final YogaNode root = new YogaNode(config);
root.setWidth(500f);
root.setHeight(500f);

final YogaNode root_child0 = new YogaNode(config);
root.addChildAt(root_child0, 0);

final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1f);
root_child0.addChildAt(root_child0_child0, 0);

final YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.setFlexGrow(1f);
root_child0_child0_child0.setFlexShrink(1f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);

assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);

root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);

assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(500f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
}

@Test
public void test_align_flex_start_with_shrinking_children_with_stretch() {
YogaConfig config = new YogaConfig();

final YogaNode root = new YogaNode(config);
Expand Down
Loading

0 comments on commit d32ff55

Please sign in to comment.