flex_shrink_flex_grow_row and flex_shrink_flex_grow_child_flex_shrink_other_child tests were directly added in YGFlexTest.cpp, Added these in YGFlexTest.html so that they can generated accordingly in all different langauges via gentest ruby script
Summary: @public `flex_shrink_flex_grow_row` and `flex_shrink_flex_grow_child_flex_shrink_other_child` tests were present in YGFlexTest.cpp. When running ruby script to generate tests, these were getting removed since they were not added in YGFlexTest.html using which tests are generated. This diff adds tests in YGFlexTest.html and contains corresponding generated test cases for different languages. Reviewed By: priteshrnandgaonkar Differential Revision: D12838701 fbshipit-source-id: 5e92716d94fa392230db2c0ec3b8c131a089c55a
This commit is contained in:
committed by
Facebook Github Bot
parent
d02f4a94de
commit
a2ef8978cd
@@ -69,6 +69,123 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
Assert.AreEqual(25f, root_child1.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_flex_shrink_flex_grow_row()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root.Width = 500;
|
||||||
|
root.Height = 500;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexShrink = 1;
|
||||||
|
root_child0.Width = 500;
|
||||||
|
root_child0.Height = 100;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1 = new YogaNode(config);
|
||||||
|
root_child1.FlexShrink = 1;
|
||||||
|
root_child1.Width = 500;
|
||||||
|
root_child1.Height = 100;
|
||||||
|
root.Insert(1, root_child1);
|
||||||
|
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(250f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(250f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child1.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(250f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_flex_shrink_flex_grow_child_flex_shrink_other_child()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root.Width = 500;
|
||||||
|
root.Height = 500;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.FlexShrink = 1;
|
||||||
|
root_child0.Width = 500;
|
||||||
|
root_child0.Height = 100;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child1 = new YogaNode(config);
|
||||||
|
root_child1.FlexGrow = 1;
|
||||||
|
root_child1.FlexShrink = 1;
|
||||||
|
root_child1.Width = 500;
|
||||||
|
root_child1.Height = 100;
|
||||||
|
root.Insert(1, root_child1);
|
||||||
|
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(250f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(250f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child1.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(250f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child1.LayoutY);
|
||||||
|
Assert.AreEqual(250f, root_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root_child1.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_flex_basis_flex_grow_row()
|
public void Test_flex_basis_flex_grow_row()
|
||||||
{
|
{
|
||||||
|
@@ -3,6 +3,16 @@
|
|||||||
<div style="flex-grow: 1;"></div>
|
<div style="flex-grow: 1;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="flex_shrink_flex_grow_row" style="width: 500px; height: 500px; flex-direction: row;">
|
||||||
|
<div style="width: 500px; height: 100px; flex-grow: 0; flex-shrink: 1;"></div>
|
||||||
|
<div style="width: 500px; height: 100px; flex-grow: 0; flex-shrink: 1;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="flex_shrink_flex_grow_child_flex_shrink_other_child" style="width: 500px; height: 500px; flex-direction: row;">
|
||||||
|
<div style="width: 500px; height: 100px; flex-grow: 0; flex-shrink: 1;"></div>
|
||||||
|
<div style="width: 500px; height: 100px; flex-grow: 1; flex-shrink: 1;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
|
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||||
<div style="flex-basis: 50px; flex-grow: 1;"></div>
|
<div style="flex-basis: 50px; flex-grow: 1;"></div>
|
||||||
<div style="flex-grow: 1;"></div>
|
<div style="flex-grow: 1;"></div>
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
|
||||||
|
|
||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
@@ -77,6 +76,121 @@ public class YGFlexTest {
|
|||||||
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_flex_shrink_flex_grow_row() {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root.setWidth(500f);
|
||||||
|
root.setHeight(500f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexShrink(1f);
|
||||||
|
root_child0.setWidth(500f);
|
||||||
|
root_child0.setHeight(100f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child1 = createNode(config);
|
||||||
|
root_child1.setFlexShrink(1f);
|
||||||
|
root_child1.setWidth(500f);
|
||||||
|
root_child1.setHeight(100f);
|
||||||
|
root.addChildAt(root_child1, 1);
|
||||||
|
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(250f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(250f, root_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child1.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(250f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(250f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_flex_shrink_flex_grow_child_flex_shrink_other_child() {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
final YogaNode root = createNode(config);
|
||||||
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root.setWidth(500f);
|
||||||
|
root.setHeight(500f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = createNode(config);
|
||||||
|
root_child0.setFlexShrink(1f);
|
||||||
|
root_child0.setWidth(500f);
|
||||||
|
root_child0.setHeight(100f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child1 = createNode(config);
|
||||||
|
root_child1.setFlexGrow(1f);
|
||||||
|
root_child1.setFlexShrink(1f);
|
||||||
|
root_child1.setWidth(500f);
|
||||||
|
root_child1.setHeight(100f);
|
||||||
|
root.addChildAt(root_child1, 1);
|
||||||
|
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(250f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(250f, root_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child1.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(250f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(250f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(250f, root_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_flex_basis_flex_grow_row() {
|
public void test_flex_basis_flex_grow_row() {
|
||||||
YogaConfig config = new YogaConfig();
|
YogaConfig config = new YogaConfig();
|
||||||
|
@@ -66,6 +66,129 @@ it("flex_basis_flex_grow_column", function () {
|
|||||||
config.free();
|
config.free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
it("flex_shrink_flex_grow_row", function () {
|
||||||
|
var config = Yoga.Config.create();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var root = Yoga.Node.create(config);
|
||||||
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root.setWidth(500);
|
||||||
|
root.setHeight(500);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexShrink(1);
|
||||||
|
root_child0.setWidth(500);
|
||||||
|
root_child0.setHeight(100);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child1 = Yoga.Node.create(config);
|
||||||
|
root_child1.setFlexShrink(1);
|
||||||
|
root_child1.setWidth(500);
|
||||||
|
root_child1.setHeight(100);
|
||||||
|
root.insertChild(root_child1, 1);
|
||||||
|
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(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(500 === root.getComputedHeight(), "500 === 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(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||||
|
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.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(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||||
|
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== "undefined") {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("flex_shrink_flex_grow_child_flex_shrink_other_child", function () {
|
||||||
|
var config = Yoga.Config.create();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var root = Yoga.Node.create(config);
|
||||||
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root.setWidth(500);
|
||||||
|
root.setHeight(500);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setFlexShrink(1);
|
||||||
|
root_child0.setWidth(500);
|
||||||
|
root_child0.setHeight(100);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child1 = Yoga.Node.create(config);
|
||||||
|
root_child1.setFlexGrow(1);
|
||||||
|
root_child1.setFlexShrink(1);
|
||||||
|
root_child1.setWidth(500);
|
||||||
|
root_child1.setHeight(100);
|
||||||
|
root.insertChild(root_child1, 1);
|
||||||
|
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(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(500 === root.getComputedHeight(), "500 === 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(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(250 === root_child1.getComputedLeft(), "250 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||||
|
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.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(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(250 === root_child0.getComputedWidth(), "250 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
||||||
|
console.assert(250 === root_child1.getComputedWidth(), "250 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== "undefined") {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
it("flex_basis_flex_grow_row", function () {
|
it("flex_basis_flex_grow_row", function () {
|
||||||
var config = Yoga.Config.create();
|
var config = Yoga.Config.create();
|
||||||
|
|
||||||
|
@@ -73,14 +73,12 @@ TEST(YogaTest, flex_shrink_flex_grow_row) {
|
|||||||
YGNodeStyleSetHeight(root, 500);
|
YGNodeStyleSetHeight(root, 500);
|
||||||
|
|
||||||
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
YGNodeStyleSetFlexGrow(root_child0, 0);
|
|
||||||
YGNodeStyleSetFlexShrink(root_child0, 1);
|
YGNodeStyleSetFlexShrink(root_child0, 1);
|
||||||
YGNodeStyleSetWidth(root_child0, 500);
|
YGNodeStyleSetWidth(root_child0, 500);
|
||||||
YGNodeStyleSetHeight(root_child0, 100);
|
YGNodeStyleSetHeight(root_child0, 100);
|
||||||
YGNodeInsertChild(root, root_child0, 0);
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
||||||
YGNodeStyleSetFlexGrow(root_child1, 0);
|
|
||||||
YGNodeStyleSetFlexShrink(root_child1, 1);
|
YGNodeStyleSetFlexShrink(root_child1, 1);
|
||||||
YGNodeStyleSetWidth(root_child1, 500);
|
YGNodeStyleSetWidth(root_child1, 500);
|
||||||
YGNodeStyleSetHeight(root_child1, 100);
|
YGNodeStyleSetHeight(root_child1, 100);
|
||||||
@@ -101,6 +99,24 @@ TEST(YogaTest, flex_shrink_flex_grow_row) {
|
|||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||||
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
@@ -115,7 +131,6 @@ TEST(YogaTest, flex_shrink_flex_grow_child_flex_shrink_other_child) {
|
|||||||
YGNodeStyleSetHeight(root, 500);
|
YGNodeStyleSetHeight(root, 500);
|
||||||
|
|
||||||
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
YGNodeStyleSetFlexGrow(root_child0, 0);
|
|
||||||
YGNodeStyleSetFlexShrink(root_child0, 1);
|
YGNodeStyleSetFlexShrink(root_child0, 1);
|
||||||
YGNodeStyleSetWidth(root_child0, 500);
|
YGNodeStyleSetWidth(root_child0, 500);
|
||||||
YGNodeStyleSetHeight(root_child0, 100);
|
YGNodeStyleSetHeight(root_child0, 100);
|
||||||
@@ -143,6 +158,24 @@ TEST(YogaTest, flex_shrink_flex_grow_child_flex_shrink_other_child) {
|
|||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||||
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
|
||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
|
Reference in New Issue
Block a user