Add some tests for justification under row-reverse (#1560)

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

I added these when I was trying to debug the Facepile break removing the row-reverse errata caused. Yoga is doing the right thing, and the tests pass. We didn't have this specific coverage before, so add it.

Reviewed By: joevilches

Differential Revision: D52909633

fbshipit-source-id: d1e8f55bb534d76bd7dfdc46a1e1cc6f0a3ca211
This commit is contained in:
Nick Gerleman
2024-01-19 16:21:59 -08:00
committed by Facebook GitHub Bot
parent 8744792f41
commit 395c596695
4 changed files with 435 additions and 3 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<<f1f4fb9b85e0a3a11d9fd07de9412a24>>
* @generated SignedSource<<88d2dd510790179efc539f8d3cba00bb>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html
*/
@@ -1239,6 +1239,142 @@ public class YGJustifyContentTest {
assertEquals(50f, root_child0_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_flex_start_row_reverse() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, 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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_flex_end_row_reverse() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, 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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}