From a3a483aa1a317d8692f11d58810a3914c35c5731 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Wed, 25 Sep 2024 12:24:29 -0700 Subject: [PATCH] Add more fixtures for box sizing (#1702) Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1702 tsia Reviewed By: jorge-cab Differential Revision: D63151874 --- gentest/fixtures/YGBoxSizingTest.html | 142 ++ .../com/facebook/yoga/YGBoxSizingTest.java | 1561 ++++++++++++++- .../tests/generated/YGBoxSizingTest.test.ts | 1673 ++++++++++++++++- tests/generated/YGBoxSizingTest.cpp | 1599 +++++++++++++++- 4 files changed, 4972 insertions(+), 3 deletions(-) diff --git a/gentest/fixtures/YGBoxSizingTest.html b/gentest/fixtures/YGBoxSizingTest.html index ce88f52306..a0a57185e4 100644 --- a/gentest/fixtures/YGBoxSizingTest.html +++ b/gentest/fixtures/YGBoxSizingTest.html @@ -1,3 +1,145 @@
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
diff --git a/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java b/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java index edc5b14bba..2cffa0a957 100644 --- a/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java +++ b/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1b72c10a32dce3a330fae20103be9846>> + * @generated SignedSource<<84bb16d1a7ae39fb8f159ee58baef4c2>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html */ @@ -62,6 +62,1565 @@ public void test_box_sizing_content_box() { assertEquals(130f, root.getLayoutHeight(), 0.0f); } + @Test + public void test_box_sizing_border_box() { + 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 + @Ignore + 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_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 + @Ignore + 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_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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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 + @Ignore + 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); + } + private YogaNode createNode(YogaConfig config) { return mNodeFactory.create(config); } diff --git a/javascript/tests/generated/YGBoxSizingTest.test.ts b/javascript/tests/generated/YGBoxSizingTest.test.ts index 55e618526c..4fd75be153 100644 --- a/javascript/tests/generated/YGBoxSizingTest.test.ts +++ b/javascript/tests/generated/YGBoxSizingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<40a2a45449f152b9c1f91adfc46ac6df>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html */ @@ -67,3 +67,1674 @@ test.skip('box_sizing_content_box', () => { config.free(); } }); +test('box_sizing_border_box', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_padding_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_padding_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_border_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_border_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_no_padding_no_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_no_padding_no_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(15); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(15); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(90); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(15); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(15); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_siblings', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setBorder(Edge.Left, 10); + root_child1.setBorder(Edge.Top, 10); + root_child1.setBorder(Edge.Right, 10); + root_child1.setBorder(Edge.Bottom, 10); + root_child1.setWidth(25); + root_child1.setHeight(25); + root_child1.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(65); + expect(root_child1.getComputedHeight()).toBe(65); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(115); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(35); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(65); + expect(root_child1.getComputedHeight()).toBe(65); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(75); + expect(root_child3.getComputedTop()).toBe(115); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_siblings', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setBorder(Edge.Left, 10); + root_child1.setBorder(Edge.Top, 10); + root_child1.setBorder(Edge.Right, 10); + root_child1.setBorder(Edge.Bottom, 10); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(75); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMaxWidth(50); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMaxWidth(50); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMaxHeight(50); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMaxHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMinWidth(50); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMinWidth(50); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_min_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMinHeight(50); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_min_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMinHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_no_height_no_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_no_height_no_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(18); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_nested', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 15); + root.setPadding(Edge.Top, 15); + root.setPadding(Edge.Right, 15); + root.setPadding(Edge.Bottom, 15); + root.setBorder(Edge.Left, 3); + root.setBorder(Edge.Top, 3); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 3); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0.setBorder(Edge.Top, 2); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 2); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(5); + root_child0_child0.setBoxSizing(BoxSizing.ContentBox); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(136); + expect(root.getComputedHeight()).toBe(136); + + expect(root_child0.getComputedLeft()).toBe(18); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(38); + expect(root_child0.getComputedHeight()).toBe(38); + + expect(root_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(16); + expect(root_child0_child0.getComputedHeight()).toBe(11); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(136); + expect(root.getComputedHeight()).toBe(136); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(38); + expect(root_child0.getComputedHeight()).toBe(38); + + expect(root_child0_child0.getComputedLeft()).toBe(13); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(16); + expect(root_child0_child0.getComputedHeight()).toBe(11); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_nested', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 15); + root.setPadding(Edge.Top, 15); + root.setPadding(Edge.Right, 15); + root.setPadding(Edge.Bottom, 15); + root.setBorder(Edge.Left, 3); + root.setBorder(Edge.Top, 3); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 3); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0.setBorder(Edge.Top, 2); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 2); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(5); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(18); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(6); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(6); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_nested_alternating', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 3); + root.setPadding(Edge.Top, 3); + root.setPadding(Edge.Right, 3); + root.setPadding(Edge.Bottom, 3); + root.setBorder(Edge.Left, 2); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 2); + root.setBorder(Edge.Bottom, 2); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 8); + root_child0.setPadding(Edge.Bottom, 8); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 2); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 2); + root_child0.setWidth(40); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 3); + root_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0.setPadding(Edge.Right, 3); + root_child0_child0.setPadding(Edge.Bottom, 3); + root_child0_child0.setBorder(Edge.Left, 6); + root_child0_child0.setBorder(Edge.Top, 6); + root_child0_child0.setBorder(Edge.Right, 6); + root_child0_child0.setBorder(Edge.Bottom, 6); + root_child0_child0.setWidth(20); + root_child0_child0.setHeight(25); + root_child0_child0.setBoxSizing(BoxSizing.ContentBox); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0_child0.setBorder(Edge.Left, 1); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 1); + root_child0_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0_child0.setWidth(10); + root_child0_child0_child0.setHeight(5); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(38); + expect(root_child0_child0.getComputedHeight()).toBe(43); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0_child0.getComputedHeight()).toBe(5); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(65); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(-8); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(38); + expect(root_child0_child0.getComputedHeight()).toBe(43); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(19); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0_child0.getComputedHeight()).toBe(5); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_border_box_nested_alternating', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 3); + root.setPadding(Edge.Top, 3); + root.setPadding(Edge.Right, 3); + root.setPadding(Edge.Bottom, 3); + root.setBorder(Edge.Left, 2); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 2); + root.setBorder(Edge.Bottom, 2); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 8); + root_child0.setPadding(Edge.Bottom, 8); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 2); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 2); + root_child0.setWidth(40); + root_child0.setHeight(40); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 3); + root_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0.setPadding(Edge.Right, 3); + root_child0_child0.setPadding(Edge.Bottom, 3); + root_child0_child0.setBorder(Edge.Left, 6); + root_child0_child0.setBorder(Edge.Top, 6); + root_child0_child0.setBorder(Edge.Right, 6); + root_child0_child0.setBorder(Edge.Bottom, 6); + root_child0_child0.setWidth(20); + root_child0_child0.setHeight(25); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0_child0.setBorder(Edge.Left, 1); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 1); + root_child0_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0_child0.setWidth(10); + root_child0_child0_child0.setHeight(5); + root_child0_child0_child0.setBoxSizing(BoxSizing.ContentBox); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(14); + expect(root_child0_child0_child0.getComputedHeight()).toBe(9); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(35); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(30); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-3); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(14); + expect(root_child0_child0_child0.getComputedHeight()).toBe(9); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/generated/YGBoxSizingTest.cpp b/tests/generated/YGBoxSizingTest.cpp index 70206f6772..1728a7a7a1 100644 --- a/tests/generated/YGBoxSizingTest.cpp +++ b/tests/generated/YGBoxSizingTest.cpp @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * clang-format off - * @generated SignedSource<<6a7f059e2eb63c8cd443dcddf18e4ed6>> + * @generated SignedSource<<38c0ba6ef126d3453c7e0b56da131566>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html */ @@ -49,3 +49,1600 @@ TEST(YogaTest, box_sizing_content_box) { YGConfigFree(config); } + +TEST(YogaTest, box_sizing_border_box) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root, YGEdgeTop, 5); + YGNodeStyleSetPadding(root, YGEdgeRight, 5); + YGNodeStyleSetPadding(root, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_padding_only) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root, YGEdgeTop, 5); + YGNodeStyleSetPadding(root, YGEdgeRight, 5); + YGNodeStyleSetPadding(root, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_padding_only) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root, YGEdgeTop, 5); + YGNodeStyleSetPadding(root, YGEdgeRight, 5); + YGNodeStyleSetPadding(root, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_border_only) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_border_only) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_no_padding_no_border) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_no_padding_no_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_children) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root, YGEdgeTop, 5); + YGNodeStyleSetPadding(root, YGEdgeRight, 5); + YGNodeStyleSetPadding(root, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 25); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 25); + YGNodeStyleSetHeight(root_child2, 25); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 25); + YGNodeStyleSetHeight(root_child3, 25); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_children) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root, YGEdgeTop, 5); + YGNodeStyleSetPadding(root, YGEdgeRight, 5); + YGNodeStyleSetPadding(root, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 25); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 25); + YGNodeStyleSetHeight(root_child2, 25); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 25); + YGNodeStyleSetHeight(root_child3, 25); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_siblings) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 25); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root_child1, YGEdgeTop, 10); + YGNodeStyleSetPadding(root_child1, YGEdgeRight, 10); + YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeTop, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeRight, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeStyleSetBoxSizing(root_child1, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 25); + YGNodeStyleSetHeight(root_child2, 25); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 25); + YGNodeStyleSetHeight(root_child3, 25); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(115, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(115, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_siblings) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 25); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root_child1, YGEdgeTop, 10); + YGNodeStyleSetPadding(root_child1, YGEdgeRight, 10); + YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeTop, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeRight, 10); + YGNodeStyleSetBorder(root_child1, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 25); + YGNodeStyleSetHeight(root_child2, 25); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 25); + YGNodeStyleSetHeight(root_child3, 25); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_max_width) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetMaxWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_max_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetMaxWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_max_height) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetMaxHeight(root_child0, 50); + YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_max_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetMaxHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_min_width) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetMinWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_min_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetMinWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 25); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_min_height) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetMinHeight(root_child0, 50); + YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_min_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetMinHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 25); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_no_height_no_width) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7); + YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_no_height_no_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_nested) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 15); + YGNodeStyleSetPadding(root, YGEdgeTop, 15); + YGNodeStyleSetPadding(root, YGEdgeRight, 15); + YGNodeStyleSetPadding(root, YGEdgeBottom, 15); + YGNodeStyleSetBorder(root, YGEdgeLeft, 3); + YGNodeStyleSetBorder(root, YGEdgeTop, 3); + YGNodeStyleSetBorder(root, YGEdgeRight, 3); + YGNodeStyleSetBorder(root, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 1); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 1); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 1); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 1); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 2); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 2); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 2); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 2); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 5); + YGNodeStyleSetBoxSizing(root_child0_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(16, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(16, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_nested) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 15); + YGNodeStyleSetPadding(root, YGEdgeTop, 15); + YGNodeStyleSetPadding(root, YGEdgeRight, 15); + YGNodeStyleSetPadding(root, YGEdgeBottom, 15); + YGNodeStyleSetBorder(root, YGEdgeLeft, 3); + YGNodeStyleSetBorder(root, YGEdgeTop, 3); + YGNodeStyleSetBorder(root, YGEdgeRight, 3); + YGNodeStyleSetBorder(root, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 7); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 1); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 1); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 1); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 1); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 2); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 2); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 2); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 2); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 5); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(62, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_content_box_nested_alternating) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root, YGEdgeTop, 3); + YGNodeStyleSetPadding(root, YGEdgeRight, 3); + YGNodeStyleSetPadding(root, YGEdgeBottom, 3); + YGNodeStyleSetBorder(root, YGEdgeLeft, 2); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 2); + YGNodeStyleSetBorder(root, YGEdgeBottom, 2); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 8); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 2); + YGNodeStyleSetWidth(root_child0, 40); + YGNodeStyleSetHeight(root_child0, 40); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 6); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 6); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 6); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root_child0_child0, 20); + YGNodeStyleSetHeight(root_child0_child0, 25); + YGNodeStyleSetBoxSizing(root_child0_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 1); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 1); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 1); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeLeft, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeTop, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeRight, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeBottom, 1); + YGNodeStyleSetWidth(root_child0_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0_child0, 5); + YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(65, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-8, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(19, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, box_sizing_border_box_nested_alternating) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root, YGEdgeTop, 3); + YGNodeStyleSetPadding(root, YGEdgeRight, 3); + YGNodeStyleSetPadding(root, YGEdgeBottom, 3); + YGNodeStyleSetBorder(root, YGEdgeLeft, 2); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 2); + YGNodeStyleSetBorder(root, YGEdgeBottom, 2); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 8); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 2); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 2); + YGNodeStyleSetWidth(root_child0, 40); + YGNodeStyleSetHeight(root_child0, 40); + YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 6); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 6); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 6); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root_child0_child0, 20); + YGNodeStyleSetHeight(root_child0_child0, 25); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 1); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 1); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 1); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeLeft, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeTop, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeRight, 1); + YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeBottom, 1); + YGNodeStyleSetWidth(root_child0_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0_child0, 5); + YGNodeStyleSetBoxSizing(root_child0_child0_child0, YGBoxSizingContentBox); + YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(-3, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +}