2022-10-13 08:18:49 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
2022-11-15 19:51:48 -08:00
|
|
|
// @generated by gentest/gentest.rb from gentest/fixtures/YGGapTest.html
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
package com.facebook.yoga;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
import org.junit.Ignore;
|
2022-10-13 08:18:49 -07:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.junit.runners.Parameterized;
|
|
|
|
|
|
|
|
@RunWith(Parameterized.class)
|
|
|
|
public class YGGapTest {
|
|
|
|
@Parameterized.Parameters(name = "{0}")
|
|
|
|
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
|
|
|
|
return TestParametrization.nodeFactories();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
|
|
|
|
|
|
|
|
@Test
|
2022-11-16 14:02:31 -08:00
|
|
|
public void test_column_gap_flexible() {
|
2022-10-13 08:18:49 -07:00
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWidth(80f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setFlexGrow(1f);
|
|
|
|
root_child0.setFlexShrink(1f);
|
|
|
|
root_child0.setFlexBasisPercent(0f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setFlexGrow(1f);
|
|
|
|
root_child1.setFlexShrink(1f);
|
|
|
|
root_child1.setFlexBasisPercent(0f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setFlexGrow(1f);
|
|
|
|
root_child2.setFlexShrink(1f);
|
|
|
|
root_child2.setFlexBasisPercent(0f);
|
|
|
|
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(80f, 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(30f, 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(60f, 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(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, 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(30f, 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(0f, 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
|
2022-11-16 14:02:31 -08:00
|
|
|
public void test_column_gap_inflexible() {
|
2022-10-13 08:18:49 -07:00
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWidth(80f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
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(80f, 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(30f, 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(60f, 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(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, 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(30f, 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(0f, 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
|
2022-11-16 14:02:31 -08:00
|
|
|
public void test_column_gap_mixed_flexible() {
|
2022-10-13 08:18:49 -07:00
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWidth(80f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setFlexGrow(1f);
|
|
|
|
root_child1.setFlexShrink(1f);
|
|
|
|
root_child1.setFlexBasisPercent(0f);
|
|
|
|
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(80f, 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(30f, 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(60f, 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(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, 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(30f, 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(0f, 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);
|
|
|
|
}
|
|
|
|
|
2022-11-16 14:02:31 -08:00
|
|
|
@Test
|
|
|
|
public void test_column_gap_child_margins() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-11-16 14:02:31 -08:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWidth(80f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setFlexGrow(1f);
|
|
|
|
root_child0.setFlexShrink(1f);
|
|
|
|
root_child0.setFlexBasisPercent(0f);
|
|
|
|
root_child0.setMargin(YogaEdge.LEFT, 2f);
|
|
|
|
root_child0.setMargin(YogaEdge.RIGHT, 2f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setFlexGrow(1f);
|
|
|
|
root_child1.setFlexShrink(1f);
|
|
|
|
root_child1.setFlexBasisPercent(0f);
|
|
|
|
root_child1.setMargin(YogaEdge.LEFT, 10f);
|
|
|
|
root_child1.setMargin(YogaEdge.RIGHT, 10f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setFlexGrow(1f);
|
|
|
|
root_child2.setFlexShrink(1f);
|
|
|
|
root_child2.setFlexBasisPercent(0f);
|
|
|
|
root_child2.setMargin(YogaEdge.LEFT, 15f);
|
|
|
|
root_child2.setMargin(YogaEdge.RIGHT, 15f);
|
|
|
|
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(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(2f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(2f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(26f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(2f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(63f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(2f, 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(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(76f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(2f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(52f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(2f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(15f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(2f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:18:49 -07:00
|
|
|
@Test
|
|
|
|
public void test_column_row_gap_wrapping() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(80f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setWidth(20f);
|
|
|
|
root_child1.setHeight(20f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setWidth(20f);
|
|
|
|
root_child2.setHeight(20f);
|
|
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root_child3.setHeight(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root_child4.setHeight(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root_child5.setHeight(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
|
|
|
|
final YogaNode root_child6 = createNode(config);
|
|
|
|
root_child6.setWidth(20f);
|
|
|
|
root_child6.setHeight(20f);
|
|
|
|
root.addChildAt(root_child6, 6);
|
|
|
|
|
|
|
|
final YogaNode root_child7 = createNode(config);
|
|
|
|
root_child7.setWidth(20f);
|
|
|
|
root_child7.setHeight(20f);
|
|
|
|
root.addChildAt(root_child7, 7);
|
|
|
|
|
|
|
|
final YogaNode root_child8 = createNode(config);
|
|
|
|
root_child8.setWidth(20f);
|
|
|
|
root_child8.setHeight(20f);
|
|
|
|
root.addChildAt(root_child8, 8);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(80f, 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(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child6.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child6.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child6.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child6.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child7.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child7.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child7.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child7.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child8.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child8.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child8.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child8.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(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child6.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child6.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child6.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child6.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child7.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child7.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child7.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child7.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child8.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child8.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child8.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child8.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_column_gap_justify_flex_start() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
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(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(30f, 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(60f, 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(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(50f, 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(20f, 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_column_gap_justify_center() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.CENTER);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
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(10f, 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(40f, 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(70f, 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(70f, 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(40f, 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(10f, 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_column_gap_justify_flex_end() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.FLEX_END);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
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(20f, 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(50f, 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(80f, 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(60f, 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(30f, 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(0f, 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_column_gap_justify_space_between() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.SPACE_BETWEEN);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
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(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(40f, 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(80f, 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(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(40f, 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(0f, 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_column_gap_justify_space_around() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.SPACE_AROUND);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
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(3f, 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(40f, 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(77f, 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(77f, 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(40f, 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(3f, 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_column_gap_justify_space_evenly() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.SPACE_EVENLY);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
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(5f, 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(40f, 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(75f, 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(75f, 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(40f, 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(5f, 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_column_gap_wrap_align_flex_start() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setWidth(20f);
|
|
|
|
root_child1.setHeight(20f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setWidth(20f);
|
|
|
|
root_child2.setHeight(20f);
|
|
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root_child3.setHeight(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root_child4.setHeight(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root_child5.setHeight(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
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(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.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(80f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_column_gap_wrap_align_center() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setAlignContent(YogaAlign.CENTER);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setWidth(20f);
|
|
|
|
root_child1.setHeight(20f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setWidth(20f);
|
|
|
|
root_child2.setHeight(20f);
|
|
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root_child3.setHeight(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root_child4.setHeight(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root_child5.setHeight(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
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(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(60f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(60f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(60f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.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(80f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(60f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(60f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(60f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_column_gap_wrap_align_flex_end() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setAlignContent(YogaAlign.FLEX_END);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setWidth(20f);
|
|
|
|
root_child1.setHeight(20f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setWidth(20f);
|
|
|
|
root_child2.setHeight(20f);
|
|
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root_child3.setHeight(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root_child4.setHeight(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root_child5.setHeight(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
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(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.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(80f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(40f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_column_gap_wrap_align_space_between() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setAlignContent(YogaAlign.SPACE_BETWEEN);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setWidth(20f);
|
|
|
|
root_child1.setHeight(20f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setWidth(20f);
|
|
|
|
root_child2.setHeight(20f);
|
|
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root_child3.setHeight(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root_child4.setHeight(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root_child5.setHeight(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
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(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.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(80f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_column_gap_wrap_align_space_around() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setAlignContent(YogaAlign.SPACE_AROUND);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setWidth(20f);
|
|
|
|
root_child1.setHeight(20f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setWidth(20f);
|
|
|
|
root_child2.setHeight(20f);
|
|
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root_child3.setHeight(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root_child4.setHeight(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root_child5.setHeight(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
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(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(70f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(70f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(70f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.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(80f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(70f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(70f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(70f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
Incorporate gap space into main axis overflow flag (#1173)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1173
In https://github.com/facebook/react-native/issues/35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap.
In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization?
If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead.
`flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`.
We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap.
Changelog:
[General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched
Reviewed By: yungsters
Differential Revision: D41311424
fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
2022-11-15 19:51:48 -08:00
|
|
|
@Test
|
|
|
|
public void test_column_gap_wrap_align_stretch() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
Incorporate gap space into main axis overflow flag (#1173)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1173
In https://github.com/facebook/react-native/issues/35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap.
In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization?
If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead.
`flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`.
We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap.
Changelog:
[General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched
Reviewed By: yungsters
Differential Revision: D41311424
fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
2022-11-15 19:51:48 -08:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setAlignContent(YogaAlign.STRETCH);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(300f);
|
|
|
|
root.setHeight(300f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 5f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setFlexGrow(1f);
|
|
|
|
root_child0.setMinWidth(60f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setFlexGrow(1f);
|
|
|
|
root_child1.setMinWidth(60f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setFlexGrow(1f);
|
|
|
|
root_child2.setMinWidth(60f);
|
|
|
|
root.addChildAt(root_child2, 2);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setFlexGrow(1f);
|
|
|
|
root_child3.setMinWidth(60f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setFlexGrow(1f);
|
|
|
|
root_child4.setMinWidth(60f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(300f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(300f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(71f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(76f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(72f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(153f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(71f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(229f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(71f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(150f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(300f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child4.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(300f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(300f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(229f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(71f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(153f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(71f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(76f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(72f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(71f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(150f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(300f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(150f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2022-12-15 16:30:37 -08:00
|
|
|
@Test
|
|
|
|
public void test_column_gap_determines_parent_width() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-12-15 16:30:37 -08:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setWidth(10f);
|
|
|
|
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(30f);
|
|
|
|
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(80f, 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(10f, 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(50f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(30f, 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(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(70f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(40f, 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(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:18:49 -07:00
|
|
|
@Test
|
|
|
|
public void test_row_gap_align_items_stretch() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setAlignContent(YogaAlign.STRETCH);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(200f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
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(200f, 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(90f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(110f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(110f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(110f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child5.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(200f, 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(90f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(110f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(110f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(110f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(90f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_row_gap_align_items_end() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-10-13 08:18:49 -07:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setAlignItems(YogaAlign.FLEX_END);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(200f);
|
|
|
|
root.setGap(YogaGutter.COLUMN, 10f);
|
|
|
|
root.setGap(YogaGutter.ROW, 20f);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
final YogaNode root_child3 = createNode(config);
|
|
|
|
root_child3.setWidth(20f);
|
|
|
|
root.addChildAt(root_child3, 3);
|
|
|
|
|
|
|
|
final YogaNode root_child4 = createNode(config);
|
|
|
|
root_child4.setWidth(20f);
|
|
|
|
root.addChildAt(root_child4, 4);
|
|
|
|
|
|
|
|
final YogaNode root_child5 = createNode(config);
|
|
|
|
root_child5.setWidth(20f);
|
|
|
|
root.addChildAt(root_child5, 5);
|
|
|
|
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(200f, 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(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(60f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child5.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(200f, 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(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child3.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child3.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child4.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child5.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child5.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2022-11-16 14:02:31 -08:00
|
|
|
@Test
|
|
|
|
public void test_row_gap_column_child_margins() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-11-16 14:02:31 -08:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(200f);
|
|
|
|
root.setGap(YogaGutter.ROW, 10f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setFlexGrow(1f);
|
|
|
|
root_child0.setFlexShrink(1f);
|
|
|
|
root_child0.setFlexBasisPercent(0f);
|
|
|
|
root_child0.setMargin(YogaEdge.TOP, 2f);
|
|
|
|
root_child0.setMargin(YogaEdge.BOTTOM, 2f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setFlexGrow(1f);
|
|
|
|
root_child1.setFlexShrink(1f);
|
|
|
|
root_child1.setFlexBasisPercent(0f);
|
|
|
|
root_child1.setMargin(YogaEdge.TOP, 10f);
|
|
|
|
root_child1.setMargin(YogaEdge.BOTTOM, 10f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setFlexGrow(1f);
|
|
|
|
root_child2.setFlexShrink(1f);
|
|
|
|
root_child2.setFlexBasisPercent(0f);
|
|
|
|
root_child2.setMargin(YogaEdge.TOP, 15f);
|
|
|
|
root_child2.setMargin(YogaEdge.BOTTOM, 15f);
|
|
|
|
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(200f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(2f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(42f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(66f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(42f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(143f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(42f, 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(200f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(2f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(42f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(66f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(42f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(143f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(42f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_row_gap_row_wrap_child_margins() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-11-16 14:02:31 -08:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setWrap(YogaWrap.WRAP);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setHeight(200f);
|
|
|
|
root.setGap(YogaGutter.ROW, 10f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setMargin(YogaEdge.TOP, 2f);
|
|
|
|
root_child0.setMargin(YogaEdge.BOTTOM, 2f);
|
|
|
|
root_child0.setWidth(60f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setMargin(YogaEdge.TOP, 10f);
|
|
|
|
root_child1.setMargin(YogaEdge.BOTTOM, 10f);
|
|
|
|
root_child1.setWidth(60f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setMargin(YogaEdge.TOP, 15f);
|
|
|
|
root_child2.setMargin(YogaEdge.BOTTOM, 15f);
|
|
|
|
root_child2.setWidth(60f);
|
|
|
|
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(200f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(2f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(24f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(60f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(59f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(60f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, 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(200f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(40f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(2f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(24f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(60f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(40f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(59f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(60f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2022-12-15 16:30:37 -08:00
|
|
|
@Test
|
|
|
|
public void test_row_gap_determines_parent_height() {
|
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2023-01-08 13:41:27 -08:00
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
|
|
|
|
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_ABSOLUTE_TRAILING_COLUMN_MARGIN, true);
|
2022-12-15 16:30:37 -08:00
|
|
|
|
|
|
|
final YogaNode root = createNode(config);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setGap(YogaGutter.ROW, 10f);
|
|
|
|
|
|
|
|
final YogaNode root_child0 = createNode(config);
|
|
|
|
root_child0.setHeight(10f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
|
|
|
final YogaNode root_child1 = createNode(config);
|
|
|
|
root_child1.setHeight(20f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
|
|
|
final YogaNode root_child2 = createNode(config);
|
|
|
|
root_child2.setHeight(30f);
|
|
|
|
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(80f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(50f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(30f, 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(80f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(50f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:18:49 -07:00
|
|
|
private YogaNode createNode(YogaConfig config) {
|
|
|
|
return mNodeFactory.create(config);
|
|
|
|
}
|
|
|
|
}
|