Fix align-content of cross-stretched container (#1524)

Summary:
X-link: https://github.com/facebook/react-native/pull/41964

Pull Request resolved: https://github.com/facebook/yoga/pull/1524

D52087013 (#1513) fixed some issues, including where measuring under max-content or fit-content, align-content stretch would consume the entire available cross-dimensions, instead of only sizing to definite dimension, like the spec dicates.

I missed a case, where flexbox considers a container as having a definite cross-size if it is being stretched, even if it doesn't have a definite length.

https://www.w3.org/TR/css-flexbox-1/#definite-sizes

> 3. Once the cross size of a flex line has been determined, items in auto-sized flex containers are also considered definite for the purpose of layout;

> 1. If a single-line flex container has a definite cross size, the outer cross size of any stretched flex items is the flex container’s inner cross size (clamped to the flex item’s min and max cross size) and is considered definite.

We handle `align-items: stretch` of a flex container after cross-size determination by laying out the child under stretch-fit (previously YGMeasureModeExactly) constraint. This checks that case, and sizing the line container to specified cross-dim if we are told to stretch to it.

We could probably afford to merge this a bit with later with what is currently step 9, where we end up redoing some of this same math.

Reviewed By: yungsters

Differential Revision: D52234980

fbshipit-source-id: 475773a352fd01f63a4b21e93a55519726dc0da7
This commit is contained in:
Nick Gerleman
2023-12-17 01:13:36 -08:00
committed by Facebook GitHub Bot
parent 2a8c7a4223
commit a1751127ef
5 changed files with 1500 additions and 5 deletions

View File

@@ -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<<d7a3a106458c874d95ce8b61bd4f07bf>>
* @generated SignedSource<<75aa9390813e51550d9760c37e59de0c>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html
*/
@@ -4601,6 +4601,485 @@ public class YGAlignContentTest {
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_flex_start_stretch_doesnt_influence_line_box_dim() {
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.setPadding(YogaEdge.LEFT, 20);
root.setPadding(YogaEdge.TOP, 20);
root.setPadding(YogaEdge.RIGHT, 20);
root.setPadding(YogaEdge.BOTTOM, 20);
root.setWidth(400f);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.RIGHT, 20f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexDirection(YogaFlexDirection.ROW);
root_child1.setWrap(YogaWrap.WRAP);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = createNode(config);
root_child1_child0.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child0.setWidth(30f);
root_child1_child0.setHeight(30f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 = createNode(config);
root_child1_child1.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child1.setWidth(30f);
root_child1_child1.setHeight(30f);
root_child1.addChildAt(root_child1_child1, 1);
final YogaNode root_child1_child2 = createNode(config);
root_child1_child2.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child2.setWidth(30f);
root_child1_child2.setHeight(30f);
root_child1.addChildAt(root_child1_child2, 2);
final YogaNode root_child1_child3 = createNode(config);
root_child1_child3.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child3.setWidth(30f);
root_child1_child3.setHeight(30f);
root_child1.addChildAt(root_child1_child3, 3);
final YogaNode root_child1_child4 = createNode(config);
root_child1_child4.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child4.setWidth(30f);
root_child1_child4.setHeight(30f);
root_child1.addChildAt(root_child1_child4, 4);
final YogaNode root_child2 = createNode(config);
root_child2.setMargin(YogaEdge.LEFT, 20f);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
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(400f, root.getLayoutWidth(), 0.0f);
assertEquals(140f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(140f, root_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
assertEquals(170f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child1_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f);
assertEquals(330f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, 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(400f, root.getLayoutWidth(), 0.0f);
assertEquals(140f, root.getLayoutHeight(), 0.0f);
assertEquals(260f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, 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(20f, root_child1.getLayoutY(), 0.0f);
assertEquals(170f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child1_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1_child3.getLayoutX(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1_child4.getLayoutX(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_stretch_does_influence_line_box_dim() {
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.setPadding(YogaEdge.LEFT, 20);
root.setPadding(YogaEdge.TOP, 20);
root.setPadding(YogaEdge.RIGHT, 20);
root.setPadding(YogaEdge.BOTTOM, 20);
root.setWidth(400f);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.RIGHT, 20f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexDirection(YogaFlexDirection.ROW);
root_child1.setAlignContent(YogaAlign.STRETCH);
root_child1.setWrap(YogaWrap.WRAP);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = createNode(config);
root_child1_child0.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child0.setWidth(30f);
root_child1_child0.setHeight(30f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 = createNode(config);
root_child1_child1.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child1.setWidth(30f);
root_child1_child1.setHeight(30f);
root_child1.addChildAt(root_child1_child1, 1);
final YogaNode root_child1_child2 = createNode(config);
root_child1_child2.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child2.setWidth(30f);
root_child1_child2.setHeight(30f);
root_child1.addChildAt(root_child1_child2, 2);
final YogaNode root_child1_child3 = createNode(config);
root_child1_child3.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child3.setWidth(30f);
root_child1_child3.setHeight(30f);
root_child1.addChildAt(root_child1_child3, 3);
final YogaNode root_child1_child4 = createNode(config);
root_child1_child4.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child4.setWidth(30f);
root_child1_child4.setHeight(30f);
root_child1.addChildAt(root_child1_child4, 4);
final YogaNode root_child2 = createNode(config);
root_child2.setMargin(YogaEdge.LEFT, 20f);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
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(400f, root.getLayoutWidth(), 0.0f);
assertEquals(140f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(140f, root_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
assertEquals(170f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child1_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f);
assertEquals(330f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, 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(400f, root.getLayoutWidth(), 0.0f);
assertEquals(140f, root.getLayoutHeight(), 0.0f);
assertEquals(260f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, 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(20f, root_child1.getLayoutY(), 0.0f);
assertEquals(170f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child1_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1_child3.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1_child4.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_space_evenly_stretch_does_influence_line_box_dim() {
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.setPadding(YogaEdge.LEFT, 20);
root.setPadding(YogaEdge.TOP, 20);
root.setPadding(YogaEdge.RIGHT, 20);
root.setPadding(YogaEdge.BOTTOM, 20);
root.setWidth(400f);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.RIGHT, 20f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexDirection(YogaFlexDirection.ROW);
root_child1.setAlignContent(YogaAlign.STRETCH);
root_child1.setWrap(YogaWrap.WRAP);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = createNode(config);
root_child1_child0.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child0.setWidth(30f);
root_child1_child0.setHeight(30f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 = createNode(config);
root_child1_child1.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child1.setWidth(30f);
root_child1_child1.setHeight(30f);
root_child1.addChildAt(root_child1_child1, 1);
final YogaNode root_child1_child2 = createNode(config);
root_child1_child2.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child2.setWidth(30f);
root_child1_child2.setHeight(30f);
root_child1.addChildAt(root_child1_child2, 2);
final YogaNode root_child1_child3 = createNode(config);
root_child1_child3.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child3.setWidth(30f);
root_child1_child3.setHeight(30f);
root_child1.addChildAt(root_child1_child3, 3);
final YogaNode root_child1_child4 = createNode(config);
root_child1_child4.setMargin(YogaEdge.RIGHT, 20f);
root_child1_child4.setWidth(30f);
root_child1_child4.setHeight(30f);
root_child1.addChildAt(root_child1_child4, 4);
final YogaNode root_child2 = createNode(config);
root_child2.setMargin(YogaEdge.LEFT, 20f);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
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(400f, root.getLayoutWidth(), 0.0f);
assertEquals(140f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(140f, root_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
assertEquals(170f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child1_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f);
assertEquals(330f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, 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(400f, root.getLayoutWidth(), 0.0f);
assertEquals(140f, root.getLayoutHeight(), 0.0f);
assertEquals(260f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, 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(20f, root_child1.getLayoutY(), 0.0f);
assertEquals(170f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child1_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1_child3.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1_child4.getLayoutX(), 0.0f);
assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}