2017-02-03 05:37:45 -08:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-02-03 05:37:45 -08:00
|
|
|
*
|
2019-03-25 05:37:36 -07:00
|
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
|
|
* file in the root directory of this source tree.
|
2017-02-03 05:37:45 -08:00
|
|
|
*/
|
|
|
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html
|
|
|
|
|
|
|
|
package com.facebook.yoga;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.junit.runners.Parameterized;
|
|
|
|
|
|
|
|
@RunWith(Parameterized.class)
|
2017-02-03 05:37:45 -08:00
|
|
|
public class YGDimensionTest {
|
2018-07-30 09:30:51 -07:00
|
|
|
@Parameterized.Parameters(name = "{0}")
|
|
|
|
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
|
|
|
|
return TestParametrization.nodeFactories();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
|
|
|
|
|
2017-02-03 05:37:45 -08:00
|
|
|
@Test
|
|
|
|
public void test_wrap_child() {
|
2019-09-17 06:52:49 -07:00
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2017-02-03 05:37:45 -08:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-02-03 05:37:45 -08:00
|
|
|
root_child0.setWidth(100f);
|
|
|
|
root_child0.setHeight(100f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2017-02-03 05:37:45 -08:00
|
|
|
|
|
|
|
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(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2017-02-03 05:37:45 -08:00
|
|
|
|
|
|
|
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(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_wrap_grandchild() {
|
2019-09-17 06:52:49 -07:00
|
|
|
YogaConfig config = YogaConfigFactory.create();
|
2017-03-01 09:19:55 -08:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-02-03 05:37:45 -08:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-02-03 05:37:45 -08:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0_child0 = createNode(config);
|
2017-02-03 05:37:45 -08:00
|
|
|
root_child0_child0.setWidth(100f);
|
|
|
|
root_child0_child0.setHeight(100f);
|
|
|
|
root_child0.addChildAt(root_child0_child0, 0);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2017-02-03 05:37:45 -08:00
|
|
|
|
|
|
|
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(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2017-02-03 05:37:45 -08:00
|
|
|
|
|
|
|
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(100f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
private YogaNode createNode(YogaConfig config) {
|
|
|
|
return mNodeFactory.create(config);
|
|
|
|
}
|
2017-02-03 05:37:45 -08:00
|
|
|
}
|