|
| 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<<b6fd86b68e2b4b22e8479246a3c5a6ac>> |
| 8 | + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_distribute_space_flex_auto.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 grid_distribute_space_flex_auto { |
| 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_grid_distribute_space_flex_auto() { |
| 32 | + YogaConfig config = YogaConfigFactory.create(); |
| 33 | + |
| 34 | + final YogaNode root = createNode(config); |
| 35 | + root.setPositionType(YogaPositionType.ABSOLUTE); |
| 36 | + root.setWidth(300f); |
| 37 | + root.setDisplay(YogaDisplay.GRID); |
| 38 | + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); |
| 39 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 40 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 41 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 42 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 43 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 44 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 45 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 46 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 47 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 48 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 49 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 50 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 51 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 52 | + root.setGridTemplateColumns(rootGridTemplateColumns); |
| 53 | + |
| 54 | + final YogaNode root_child0 = createNode(config); |
| 55 | + root_child0.setWidth(200f); |
| 56 | + root_child0.setHeight(50f); |
| 57 | + root_child0.setGridColumnStart(1); |
| 58 | + root_child0.setGridColumnEnd(4); |
| 59 | + root.addChildAt(root_child0, 0); |
| 60 | + |
| 61 | + final YogaNode root_child1 = createNode(config); |
| 62 | + root_child1.setWidth(50f); |
| 63 | + root_child1.setHeight(30f); |
| 64 | + root.addChildAt(root_child1, 1); |
| 65 | + |
| 66 | + final YogaNode root_child2 = createNode(config); |
| 67 | + root_child2.setHeight(30f); |
| 68 | + root.addChildAt(root_child2, 2); |
| 69 | + |
| 70 | + final YogaNode root_child3 = createNode(config); |
| 71 | + root_child3.setWidth(50f); |
| 72 | + root_child3.setHeight(30f); |
| 73 | + root.addChildAt(root_child3, 3); |
| 74 | + root.setDirection(YogaDirection.LTR); |
| 75 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 76 | + |
| 77 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 78 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 79 | + assertEquals(300f, root.getLayoutWidth(), 0.0f); |
| 80 | + assertEquals(80f, root.getLayoutHeight(), 0.0f); |
| 81 | + |
| 82 | + assertEquals(0f, root_child0.getLayoutX(), 0.0f); |
| 83 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 84 | + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); |
| 85 | + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); |
| 86 | + |
| 87 | + assertEquals(0f, root_child1.getLayoutX(), 0.0f); |
| 88 | + assertEquals(50f, root_child1.getLayoutY(), 0.0f); |
| 89 | + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); |
| 90 | + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); |
| 91 | + |
| 92 | + assertEquals(50f, root_child2.getLayoutX(), 0.0f); |
| 93 | + assertEquals(50f, root_child2.getLayoutY(), 0.0f); |
| 94 | + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); |
| 95 | + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); |
| 96 | + |
| 97 | + assertEquals(250f, root_child3.getLayoutX(), 0.0f); |
| 98 | + assertEquals(50f, root_child3.getLayoutY(), 0.0f); |
| 99 | + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); |
| 100 | + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); |
| 101 | + |
| 102 | + root.setDirection(YogaDirection.RTL); |
| 103 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 104 | + |
| 105 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 106 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 107 | + assertEquals(300f, root.getLayoutWidth(), 0.0f); |
| 108 | + assertEquals(80f, root.getLayoutHeight(), 0.0f); |
| 109 | + |
| 110 | + assertEquals(100f, root_child0.getLayoutX(), 0.0f); |
| 111 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 112 | + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); |
| 113 | + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); |
| 114 | + |
| 115 | + assertEquals(250f, root_child1.getLayoutX(), 0.0f); |
| 116 | + assertEquals(50f, root_child1.getLayoutY(), 0.0f); |
| 117 | + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); |
| 118 | + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); |
| 119 | + |
| 120 | + assertEquals(50f, root_child2.getLayoutX(), 0.0f); |
| 121 | + assertEquals(50f, root_child2.getLayoutY(), 0.0f); |
| 122 | + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); |
| 123 | + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); |
| 124 | + |
| 125 | + assertEquals(0f, root_child3.getLayoutX(), 0.0f); |
| 126 | + assertEquals(50f, root_child3.getLayoutY(), 0.0f); |
| 127 | + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); |
| 128 | + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); |
| 129 | + } |
| 130 | + |
| 131 | + private YogaNode createNode(YogaConfig config) { |
| 132 | + return mNodeFactory.create(config); |
| 133 | + } |
| 134 | +} |
0 commit comments