2016-10-23 10:27:32 -07:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-10-23 10:27:32 -07:00
|
|
|
*
|
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.
|
2016-10-23 10:27:32 -07:00
|
|
|
*/
|
|
|
|
|
2017-01-31 09:28:09 -08:00
|
|
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-05 02:56:20 -08:00
|
|
|
package com.facebook.yoga;
|
2016-10-23 10:27:32 -07:00
|
|
|
|
|
|
|
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)
|
2016-12-03 04:40:21 -08:00
|
|
|
public class YGJustifyContentTest {
|
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;
|
|
|
|
|
2016-10-23 10:27:32 -07:00
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_flex_start() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(10f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(20f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(92f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(82f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(72f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_flex_end() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.FLEX_END);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(72f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(82f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(92f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(10f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_center() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.CENTER);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(36f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(46f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(56f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(56f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(46f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(36f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_space_between() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.SPACE_BETWEEN);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(46f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(92f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(92f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(46f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_space_around() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.SPACE_AROUND);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setWidth(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(12f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(46f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(46f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(12f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_column_flex_start() {
|
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);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root_child1.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
2017-11-27 03:40:01 -08:00
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
2017-11-27 03:40:01 -08:00
|
|
|
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
2017-11-27 03:40:01 -08:00
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
2016-11-23 11:12:51 -08:00
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
2017-11-27 03:40:01 -08:00
|
|
|
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_column_flex_end() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setJustifyContent(YogaJustify.FLEX_END);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(72f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(82f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(92f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(72f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(82f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(92f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_column_center() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setJustifyContent(YogaJustify.CENTER);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(36f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(56f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(36f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(56f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_column_space_between() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setJustifyContent(YogaJustify.SPACE_BETWEEN);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(92f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(92f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_column_space_around() {
|
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);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setJustifyContent(YogaJustify.SPACE_AROUND);
|
2016-11-29 09:04:43 -08:00
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child0.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child1.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2016-11-29 09:04:43 -08:00
|
|
|
root_child2.setHeight(10f);
|
2016-10-23 10:27:32 -07:00
|
|
|
root.addChildAt(root_child2, 2);
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.LTR);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(12f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-12-02 05:47:43 -08:00
|
|
|
root.setDirection(YogaDirection.RTL);
|
2017-02-03 11:19:45 -08:00
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
2016-10-23 10:27:32 -07:00
|
|
|
|
2016-11-23 11:12:51 -08:00
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(12f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(80f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|
|
|
|
|
2017-11-24 07:06:16 -08:00
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_min_width_and_margin() {
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.CENTER);
|
|
|
|
root.setMargin(YogaEdge.LEFT, 100f);
|
|
|
|
root.setMinWidth(50f);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(50f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(15f, 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);
|
|
|
|
|
|
|
|
root.setDirection(YogaDirection.RTL);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(50f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(15f, 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_max_width_and_margin() {
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.CENTER);
|
|
|
|
root.setMargin(YogaEdge.LEFT, 100f);
|
|
|
|
root.setWidth(100f);
|
|
|
|
root.setMaxWidth(80f);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, 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);
|
|
|
|
|
|
|
|
root.setDirection(YogaDirection.RTL);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(80f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(30f, 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_column_min_height_and_margin() {
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root.setJustifyContent(YogaJustify.CENTER);
|
|
|
|
root.setMargin(YogaEdge.TOP, 100f);
|
|
|
|
root.setMinHeight(50f);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(50f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
root.setDirection(YogaDirection.RTL);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(50f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_colunn_max_height_and_margin() {
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root.setJustifyContent(YogaJustify.CENTER);
|
|
|
|
root.setMargin(YogaEdge.TOP, 100f);
|
|
|
|
root.setHeight(100f);
|
|
|
|
root.setMaxHeight(80f);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-11-24 07:06:16 -08:00
|
|
|
root_child0.setWidth(20f);
|
|
|
|
root_child0.setHeight(20f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
root.setDirection(YogaDirection.LTR);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(80f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
root.setDirection(YogaDirection.RTL);
|
|
|
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
|
|
|
|
|
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(80f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2017-11-27 03:40:01 -08:00
|
|
|
@Test
|
|
|
|
public void test_justify_content_column_space_evenly() {
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root.setJustifyContent(YogaJustify.SPACE_EVENLY);
|
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root_child0.setHeight(10f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root_child1.setHeight(10f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root_child2.setHeight(10f);
|
|
|
|
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(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(18f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(74f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, 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(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(18f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(46f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(74f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(102f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test_justify_content_row_space_evenly() {
|
|
|
|
YogaConfig config = new YogaConfig();
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
|
|
|
root.setJustifyContent(YogaJustify.SPACE_EVENLY);
|
|
|
|
root.setWidth(102f);
|
|
|
|
root.setHeight(102f);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child0 = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root_child0.setHeight(10f);
|
|
|
|
root.addChildAt(root_child0, 0);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child1 = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root_child1.setHeight(10f);
|
|
|
|
root.addChildAt(root_child1, 1);
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
final YogaNode root_child2 = createNode(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
root_child2.setHeight(10f);
|
|
|
|
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(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(26f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(51f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(77f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, 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(102f, root.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(102f, root.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(77f, root_child0.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(51f, root_child1.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
|
|
|
|
|
|
|
assertEquals(26f, root_child2.getLayoutX(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
|
|
|
|
assertEquals(0f, root_child2.getLayoutWidth(), 0.0f);
|
|
|
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
|
|
|
}
|
|
|
|
|
2018-07-30 09:30:51 -07:00
|
|
|
private YogaNode createNode(YogaConfig config) {
|
|
|
|
return mNodeFactory.create(config);
|
|
|
|
}
|
2016-10-23 10:27:32 -07:00
|
|
|
}
|