diff --git a/gentest/fixtures/YGPercentageTest.html b/gentest/fixtures/YGPercentageTest.html
index 7749e5ff08..2753f8932f 100644
--- a/gentest/fixtures/YGPercentageTest.html
+++ b/gentest/fixtures/YGPercentageTest.html
@@ -109,3 +109,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/tests/com/facebook/yoga/YGPercentageTest.java b/java/tests/com/facebook/yoga/YGPercentageTest.java
index 60ea40510b..d566436f42 100644
--- a/java/tests/com/facebook/yoga/YGPercentageTest.java
+++ b/java/tests/com/facebook/yoga/YGPercentageTest.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<>
+ * @generated SignedSource<<5732db99011860ede54f3fd33ba863c9>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html
*/
@@ -1230,6 +1230,421 @@ public void test_percent_absolute_position() {
assertEquals(50f, root_child0_child1.getLayoutHeight(), 0.0f);
}
+ @Test
+ public void test_percent_of_minmax_main() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMinWidth(60f);
+ root.setMaxWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_percent_of_min_main() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMinWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_percent_of_min_main_multiple() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMinWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidthPercent(50f);
+ root_child1.setHeight(20f);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = createNode(config);
+ root_child2.setWidthPercent(50f);
+ root_child2.setHeight(20f);
+ root.addChildAt(root_child2, 2);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child2.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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(-30f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_percent_of_max_main() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMaxWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(0f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(0f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_percent_of_minmax_cross_stretched() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMinWidth(60f);
+ root.setMaxWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_percent_absolute_of_minmax_cross_stretched() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMinWidth(60f);
+ root.setMaxWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_percent_of_minmax_cross_unstretched() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setAlignItems(YogaAlign.FLEX_START);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMinWidth(60f);
+ root.setMaxWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ @Ignore
+ public void test_percent_of_min_cross_unstretched() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setAlignItems(YogaAlign.FLEX_START);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMinWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_percent_of_max_cross_unstretched() {
+ YogaConfig config = YogaConfigFactory.create();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
+
+ final YogaNode root = createNode(config);
+ root.setAlignItems(YogaAlign.FLEX_START);
+ root.setPositionType(YogaPositionType.ABSOLUTE);
+ root.setMaxWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidthPercent(50f);
+ root_child0.setHeight(20f);
+ 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(0f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, 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(0f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
+ }
+
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
diff --git a/javascript/tests/generated/YGPercentageTest.test.ts b/javascript/tests/generated/YGPercentageTest.test.ts
index 184d65a932..fd38d949ec 100644
--- a/javascript/tests/generated/YGPercentageTest.test.ts
+++ b/javascript/tests/generated/YGPercentageTest.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<<31e52c7900fc207dcb99becfaa715781>>
+ * @generated SignedSource<<3ec0d105e6fe56cb6eb30f8f9217cacd>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html
*/
@@ -1349,3 +1349,468 @@ test('percent_absolute_position', () => {
config.free();
}
});
+test('percent_of_minmax_main', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setFlexDirection(FlexDirection.Row);
+ root.setPositionType(PositionType.Absolute);
+ root.setMinWidth(60);
+ root.setMaxWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(30);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('percent_of_min_main', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setFlexDirection(FlexDirection.Row);
+ root.setPositionType(PositionType.Absolute);
+ root.setMinWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(30);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('percent_of_min_main_multiple', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setFlexDirection(FlexDirection.Row);
+ root.setPositionType(PositionType.Absolute);
+ root.setMinWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ root.insertChild(root_child0, 0);
+
+ const root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth("50%");
+ root_child1.setHeight(20);
+ root.insertChild(root_child1, 1);
+
+ const root_child2 = Yoga.Node.create(config);
+ root_child2.setWidth("50%");
+ root_child2.setHeight(20);
+ root.insertChild(root_child2, 2);
+ root.calculateLayout(undefined, undefined, Direction.LTR);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ expect(root_child1.getComputedLeft()).toBe(30);
+ expect(root_child1.getComputedTop()).toBe(0);
+ expect(root_child1.getComputedWidth()).toBe(30);
+ expect(root_child1.getComputedHeight()).toBe(20);
+
+ expect(root_child2.getComputedLeft()).toBe(60);
+ expect(root_child2.getComputedTop()).toBe(0);
+ expect(root_child2.getComputedWidth()).toBe(30);
+ expect(root_child2.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(30);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ expect(root_child1.getComputedLeft()).toBe(0);
+ expect(root_child1.getComputedTop()).toBe(0);
+ expect(root_child1.getComputedWidth()).toBe(30);
+ expect(root_child1.getComputedHeight()).toBe(20);
+
+ expect(root_child2.getComputedLeft()).toBe(-30);
+ expect(root_child2.getComputedTop()).toBe(0);
+ expect(root_child2.getComputedWidth()).toBe(30);
+ expect(root_child2.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('percent_of_max_main', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setFlexDirection(FlexDirection.Row);
+ root.setPositionType(PositionType.Absolute);
+ root.setMaxWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(0);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(0);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(0);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(0);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('percent_of_minmax_cross_stretched', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setMinWidth(60);
+ root.setMaxWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(30);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('percent_absolute_of_minmax_cross_stretched', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setPositionType(PositionType.Absolute);
+ root.setMinWidth(60);
+ root.setMaxWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setPositionType(PositionType.Absolute);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(30);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('percent_of_minmax_cross_unstretched', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setAlignItems(Align.FlexStart);
+ root.setPositionType(PositionType.Absolute);
+ root.setMinWidth(60);
+ root.setMaxWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(30);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test.skip('percent_of_min_cross_unstretched', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setAlignItems(Align.FlexStart);
+ root.setPositionType(PositionType.Absolute);
+ root.setMinWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(60);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(30);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(30);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+test('percent_of_max_cross_unstretched', () => {
+ const config = Yoga.Config.create();
+ let root;
+
+ config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
+
+ try {
+ root = Yoga.Node.create(config);
+ root.setAlignItems(Align.FlexStart);
+ root.setPositionType(PositionType.Absolute);
+ root.setMaxWidth(60);
+ root.setHeight(50);
+
+ const root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth("50%");
+ root_child0.setHeight(20);
+ 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(0);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(0);
+ expect(root_child0.getComputedHeight()).toBe(20);
+
+ root.calculateLayout(undefined, undefined, Direction.RTL);
+
+ expect(root.getComputedLeft()).toBe(0);
+ expect(root.getComputedTop()).toBe(0);
+ expect(root.getComputedWidth()).toBe(0);
+ expect(root.getComputedHeight()).toBe(50);
+
+ expect(root_child0.getComputedLeft()).toBe(0);
+ expect(root_child0.getComputedTop()).toBe(0);
+ expect(root_child0.getComputedWidth()).toBe(0);
+ expect(root_child0.getComputedHeight()).toBe(20);
+ } finally {
+ if (typeof root !== 'undefined') {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
diff --git a/tests/generated/YGPercentageTest.cpp b/tests/generated/YGPercentageTest.cpp
index 1e3e0a6fa4..72115f1cf0 100644
--- a/tests/generated/YGPercentageTest.cpp
+++ b/tests/generated/YGPercentageTest.cpp
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* clang-format off
- * @generated SignedSource<>
+ * @generated SignedSource<<4a44e1ad05f18f3473a74f06cd835e4e>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html
*/
@@ -1236,3 +1236,431 @@ TEST(YogaTest, percent_absolute_position) {
YGConfigFree(config);
}
+
+TEST(YogaTest, percent_of_minmax_main) {
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMinWidth(root, 60);
+ YGNodeStyleSetMaxWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_of_min_main) {
+ GTEST_SKIP();
+
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMinWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_of_min_main_multiple) {
+ GTEST_SKIP();
+
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMinWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child1, 50);
+ YGNodeStyleSetHeight(root_child1, 20);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child2, 50);
+ YGNodeStyleSetHeight(root_child2, 20);
+ YGNodeInsertChild(root, root_child2, 2);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(-30, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_of_max_main) {
+ GTEST_SKIP();
+
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMaxWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(0, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_of_minmax_cross_stretched) {
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMinWidth(root, 60);
+ YGNodeStyleSetMaxWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_absolute_of_minmax_cross_stretched) {
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMinWidth(root, 60);
+ YGNodeStyleSetMaxWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_of_minmax_cross_unstretched) {
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMinWidth(root, 60);
+ YGNodeStyleSetMaxWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_of_min_cross_unstretched) {
+ GTEST_SKIP();
+
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMinWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, percent_of_max_cross_unstretched) {
+ const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
+ YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
+ YGNodeStyleSetMaxWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0, 50);
+ YGNodeStyleSetHeight(root_child0, 20);
+ 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(0, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}