|
| 1 | +/* |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @generated SignedSource<<be0d102e74e15f15050520f21afcaee1>> |
| 8 | + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayContentsTest.html |
| 9 | + */ |
| 10 | + |
| 11 | +package com.facebook.yoga; |
| 12 | + |
| 13 | +import static org.junit.Assert.assertEquals; |
| 14 | + |
| 15 | +import org.junit.Ignore; |
| 16 | +import org.junit.Test; |
| 17 | +import org.junit.runner.RunWith; |
| 18 | +import org.junit.runners.Parameterized; |
| 19 | +import com.facebook.yoga.utils.TestUtils; |
| 20 | + |
| 21 | +@RunWith(Parameterized.class) |
| 22 | +public class YGDisplayContentsTest { |
| 23 | + @Parameterized.Parameters(name = "{0}") |
| 24 | + public static Iterable<TestParametrization.NodeFactory> nodeFactories() { |
| 25 | + return TestParametrization.nodeFactories(); |
| 26 | + } |
| 27 | + |
| 28 | + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; |
| 29 | + |
| 30 | + @Test |
| 31 | + public void test_test1() { |
| 32 | + YogaConfig config = YogaConfigFactory.create(); |
| 33 | + |
| 34 | + final YogaNode root = createNode(config); |
| 35 | + root.setFlexDirection(YogaFlexDirection.ROW); |
| 36 | + root.setPositionType(YogaPositionType.ABSOLUTE); |
| 37 | + root.setWidth(100f); |
| 38 | + root.setHeight(100f); |
| 39 | + |
| 40 | + final YogaNode root_child0 = createNode(config); |
| 41 | + root_child0.setDisplay(YogaDisplay.CONTENTS); |
| 42 | + root.addChildAt(root_child0, 0); |
| 43 | + |
| 44 | + final YogaNode root_child0_child0 = createNode(config); |
| 45 | + root_child0_child0.setFlexGrow(1f); |
| 46 | + root_child0_child0.setFlexShrink(1f); |
| 47 | + root_child0_child0.setFlexBasisPercent(0f); |
| 48 | + root_child0_child0.setHeight(10f); |
| 49 | + root_child0.addChildAt(root_child0_child0, 0); |
| 50 | + |
| 51 | + final YogaNode root_child0_child1 = createNode(config); |
| 52 | + root_child0_child1.setFlexGrow(1f); |
| 53 | + root_child0_child1.setFlexShrink(1f); |
| 54 | + root_child0_child1.setFlexBasisPercent(0f); |
| 55 | + root_child0_child1.setHeight(20f); |
| 56 | + root_child0.addChildAt(root_child0_child1, 1); |
| 57 | + root.setDirection(YogaDirection.LTR); |
| 58 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 59 | + |
| 60 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 61 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 62 | + assertEquals(100f, root.getLayoutWidth(), 0.0f); |
| 63 | + assertEquals(100f, root.getLayoutHeight(), 0.0f); |
| 64 | + |
| 65 | + assertEquals(0f, root_child0.getLayoutX(), 0.0f); |
| 66 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 67 | + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); |
| 68 | + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); |
| 69 | + |
| 70 | + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); |
| 71 | + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); |
| 72 | + assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f); |
| 73 | + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); |
| 74 | + |
| 75 | + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); |
| 76 | + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); |
| 77 | + assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f); |
| 78 | + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); |
| 79 | + |
| 80 | + root.setDirection(YogaDirection.RTL); |
| 81 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 82 | + |
| 83 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 84 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 85 | + assertEquals(100f, root.getLayoutWidth(), 0.0f); |
| 86 | + assertEquals(100f, root.getLayoutHeight(), 0.0f); |
| 87 | + |
| 88 | + assertEquals(0f, root_child0.getLayoutX(), 0.0f); |
| 89 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 90 | + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); |
| 91 | + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); |
| 92 | + |
| 93 | + assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f); |
| 94 | + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); |
| 95 | + assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f); |
| 96 | + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); |
| 97 | + |
| 98 | + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); |
| 99 | + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); |
| 100 | + assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f); |
| 101 | + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); |
| 102 | + } |
| 103 | + |
| 104 | + private YogaNode createNode(YogaConfig config) { |
| 105 | + return mNodeFactory.create(config); |
| 106 | + } |
| 107 | +} |
0 commit comments