Add YogaNodeProperties implementation based on ByteBuffer

Summary:
@public
Adds an implementation of `YogaNodeProperties` that accesses style and layout properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.

This needs further cleanup after experimenting, e.g. to codegen the offsets.

Reviewed By: pasqualeanatriello

Differential Revision: D8911723

fbshipit-source-id: 3c24b57eb545155878896ebb5d64d4553eb6bedc
This commit is contained in:
David Aurelio
2018-07-30 09:30:51 -07:00
committed by Facebook Github Bot
parent b1821ab4cd
commit 3499e2e0ef
29 changed files with 2034 additions and 979 deletions

View File

@@ -9,21 +9,31 @@
package com.facebook.yoga;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class YGMarginTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_margin_start() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.START, 10f);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
@@ -58,11 +68,11 @@ public class YGMarginTest {
public void test_margin_top() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -97,13 +107,13 @@ public class YGMarginTest {
public void test_margin_end() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.END, 10f);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
@@ -138,12 +148,12 @@ public class YGMarginTest {
public void test_margin_bottom() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -178,12 +188,12 @@ public class YGMarginTest {
public void test_margin_and_flex_row() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.START, 10f);
root_child0.setMargin(YogaEdge.END, 10f);
@@ -219,11 +229,11 @@ public class YGMarginTest {
public void test_margin_and_flex_column() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
@@ -259,12 +269,12 @@ public class YGMarginTest {
public void test_margin_and_stretch_row() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
@@ -300,11 +310,11 @@ public class YGMarginTest {
public void test_margin_and_stretch_column() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.START, 10f);
root_child0.setMargin(YogaEdge.END, 10f);
@@ -340,17 +350,17 @@ public class YGMarginTest {
public void test_margin_with_sibling_row() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.END, 10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -394,16 +404,16 @@ public class YGMarginTest {
public void test_margin_with_sibling_column() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -447,18 +457,18 @@ public class YGMarginTest {
public void test_margin_auto_bottom() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.BOTTOM);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -503,18 +513,18 @@ public class YGMarginTest {
public void test_margin_auto_top() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.TOP);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -559,19 +569,19 @@ public class YGMarginTest {
public void test_margin_auto_bottom_and_top() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.TOP);
root_child0.setMarginAuto(YogaEdge.BOTTOM);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -616,19 +626,19 @@ public class YGMarginTest {
public void test_margin_auto_bottom_and_top_justify_center() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.TOP);
root_child0.setMarginAuto(YogaEdge.BOTTOM);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -673,24 +683,24 @@ public class YGMarginTest {
public void test_margin_auto_mutiple_children_column() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.TOP);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setMarginAuto(YogaEdge.TOP);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode(config);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
@@ -745,25 +755,25 @@ public class YGMarginTest {
public void test_margin_auto_mutiple_children_row() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setMarginAuto(YogaEdge.RIGHT);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode(config);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
@@ -818,20 +828,20 @@ public class YGMarginTest {
public void test_margin_auto_left_and_right_column() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -876,18 +886,18 @@ public class YGMarginTest {
public void test_margin_auto_left_and_right() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -932,20 +942,20 @@ public class YGMarginTest {
public void test_margin_auto_start_and_end_column() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.START);
root_child0.setMarginAuto(YogaEdge.END);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -990,18 +1000,18 @@ public class YGMarginTest {
public void test_margin_auto_start_and_end() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.START);
root_child0.setMarginAuto(YogaEdge.END);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1046,19 +1056,19 @@ public class YGMarginTest {
public void test_margin_auto_left_and_right_column_and_center() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1103,18 +1113,18 @@ public class YGMarginTest {
public void test_margin_auto_left() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1159,18 +1169,18 @@ public class YGMarginTest {
public void test_margin_auto_right() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1215,19 +1225,19 @@ public class YGMarginTest {
public void test_margin_auto_left_and_right_strech() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1272,18 +1282,18 @@ public class YGMarginTest {
public void test_margin_auto_top_and_bottom_strech() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.TOP);
root_child0.setMarginAuto(YogaEdge.BOTTOM);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1328,11 +1338,11 @@ public class YGMarginTest {
public void test_margin_should_not_be_part_of_max_height() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(250f);
root.setHeight(250f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.TOP, 20f);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
@@ -1369,11 +1379,11 @@ public class YGMarginTest {
public void test_margin_should_not_be_part_of_max_width() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setWidth(250f);
root.setHeight(250f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 20f);
root_child0.setWidth(100f);
root_child0.setMaxWidth(100f);
@@ -1410,12 +1420,12 @@ public class YGMarginTest {
public void test_margin_auto_left_right_child_bigger_than_parent() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(52f);
root.setHeight(52f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(72f);
@@ -1452,12 +1462,12 @@ public class YGMarginTest {
public void test_margin_auto_left_child_bigger_than_parent() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(52f);
root.setHeight(52f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setWidth(72f);
root_child0.setHeight(72f);
@@ -1493,12 +1503,12 @@ public class YGMarginTest {
public void test_margin_fix_left_auto_right_child_bigger_than_parent() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(52f);
root.setHeight(52f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 10f);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(72f);
@@ -1535,12 +1545,12 @@ public class YGMarginTest {
public void test_margin_auto_left_fix_right_child_bigger_than_parent() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(52f);
root.setHeight(52f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setMargin(YogaEdge.RIGHT, 10f);
root_child0.setWidth(72f);
@@ -1577,19 +1587,19 @@ public class YGMarginTest {
public void test_margin_auto_top_stretching_child() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasisPercent(0f);
root_child0.setMarginAuto(YogaEdge.TOP);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1634,19 +1644,19 @@ public class YGMarginTest {
public void test_margin_auto_left_stretching_child() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode(config);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasisPercent(0f);
root_child0.setMarginAuto(YogaEdge.LEFT);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode(config);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1687,4 +1697,7 @@ public class YGMarginTest {
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}