Fix row-reverse flex direction fixtures

Summary:
These tests were a bit weird for testing something with position. The gentest setup makes it so that the fixtures are wrapped in a absolutely positioned container with height and width bot 0. However, the generated yoga tests do NOT do this and instead have the root node as the fixture itself with no wrapping container.

This causes a problem when testing left/right/top/bottom position insets. Because left/right/top/bottom will position the element relative to its containing block when position is absolute, we will get different values on yoga and chrome even if the implementation is correct: https://developer.mozilla.org/en-US/docs/Web/CSS/right#description

To fix this, we just wrap the fixture in a set size div that is also absolutely positioned.

The file was also formatted.

Reviewed By: NickGerleman

Differential Revision: D50389229

fbshipit-source-id: ecd23939b973225cfb0611dc87f30c262952c5fc
This commit is contained in:
Joe Vilches
2023-10-18 17:30:18 -07:00
committed by Facebook GitHub Bot
parent f1f869b955
commit 2668e8e70c
4 changed files with 914 additions and 620 deletions

View File

@@ -1678,137 +1678,166 @@ public class YGFlexDirectionTest {
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setPosition(YogaEdge.LEFT, 100f);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(10f);
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root_child0.setPosition(YogaEdge.LEFT, 100f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidth(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidth(10f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidth(10f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(100f, root.getLayoutX(), 0.0f);
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(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(100f, root.getLayoutX(), 0.0f);
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(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
@Ignore
public void test_flex_direction_row_reverse_pos_start() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setPosition(YogaEdge.START, 100f);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(10f);
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root_child0.setPosition(YogaEdge.START, 100f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidth(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidth(10f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidth(10f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(100f, root.getLayoutX(), 0.0f);
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(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(-200f, root.getLayoutX(), 0.0f);
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(-100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
@@ -1818,137 +1847,166 @@ public class YGFlexDirectionTest {
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setPosition(YogaEdge.RIGHT, 100f);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(10f);
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root_child0.setPosition(YogaEdge.RIGHT, 100f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidth(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidth(10f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidth(10f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(-200f, root.getLayoutX(), 0.0f);
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(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(-100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(-200f, root.getLayoutX(), 0.0f);
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(-100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
@Ignore
public void test_flex_direction_row_reverse_pos_end() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setPosition(YogaEdge.END, 100f);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(10f);
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root_child0.setPosition(YogaEdge.END, 100f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidth(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidth(10f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidth(10f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(-200f, root.getLayoutX(), 0.0f);
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(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(-100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(100f, root.getLayoutX(), 0.0f);
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(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
@@ -1958,67 +2016,82 @@ public class YGFlexDirectionTest {
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
root.setPosition(YogaEdge.TOP, 100f);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(10f);
root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
root_child0.setPosition(YogaEdge.TOP, 100f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidth(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidth(10f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidth(10f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(100f, root.getLayoutY(), 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(100f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(100f, root.getLayoutY(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
@@ -2028,67 +2101,82 @@ public class YGFlexDirectionTest {
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
root.setPosition(YogaEdge.BOTTOM, 100f);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(10f);
root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
root_child0.setPosition(YogaEdge.BOTTOM, 100f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidth(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidth(10f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidth(10f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(-200f, root.getLayoutY(), 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(100f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(-100f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(-200f, root.getLayoutY(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(-100f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {