Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate gap space into main axis overflow flag #1173

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions csharp/tests/Facebook.Yoga/YGGapTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,110 @@ public void Test_column_gap_wrap_align_space_around()
Assert.AreEqual(20f, root_child5.LayoutHeight);
}

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

YogaNode root = new YogaNode(config);
root.FlexDirection = YogaFlexDirection.Row;
root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap;
root.Width = 300;
root.Height = 300;
root.ColumnGap = 5;

YogaNode root_child0 = new YogaNode(config);
root_child0.FlexGrow = 1;
root_child0.MinWidth = 60;
root.Insert(0, root_child0);

YogaNode root_child1 = new YogaNode(config);
root_child1.FlexGrow = 1;
root_child1.MinWidth = 60;
root.Insert(1, root_child1);

YogaNode root_child2 = new YogaNode(config);
root_child2.FlexGrow = 1;
root_child2.MinWidth = 60;
root.Insert(2, root_child2);

YogaNode root_child3 = new YogaNode(config);
root_child3.FlexGrow = 1;
root_child3.MinWidth = 60;
root.Insert(3, root_child3);

YogaNode root_child4 = new YogaNode(config);
root_child4.FlexGrow = 1;
root_child4.MinWidth = 60;
root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(300f, root.LayoutWidth);
Assert.AreEqual(300f, root.LayoutHeight);

Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(71f, root_child0.LayoutWidth);
Assert.AreEqual(150f, root_child0.LayoutHeight);

Assert.AreEqual(76f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(72f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);

Assert.AreEqual(153f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(71f, root_child2.LayoutWidth);
Assert.AreEqual(150f, root_child2.LayoutHeight);

Assert.AreEqual(229f, root_child3.LayoutX);
Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(71f, root_child3.LayoutWidth);
Assert.AreEqual(150f, root_child3.LayoutHeight);

Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(150f, root_child4.LayoutY);
Assert.AreEqual(300f, root_child4.LayoutWidth);
Assert.AreEqual(150f, root_child4.LayoutHeight);

root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();

Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(300f, root.LayoutWidth);
Assert.AreEqual(300f, root.LayoutHeight);

Assert.AreEqual(229f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(71f, root_child0.LayoutWidth);
Assert.AreEqual(150f, root_child0.LayoutHeight);

Assert.AreEqual(153f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(71f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);

Assert.AreEqual(76f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(72f, root_child2.LayoutWidth);
Assert.AreEqual(150f, root_child2.LayoutHeight);

Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(71f, root_child3.LayoutWidth);
Assert.AreEqual(150f, root_child3.LayoutHeight);

Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(150f, root_child4.LayoutY);
Assert.AreEqual(300f, root_child4.LayoutWidth);
Assert.AreEqual(150f, root_child4.LayoutHeight);
}

[Test]
public void Test_row_gap_align_items_stretch()
{
Expand Down
10 changes: 8 additions & 2 deletions gentest/fixtures/YGGapTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@
<div style="width: 20px; height: 20px"></div>
</div>

<div id="column_gap_wrap_align_stretch" style="flex-direction: row; flex-wrap: wrap; width: 300px; height: 300px; column-gap: 5px; align-content: stretch;">
<div style="min-width: 60px; flex-grow: 1;"></div>
<div style="min-width: 60px; flex-grow: 1;"></div>
<div style="min-width: 60px; flex-grow: 1;"></div>
<div style="min-width: 60px; flex-grow: 1;"></div>
<div style="min-width: 60px; flex-grow: 1;"></div>
</div>

<div id="row_gap_align_items_stretch" style="flex-direction: row; flex-wrap: wrap; width: 100px; height: 200px; column-gap: 10px; row-gap: 20px; align-items:stretch; align-content: stretch">
<div style="width: 20px; "></div>
<div style="width: 20px;"></div>
Expand All @@ -118,7 +126,6 @@
<div style="width: 20px;"></div>
</div>


<div id="row_gap_align_items_end" style="flex-direction: row; flex-wrap: wrap; width: 100px; height: 200px; column-gap: 10px; row-gap: 20px; align-items:flex-end;">
<div style="width: 20px; "></div>
<div style="width: 20px;"></div>
Expand All @@ -127,4 +134,3 @@
<div style="width: 20px;"></div>
<div style="width: 20px;"></div>
</div>

103 changes: 103 additions & 0 deletions java/tests/com/facebook/yoga/YGGapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,109 @@ public void test_column_gap_wrap_align_space_around() {
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
}

@Test
public void test_column_gap_wrap_align_stretch() {
YogaConfig config = YogaConfigFactory.create();

final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
root.setGap(YogaGutter.COLUMN, 5f);

final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMinWidth(60f);
root.addChildAt(root_child0, 0);

final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setMinWidth(60f);
root.addChildAt(root_child1, 1);

final YogaNode root_child2 = createNode(config);
root_child2.setFlexGrow(1f);
root_child2.setMinWidth(60f);
root.addChildAt(root_child2, 2);

final YogaNode root_child3 = createNode(config);
root_child3.setFlexGrow(1f);
root_child3.setMinWidth(60f);
root.addChildAt(root_child3, 3);

final YogaNode root_child4 = createNode(config);
root_child4.setFlexGrow(1f);
root_child4.setMinWidth(60f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);

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

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

assertEquals(76f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(72f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);

assertEquals(153f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(71f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child2.getLayoutHeight(), 0.0f);

assertEquals(229f, root_child3.getLayoutX(), 0.0f);
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(71f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child3.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(150f, root_child4.getLayoutY(), 0.0f);
assertEquals(300f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child4.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(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);

assertEquals(229f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(71f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);

assertEquals(153f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(71f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);

assertEquals(76f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(72f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child2.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(71f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child3.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(150f, root_child4.getLayoutY(), 0.0f);
assertEquals(300f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child4.getLayoutHeight(), 0.0f);
}

@Test
public void test_row_gap_align_items_stretch() {
YogaConfig config = YogaConfigFactory.create();
Expand Down
107 changes: 107 additions & 0 deletions javascript/tests/Facebook.Yoga/YGGapTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,113 @@ it("column_gap_wrap_align_space_around", function () {
config.free();
}
});
it("column_gap_wrap_align_stretch", function () {
var config = Yoga.Config.create();

try {
var root = Yoga.Node.create(config);
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root.setAlignContent(Yoga.ALIGN_STRETCH);
root.setFlexWrap(Yoga.WRAP_WRAP);
root.setWidth(300);
root.setHeight(300);
root.setGap(Yoga.GUTTER_COLUMN, 5);

var root_child0 = Yoga.Node.create(config);
root_child0.setFlexGrow(1);
root_child0.setMinWidth(60);
root.insertChild(root_child0, 0);

var root_child1 = Yoga.Node.create(config);
root_child1.setFlexGrow(1);
root_child1.setMinWidth(60);
root.insertChild(root_child1, 1);

var root_child2 = Yoga.Node.create(config);
root_child2.setFlexGrow(1);
root_child2.setMinWidth(60);
root.insertChild(root_child2, 2);

var root_child3 = Yoga.Node.create(config);
root_child3.setFlexGrow(1);
root_child3.setMinWidth(60);
root.insertChild(root_child3, 3);

var root_child4 = Yoga.Node.create(config);
root_child4.setFlexGrow(1);
root_child4.setMinWidth(60);
root.insertChild(root_child4, 4);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);

console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");

console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(71 === root_child0.getComputedWidth(), "71 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(150 === root_child0.getComputedHeight(), "150 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");

console.assert(76 === root_child1.getComputedLeft(), "76 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(72 === root_child1.getComputedWidth(), "72 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(150 === root_child1.getComputedHeight(), "150 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");

console.assert(153 === root_child2.getComputedLeft(), "153 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
console.assert(71 === root_child2.getComputedWidth(), "71 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
console.assert(150 === root_child2.getComputedHeight(), "150 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");

console.assert(229 === root_child3.getComputedLeft(), "229 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
console.assert(71 === root_child3.getComputedWidth(), "71 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
console.assert(150 === root_child3.getComputedHeight(), "150 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");

console.assert(0 === root_child4.getComputedLeft(), "0 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
console.assert(150 === root_child4.getComputedTop(), "150 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
console.assert(300 === root_child4.getComputedWidth(), "300 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
console.assert(150 === root_child4.getComputedHeight(), "150 === root_child4.getComputedHeight() (" + root_child4.getComputedHeight() + ")");

root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);

console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");

console.assert(229 === root_child0.getComputedLeft(), "229 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(71 === root_child0.getComputedWidth(), "71 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(150 === root_child0.getComputedHeight(), "150 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");

console.assert(153 === root_child1.getComputedLeft(), "153 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(71 === root_child1.getComputedWidth(), "71 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(150 === root_child1.getComputedHeight(), "150 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");

console.assert(76 === root_child2.getComputedLeft(), "76 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
console.assert(72 === root_child2.getComputedWidth(), "72 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
console.assert(150 === root_child2.getComputedHeight(), "150 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");

console.assert(0 === root_child3.getComputedLeft(), "0 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
console.assert(71 === root_child3.getComputedWidth(), "71 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
console.assert(150 === root_child3.getComputedHeight(), "150 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");

console.assert(0 === root_child4.getComputedLeft(), "0 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
console.assert(150 === root_child4.getComputedTop(), "150 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
console.assert(300 === root_child4.getComputedWidth(), "300 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
console.assert(150 === root_child4.getComputedHeight(), "150 === root_child4.getComputedHeight() (" + root_child4.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}

config.free();
}
});
it("row_gap_align_items_stretch", function () {
var config = Yoga.Config.create();

Expand Down
Loading