Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1715 X-link: https://github.com/facebook/react-native/pull/46799 Content box impl had a bug where we resolved padding % against the same reference length as the dimensions. Padding should always be against containing block's width. This is also true for width, but not for height, which should be against containing block's height. This just pipes the width into our box sizing functions. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D63787577 fbshipit-source-id: e512338770f25b66506cabab5a7cde8f04397ea0
2513 lines
98 KiB
Java
2513 lines
98 KiB
Java
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @generated SignedSource<<7f42121bbd9772cdbc079aac71040dcc>>
|
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html
|
|
*/
|
|
|
|
package com.facebook.yoga;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import org.junit.Ignore;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runners.Parameterized;
|
|
import com.facebook.yoga.utils.TestUtils;
|
|
|
|
@RunWith(Parameterized.class)
|
|
public class YGBoxSizingTest {
|
|
@Parameterized.Parameters(name = "{0}")
|
|
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
|
|
return TestParametrization.nodeFactories();
|
|
}
|
|
|
|
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_simple() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 5);
|
|
root.setPadding(YogaEdge.TOP, 5);
|
|
root.setPadding(YogaEdge.RIGHT, 5);
|
|
root.setPadding(YogaEdge.BOTTOM, 5);
|
|
root.setBorder(YogaEdge.LEFT, 10f);
|
|
root.setBorder(YogaEdge.TOP, 10f);
|
|
root.setBorder(YogaEdge.RIGHT, 10f);
|
|
root.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(130f, root.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(130f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(130f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_simple() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 5);
|
|
root.setPadding(YogaEdge.TOP, 5);
|
|
root.setPadding(YogaEdge.RIGHT, 5);
|
|
root.setPadding(YogaEdge.BOTTOM, 5);
|
|
root.setBorder(YogaEdge.LEFT, 10f);
|
|
root.setBorder(YogaEdge.TOP, 10f);
|
|
root.setBorder(YogaEdge.RIGHT, 10f);
|
|
root.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_percent() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 4);
|
|
root_child0.setPadding(YogaEdge.TOP, 4);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 4);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 4);
|
|
root_child0.setBorder(YogaEdge.LEFT, 16f);
|
|
root_child0.setBorder(YogaEdge.TOP, 16f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 16f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 16f);
|
|
root_child0.setWidthPercent(50f);
|
|
root_child0.setHeightPercent(25f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_percent() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 4);
|
|
root_child0.setPadding(YogaEdge.TOP, 4);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 4);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 4);
|
|
root_child0.setBorder(YogaEdge.LEFT, 16f);
|
|
root_child0.setBorder(YogaEdge.TOP, 16f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 16f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 16f);
|
|
root_child0.setWidthPercent(50f);
|
|
root_child0.setHeightPercent(25f);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_absolute() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root_child0.setPadding(YogaEdge.LEFT, 12);
|
|
root_child0.setPadding(YogaEdge.TOP, 12);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 12);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 12);
|
|
root_child0.setBorder(YogaEdge.LEFT, 8f);
|
|
root_child0.setBorder(YogaEdge.TOP, 8f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 8f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 8f);
|
|
root_child0.setHeightPercent(25f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_absolute() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root_child0.setPadding(YogaEdge.LEFT, 12);
|
|
root_child0.setPadding(YogaEdge.TOP, 12);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 12);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 12);
|
|
root_child0.setBorder(YogaEdge.LEFT, 8f);
|
|
root_child0.setBorder(YogaEdge.TOP, 8f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 8f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 8f);
|
|
root_child0.setHeightPercent(25f);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_comtaining_block() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 12);
|
|
root.setPadding(YogaEdge.TOP, 12);
|
|
root.setPadding(YogaEdge.RIGHT, 12);
|
|
root.setPadding(YogaEdge.BOTTOM, 12);
|
|
root.setBorder(YogaEdge.LEFT, 8f);
|
|
root.setBorder(YogaEdge.TOP, 8f);
|
|
root.setBorder(YogaEdge.RIGHT, 8f);
|
|
root.setBorder(YogaEdge.BOTTOM, 8f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPositionType(YogaPositionType.STATIC);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child0_child0 = createNode(config);
|
|
root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root_child0_child0.setWidth(50f);
|
|
root_child0_child0.setHeightPercent(25f);
|
|
root_child0.addChildAt(root_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(140f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(140f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, 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(50f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(31f, root_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(140f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(140f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(31f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_comtaining_block() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 12);
|
|
root.setPadding(YogaEdge.TOP, 12);
|
|
root.setPadding(YogaEdge.RIGHT, 12);
|
|
root.setPadding(YogaEdge.BOTTOM, 12);
|
|
root.setBorder(YogaEdge.LEFT, 8f);
|
|
root.setBorder(YogaEdge.TOP, 8f);
|
|
root.setBorder(YogaEdge.RIGHT, 8f);
|
|
root.setBorder(YogaEdge.BOTTOM, 8f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPositionType(YogaPositionType.STATIC);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child0_child0 = createNode(config);
|
|
root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root_child0_child0.setWidth(50f);
|
|
root_child0_child0.setHeightPercent(25f);
|
|
root_child0.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(60f, 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(50f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(21f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(21f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_padding_only() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 5);
|
|
root.setPadding(YogaEdge.TOP, 5);
|
|
root.setPadding(YogaEdge.RIGHT, 5);
|
|
root.setPadding(YogaEdge.BOTTOM, 5);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(110f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(110f, root.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(110f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(110f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_padding_only_percent() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(150f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPaddingPercent(YogaEdge.LEFT, 10);
|
|
root_child0.setPaddingPercent(YogaEdge.TOP, 10);
|
|
root_child0.setPaddingPercent(YogaEdge.RIGHT, 10);
|
|
root_child0.setPaddingPercent(YogaEdge.BOTTOM, 10);
|
|
root_child0.setWidth(50f);
|
|
root_child0.setHeight(75f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(150f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(70f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(95f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(150f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(30f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(70f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(95f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_padding_only() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 5);
|
|
root.setPadding(YogaEdge.TOP, 5);
|
|
root.setPadding(YogaEdge.RIGHT, 5);
|
|
root.setPadding(YogaEdge.BOTTOM, 5);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_padding_only_percent() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(150f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPaddingPercent(YogaEdge.LEFT, 10);
|
|
root_child0.setPaddingPercent(YogaEdge.TOP, 10);
|
|
root_child0.setPaddingPercent(YogaEdge.RIGHT, 10);
|
|
root_child0.setPaddingPercent(YogaEdge.BOTTOM, 10);
|
|
root_child0.setWidth(50f);
|
|
root_child0.setHeight(75f);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(150f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(75f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(150f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_border_only() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setBorder(YogaEdge.LEFT, 10f);
|
|
root.setBorder(YogaEdge.TOP, 10f);
|
|
root.setBorder(YogaEdge.RIGHT, 10f);
|
|
root.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(120f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(120f, root.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(120f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(120f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_border_only_percent() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setWidthPercent(50f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(0f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_border_only() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setBorder(YogaEdge.LEFT, 10f);
|
|
root.setBorder(YogaEdge.TOP, 10f);
|
|
root.setBorder(YogaEdge.RIGHT, 10f);
|
|
root.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_border_only_percent() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setWidthPercent(50f);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(0f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_no_padding_no_border() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_no_padding_no_border() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_children() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 5);
|
|
root.setPadding(YogaEdge.TOP, 5);
|
|
root.setPadding(YogaEdge.RIGHT, 5);
|
|
root.setPadding(YogaEdge.BOTTOM, 5);
|
|
root.setBorder(YogaEdge.LEFT, 10f);
|
|
root.setBorder(YogaEdge.TOP, 10f);
|
|
root.setBorder(YogaEdge.RIGHT, 10f);
|
|
root.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setWidth(25f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
root_child2.setWidth(25f);
|
|
root_child2.setHeight(25f);
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
root_child3.setWidth(25f);
|
|
root_child3.setHeight(25f);
|
|
root.addChildAt(root_child3, 3);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(130f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(130f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.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(130f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(130f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(90f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(90f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(90f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_children() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 5);
|
|
root.setPadding(YogaEdge.TOP, 5);
|
|
root.setPadding(YogaEdge.RIGHT, 5);
|
|
root.setPadding(YogaEdge.BOTTOM, 5);
|
|
root.setBorder(YogaEdge.LEFT, 10f);
|
|
root.setBorder(YogaEdge.TOP, 10f);
|
|
root.setBorder(YogaEdge.RIGHT, 10f);
|
|
root.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setWidth(25f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
root_child2.setWidth(25f);
|
|
root_child2.setHeight(25f);
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
root_child3.setWidth(25f);
|
|
root_child3.setHeight(25f);
|
|
root.addChildAt(root_child3, 3);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(15f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(60f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(60f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_siblings() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setWidth(25f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setPadding(YogaEdge.LEFT, 10);
|
|
root_child1.setPadding(YogaEdge.TOP, 10);
|
|
root_child1.setPadding(YogaEdge.RIGHT, 10);
|
|
root_child1.setPadding(YogaEdge.BOTTOM, 10);
|
|
root_child1.setBorder(YogaEdge.LEFT, 10f);
|
|
root_child1.setBorder(YogaEdge.TOP, 10f);
|
|
root_child1.setBorder(YogaEdge.RIGHT, 10f);
|
|
root_child1.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
root_child1.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
root_child2.setWidth(25f);
|
|
root_child2.setHeight(25f);
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
root_child3.setWidth(25f);
|
|
root_child3.setHeight(25f);
|
|
root.addChildAt(root_child3, 3);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(115f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(35f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(115f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_siblings() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setWidth(25f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setPadding(YogaEdge.LEFT, 10);
|
|
root_child1.setPadding(YogaEdge.TOP, 10);
|
|
root_child1.setPadding(YogaEdge.RIGHT, 10);
|
|
root_child1.setPadding(YogaEdge.BOTTOM, 10);
|
|
root_child1.setBorder(YogaEdge.LEFT, 10f);
|
|
root_child1.setBorder(YogaEdge.TOP, 10f);
|
|
root_child1.setBorder(YogaEdge.RIGHT, 10f);
|
|
root_child1.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
root_child2.setWidth(25f);
|
|
root_child2.setHeight(25f);
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
root_child3.setWidth(25f);
|
|
root_child3.setHeight(25f);
|
|
root.addChildAt(root_child3, 3);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(60f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child2.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child2.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child3.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child3.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child3.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_max_width() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setMaxWidth(50f);
|
|
root_child0.setHeight(25f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_max_width() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setMaxWidth(50f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_max_height() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setWidth(50f);
|
|
root_child0.setMaxHeight(50f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_max_height() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setWidth(50f);
|
|
root_child0.setMaxHeight(50f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_min_width() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setMinWidth(50f);
|
|
root_child0.setHeight(25f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(65f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(65f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_min_width() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setMinWidth(50f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_min_height() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setWidth(50f);
|
|
root_child0.setMinHeight(50f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(90f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_min_height() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 15f);
|
|
root_child0.setBorder(YogaEdge.TOP, 15f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 15f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 15f);
|
|
root_child0.setWidth(50f);
|
|
root_child0.setMinHeight(50f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
root_child1.setWidth(25f);
|
|
root_child1.setHeight(25f);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
|
|
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_no_height_no_width() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 2);
|
|
root_child0.setPadding(YogaEdge.TOP, 2);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 2);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 2);
|
|
root_child0.setBorder(YogaEdge.LEFT, 7f);
|
|
root_child0.setBorder(YogaEdge.TOP, 7f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 7f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 7f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(18f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(18f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_no_height_no_width() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 2);
|
|
root_child0.setPadding(YogaEdge.TOP, 2);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 2);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 2);
|
|
root_child0.setBorder(YogaEdge.LEFT, 7f);
|
|
root_child0.setBorder(YogaEdge.TOP, 7f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 7f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 7f);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(18f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(18f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_nested() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 15);
|
|
root.setPadding(YogaEdge.TOP, 15);
|
|
root.setPadding(YogaEdge.RIGHT, 15);
|
|
root.setPadding(YogaEdge.BOTTOM, 15);
|
|
root.setBorder(YogaEdge.LEFT, 3f);
|
|
root.setBorder(YogaEdge.TOP, 3f);
|
|
root.setBorder(YogaEdge.RIGHT, 3f);
|
|
root.setBorder(YogaEdge.BOTTOM, 3f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 2);
|
|
root_child0.setPadding(YogaEdge.TOP, 2);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 2);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 2);
|
|
root_child0.setBorder(YogaEdge.LEFT, 7f);
|
|
root_child0.setBorder(YogaEdge.TOP, 7f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 7f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 7f);
|
|
root_child0.setWidth(20f);
|
|
root_child0.setHeight(20f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child0_child0 = createNode(config);
|
|
root_child0_child0.setPadding(YogaEdge.LEFT, 1);
|
|
root_child0_child0.setPadding(YogaEdge.TOP, 1);
|
|
root_child0_child0.setPadding(YogaEdge.RIGHT, 1);
|
|
root_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
|
|
root_child0_child0.setBorder(YogaEdge.LEFT, 2f);
|
|
root_child0_child0.setBorder(YogaEdge.TOP, 2f);
|
|
root_child0_child0.setBorder(YogaEdge.RIGHT, 2f);
|
|
root_child0_child0.setBorder(YogaEdge.BOTTOM, 2f);
|
|
root_child0_child0.setWidth(10f);
|
|
root_child0_child0.setHeight(5f);
|
|
root_child0_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root_child0.addChildAt(root_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(136f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(136f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(18f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(18f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(38f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(38f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(9f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(16f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(11f, root_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(136f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(136f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(18f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(38f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(38f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(13f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(16f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(11f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_nested() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 15);
|
|
root.setPadding(YogaEdge.TOP, 15);
|
|
root.setPadding(YogaEdge.RIGHT, 15);
|
|
root.setPadding(YogaEdge.BOTTOM, 15);
|
|
root.setBorder(YogaEdge.LEFT, 3f);
|
|
root.setBorder(YogaEdge.TOP, 3f);
|
|
root.setBorder(YogaEdge.RIGHT, 3f);
|
|
root.setBorder(YogaEdge.BOTTOM, 3f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 2);
|
|
root_child0.setPadding(YogaEdge.TOP, 2);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 2);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 2);
|
|
root_child0.setBorder(YogaEdge.LEFT, 7f);
|
|
root_child0.setBorder(YogaEdge.TOP, 7f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 7f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 7f);
|
|
root_child0.setWidth(20f);
|
|
root_child0.setHeight(20f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child0_child0 = createNode(config);
|
|
root_child0_child0.setPadding(YogaEdge.LEFT, 1);
|
|
root_child0_child0.setPadding(YogaEdge.TOP, 1);
|
|
root_child0_child0.setPadding(YogaEdge.RIGHT, 1);
|
|
root_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
|
|
root_child0_child0.setBorder(YogaEdge.LEFT, 2f);
|
|
root_child0_child0.setBorder(YogaEdge.TOP, 2f);
|
|
root_child0_child0.setBorder(YogaEdge.RIGHT, 2f);
|
|
root_child0_child0.setBorder(YogaEdge.BOTTOM, 2f);
|
|
root_child0_child0.setWidth(10f);
|
|
root_child0_child0.setHeight(5f);
|
|
root_child0.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(18f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(18f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(9f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(6f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(18f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(1f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(6f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_nested_alternating() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 3);
|
|
root.setPadding(YogaEdge.TOP, 3);
|
|
root.setPadding(YogaEdge.RIGHT, 3);
|
|
root.setPadding(YogaEdge.BOTTOM, 3);
|
|
root.setBorder(YogaEdge.LEFT, 2f);
|
|
root.setBorder(YogaEdge.TOP, 2f);
|
|
root.setBorder(YogaEdge.RIGHT, 2f);
|
|
root.setBorder(YogaEdge.BOTTOM, 2f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 8);
|
|
root_child0.setPadding(YogaEdge.TOP, 8);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 8);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 8);
|
|
root_child0.setBorder(YogaEdge.LEFT, 2f);
|
|
root_child0.setBorder(YogaEdge.TOP, 2f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 2f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 2f);
|
|
root_child0.setWidth(40f);
|
|
root_child0.setHeight(40f);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child0_child0 = createNode(config);
|
|
root_child0_child0.setPadding(YogaEdge.LEFT, 3);
|
|
root_child0_child0.setPadding(YogaEdge.TOP, 3);
|
|
root_child0_child0.setPadding(YogaEdge.RIGHT, 3);
|
|
root_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
|
|
root_child0_child0.setBorder(YogaEdge.LEFT, 6f);
|
|
root_child0_child0.setBorder(YogaEdge.TOP, 6f);
|
|
root_child0_child0.setBorder(YogaEdge.RIGHT, 6f);
|
|
root_child0_child0.setBorder(YogaEdge.BOTTOM, 6f);
|
|
root_child0_child0.setWidth(20f);
|
|
root_child0_child0.setHeight(25f);
|
|
root_child0_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root_child0.addChildAt(root_child0_child0, 0);
|
|
|
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
|
root_child0_child0_child0.setPadding(YogaEdge.LEFT, 1);
|
|
root_child0_child0_child0.setPadding(YogaEdge.TOP, 1);
|
|
root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 1);
|
|
root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
|
|
root_child0_child0_child0.setBorder(YogaEdge.LEFT, 1f);
|
|
root_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
|
|
root_child0_child0_child0.setBorder(YogaEdge.RIGHT, 1f);
|
|
root_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 1f);
|
|
root_child0_child0_child0.setWidth(10f);
|
|
root_child0_child0_child0.setHeight(5f);
|
|
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(110f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(110f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(38f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(43f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(9f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(10f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(5f, 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(110f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(110f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(65f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(-8f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(38f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(43f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(19f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(10f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(5f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_nested_alternating() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.LEFT, 3);
|
|
root.setPadding(YogaEdge.TOP, 3);
|
|
root.setPadding(YogaEdge.RIGHT, 3);
|
|
root.setPadding(YogaEdge.BOTTOM, 3);
|
|
root.setBorder(YogaEdge.LEFT, 2f);
|
|
root.setBorder(YogaEdge.TOP, 2f);
|
|
root.setBorder(YogaEdge.RIGHT, 2f);
|
|
root.setBorder(YogaEdge.BOTTOM, 2f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setPadding(YogaEdge.LEFT, 8);
|
|
root_child0.setPadding(YogaEdge.TOP, 8);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 8);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 8);
|
|
root_child0.setBorder(YogaEdge.LEFT, 2f);
|
|
root_child0.setBorder(YogaEdge.TOP, 2f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 2f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 2f);
|
|
root_child0.setWidth(40f);
|
|
root_child0.setHeight(40f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
final YogaNode root_child0_child0 = createNode(config);
|
|
root_child0_child0.setPadding(YogaEdge.LEFT, 3);
|
|
root_child0_child0.setPadding(YogaEdge.TOP, 3);
|
|
root_child0_child0.setPadding(YogaEdge.RIGHT, 3);
|
|
root_child0_child0.setPadding(YogaEdge.BOTTOM, 3);
|
|
root_child0_child0.setBorder(YogaEdge.LEFT, 6f);
|
|
root_child0_child0.setBorder(YogaEdge.TOP, 6f);
|
|
root_child0_child0.setBorder(YogaEdge.RIGHT, 6f);
|
|
root_child0_child0.setBorder(YogaEdge.BOTTOM, 6f);
|
|
root_child0_child0.setWidth(20f);
|
|
root_child0_child0.setHeight(25f);
|
|
root_child0.addChildAt(root_child0_child0, 0);
|
|
|
|
final YogaNode root_child0_child0_child0 = createNode(config);
|
|
root_child0_child0_child0.setPadding(YogaEdge.LEFT, 1);
|
|
root_child0_child0_child0.setPadding(YogaEdge.TOP, 1);
|
|
root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 1);
|
|
root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 1);
|
|
root_child0_child0_child0.setBorder(YogaEdge.LEFT, 1f);
|
|
root_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
|
|
root_child0_child0_child0.setBorder(YogaEdge.RIGHT, 1f);
|
|
root_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 1f);
|
|
root_child0_child0_child0.setWidth(10f);
|
|
root_child0_child0_child0.setHeight(5f);
|
|
root_child0_child0_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(9f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(14f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(9f, 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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(35f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(30f, root_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(-3f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
|
assertEquals(9f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
|
assertEquals(14f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(9f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
@Ignore
|
|
public void test_box_sizing_content_box_flex_basis_row() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setFlexBasis(50f);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 10f);
|
|
root_child0.setBorder(YogaEdge.TOP, 10f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 10f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root_child0.setHeight(25f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(55f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(55f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_flex_basis_row() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setFlexBasis(50f);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 10f);
|
|
root_child0.setBorder(YogaEdge.TOP, 10f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 10f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(30f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(30f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
@Ignore
|
|
public void test_box_sizing_content_box_flex_basis_column() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setFlexBasis(50f);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 10f);
|
|
root_child0.setBorder(YogaEdge.TOP, 10f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 10f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root_child0.setHeight(25f);
|
|
root_child0.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(80f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_flex_basis_column() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
root_child0.setFlexBasis(50f);
|
|
root_child0.setPadding(YogaEdge.LEFT, 5);
|
|
root_child0.setPadding(YogaEdge.TOP, 5);
|
|
root_child0.setPadding(YogaEdge.RIGHT, 5);
|
|
root_child0.setPadding(YogaEdge.BOTTOM, 5);
|
|
root_child0.setBorder(YogaEdge.LEFT, 10f);
|
|
root_child0.setBorder(YogaEdge.TOP, 10f);
|
|
root_child0.setBorder(YogaEdge.RIGHT, 10f);
|
|
root_child0.setBorder(YogaEdge.BOTTOM, 10f);
|
|
root_child0.setHeight(25f);
|
|
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(50f, root_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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_padding_start() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.START, 5);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_padding_start() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.START, 5);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_padding_end() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.END, 5);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_padding_end() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setPadding(YogaEdge.END, 5);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_border_start() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setBorder(YogaEdge.START, 5f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_border_start() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setBorder(YogaEdge.START, 5f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_content_box_border_end() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setBorder(YogaEdge.END, 5f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setBoxSizing(YogaBoxSizing.CONTENT_BOX);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(105f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
@Test
|
|
public void test_box_sizing_border_box_border_end() {
|
|
YogaConfig config = YogaConfigFactory.create();
|
|
|
|
final YogaNode root = createNode(config);
|
|
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
root.setBorder(YogaEdge.END, 5f);
|
|
root.setWidth(100f);
|
|
root.setHeight(100f);
|
|
root.setDirection(YogaDirection.LTR);
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
}
|
|
|
|
private YogaNode createNode(YogaConfig config) {
|
|
return mNodeFactory.create(config);
|
|
}
|
|
}
|