2017-02-03 05:37:45 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-16 18:24:55 -08: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() {
|
2017-03-01 09:19:55 -08:00
|
|
|
YogaConfig config = new YogaConfig();
|
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() {
|
2017-03-01 09:19:55 -08:00
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
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
|
|
|
}
|