Move configuration to new YGConfig and pass them down to CalculateLayout

Summary:
Move configuration to new ```YGConfig``` and pass them down to CalculateLayout. See #418 .

Adds ```YGConfigNew()``` + ```YGConfigFree```, and changed ```YGSetExperimentalFeatureEnabled``` to use the config.

New function for calculation is ```YGNodeCalculateLayoutWithConfig```.
Closes https://github.com/facebook/yoga/pull/432

Reviewed By: astreet

Differential Revision: D4611359

Pulled By: emilsjolander

fbshipit-source-id: a1332f0e1b21cec02129dd021ee57408449e10b0
This commit is contained in:
Lukas Wöhrl
2017-03-01 09:19:55 -08:00
committed by Facebook Github Bot
parent 8668e43f6d
commit 37c48257ae
89 changed files with 4536 additions and 3049 deletions

View File

@@ -0,0 +1,49 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
@DoNotStrip
public class YogaConfig {
static {
SoLoader.loadLibrary("yoga");
}
long mNativePointer;
private native long jni_YGConfigNew();
public YogaConfig() {
mNativePointer = jni_YGConfigNew();
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
private native void jni_YGConfigFree(long nativePointer);
@Override
protected void finalize() throws Throwable {
try {
jni_YGConfigFree(mNativePointer);
} finally {
super.finalize();
}
}
private native void jni_YGConfigSetExperimentalFeatureEnabled(
long nativePointer,
int feature,
boolean enabled);
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
}
}

View File

@@ -35,20 +35,6 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGSetLogger(logger);
}
private static native void jni_YGSetExperimentalFeatureEnabled(
int feature,
boolean enabled);
public static void setExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
boolean enabled) {
jni_YGSetExperimentalFeatureEnabled(feature.intValue(), enabled);
}
private static native boolean jni_YGIsExperimentalFeatureEnabled(int feature);
public static boolean isExperimentalFeatureEnabled(YogaExperimentalFeature feature) {
return jni_YGIsExperimentalFeatureEnabled(feature.intValue());
}
private YogaNode mParent;
private List<YogaNode> mChildren;
private YogaMeasureFunction mMeasureFunction;
@@ -104,6 +90,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
}
}
private native long jni_YGNodeNewWithConfig(long configPointer);
public YogaNode(YogaConfig config) {
mNativePointer = jni_YGNodeNewWithConfig(config.mNativePointer);
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
private native void jni_YGNodeFree(long nativePointer);
@Override
protected void finalize() throws Throwable {

View File

@@ -150,6 +150,10 @@ static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
}
static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
}
void jni_YGSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
if (jLogger) {
jLogger->releaseAlias();
@@ -171,18 +175,6 @@ void jni_YGLog(alias_ref<jclass> clazz, jint level, jstring message) {
Environment::current()->ReleaseStringUTFChars(message, nMessage);
}
void jni_YGSetExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature, jboolean enabled) {
YGSetExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature), enabled);
}
jboolean jni_YGIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
return YGIsExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature));
}
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
return YGNodeGetInstanceCount();
}
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
const YGNodeRef node = YGNodeNew();
YGNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
@@ -190,6 +182,13 @@ jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
return reinterpret_cast<jlong>(node);
}
jlong jni_YGNodeNewWithConfig(alias_ref<jobject> thiz, jlong configPointer) {
const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer));
YGNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
YGNodeSetPrintFunc(node, YGPrint);
return reinterpret_cast<jlong>(node);
}
void jni_YGNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
delete YGNodeJobject(node);
@@ -368,6 +367,24 @@ YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
// Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
jlong jni_YGConfigNew(alias_ref<jobject>) {
return reinterpret_cast<jlong>(YGConfigNew());
}
void jni_YGConfigFree(alias_ref<jobject>, jlong nativePointer) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigFree(config);
}
void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref<jobject>, jlong nativePointer, jint feature, jboolean enabled) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetExperimentalFeatureEnabled(config, static_cast<YGExperimentalFeature>(feature), enabled);
}
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
return YGNodeGetInstanceCount();
}
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
jint JNI_OnLoad(JavaVM *vm, void *) {
@@ -375,6 +392,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
registerNatives("com/facebook/yoga/YogaNode",
{
YGMakeNativeMethod(jni_YGNodeNew),
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
YGMakeNativeMethod(jni_YGNodeFree),
YGMakeNativeMethod(jni_YGNodeReset),
YGMakeNativeMethod(jni_YGNodeInsertChild),
@@ -452,8 +470,12 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
YGMakeNativeMethod(jni_YGSetLogger),
YGMakeNativeMethod(jni_YGLog),
YGMakeNativeMethod(jni_YGSetExperimentalFeatureEnabled),
YGMakeNativeMethod(jni_YGIsExperimentalFeatureEnabled),
});
registerNatives("com/facebook/yoga/YogaConfig",
{
YGMakeNativeMethod(jni_YGConfigNew),
YGMakeNativeMethod(jni_YGConfigFree),
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),
});
});
}

View File

@@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals;
public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_width_height_start_top() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.START, 10f);
root_child0.setPosition(YogaEdge.TOP, 10f);
@@ -58,11 +60,13 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_width_height_end_bottom() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.END, 10f);
root_child0.setPosition(YogaEdge.BOTTOM, 10f);
@@ -98,11 +102,13 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_start_top_end_bottom() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.START, 10f);
root_child0.setPosition(YogaEdge.TOP, 10f);
@@ -138,11 +144,13 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_width_height_start_top_end_bottom() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.START, 10f);
root_child0.setPosition(YogaEdge.TOP, 10f);
@@ -180,19 +188,21 @@ public class YGAbsolutePositionTest {
@Test
public void test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setOverflow(YogaOverflow.HIDDEN);
root.setWidth(50f);
root.setHeight(50f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.START, 0f);
root_child0.setPosition(YogaEdge.TOP, 0f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(100f);
root_child0_child0.setHeight(100f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -235,7 +245,9 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_within_border() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setMargin(YogaEdge.LEFT, 10f);
root.setMargin(YogaEdge.TOP, 10f);
root.setMargin(YogaEdge.RIGHT, 10f);
@@ -251,7 +263,7 @@ public class YGAbsolutePositionTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.LEFT, 0f);
root_child0.setPosition(YogaEdge.TOP, 0f);
@@ -259,7 +271,7 @@ public class YGAbsolutePositionTest {
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setPositionType(YogaPositionType.ABSOLUTE);
root_child1.setPosition(YogaEdge.RIGHT, 0f);
root_child1.setPosition(YogaEdge.BOTTOM, 0f);
@@ -305,14 +317,16 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_and_justify_content_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setAlignItems(YogaAlign.CENTER);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(60f);
root_child0.setHeight(40f);
@@ -346,14 +360,16 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_and_justify_content_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setAlignItems(YogaAlign.FLEX_END);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(60f);
root_child0.setHeight(40f);
@@ -387,13 +403,15 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_justify_content_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(60f);
root_child0.setHeight(40f);
@@ -427,13 +445,15 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(60f);
root_child0.setHeight(40f);
@@ -467,12 +487,14 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_center_on_child_only() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignSelf(YogaAlign.CENTER);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(60f);
@@ -507,14 +529,16 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_and_justify_content_center_and_top_position() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setAlignItems(YogaAlign.CENTER);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.TOP, 10f);
root_child0.setWidth(60f);
@@ -549,14 +573,16 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_and_justify_content_center_and_bottom_position() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setAlignItems(YogaAlign.CENTER);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.BOTTOM, 10f);
root_child0.setWidth(60f);
@@ -591,14 +617,16 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_and_justify_content_center_and_left_position() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setAlignItems(YogaAlign.CENTER);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.LEFT, 5f);
root_child0.setWidth(60f);
@@ -633,14 +661,16 @@ public class YGAbsolutePositionTest {
@Test
public void test_absolute_layout_align_items_and_justify_content_center_and_right_position() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setAlignItems(YogaAlign.CENTER);
root.setFlexGrow(1f);
root.setWidth(110f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.RIGHT, 5f);
root_child0.setWidth(60f);

View File

@@ -18,33 +18,35 @@ import static org.junit.Assert.assertEquals;
public class YGAlignContentTest {
@Test
public void test_align_content_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWrap(YogaWrap.WRAP);
root.setWidth(130f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(10f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root_child4.setHeight(10f);
root.addChildAt(root_child4, 4);
@@ -117,30 +119,32 @@ public class YGAlignContentTest {
@Test
public void test_align_content_flex_start_without_height_on_children() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(10f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -212,36 +216,38 @@ public class YGAlignContentTest {
@Test
public void test_align_content_flex_start_with_flex() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(120f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(0f);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexBasisPercent(0f);
root_child1.setWidth(50f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setFlexGrow(1f);
root_child3.setFlexShrink(1f);
root_child3.setFlexBasisPercent(0f);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -313,33 +319,35 @@ public class YGAlignContentTest {
@Test
public void test_align_content_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignContent(YogaAlign.FLEX_END);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(10f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root_child4.setHeight(10f);
root.addChildAt(root_child4, 4);
@@ -412,29 +420,31 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -506,34 +516,36 @@ public class YGAlignContentTest {
@Test
public void test_align_content_spacebetween() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.SPACE_BETWEEN);
root.setWrap(YogaWrap.WRAP);
root.setWidth(130f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(10f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root_child4.setHeight(10f);
root.addChildAt(root_child4, 4);
@@ -606,34 +618,36 @@ public class YGAlignContentTest {
@Test
public void test_align_content_spacearound() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.SPACE_AROUND);
root.setWrap(YogaWrap.WRAP);
root.setWidth(140f);
root.setHeight(120f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(10f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root_child4.setHeight(10f);
root.addChildAt(root_child4, 4);
@@ -706,30 +720,32 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -801,36 +817,38 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_children() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1f);
root_child0_child0.setFlexBasisPercent(0f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -912,36 +930,38 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_flex() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setFlexGrow(1f);
root_child3.setFlexShrink(1f);
root_child3.setFlexBasisPercent(0f);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1013,35 +1033,37 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_flex_no_shrink() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setFlexGrow(1f);
root_child3.setFlexBasisPercent(0f);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1113,18 +1135,20 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_margin() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setMargin(YogaEdge.LEFT, 10f);
root_child1.setMargin(YogaEdge.TOP, 10f);
root_child1.setMargin(YogaEdge.RIGHT, 10f);
@@ -1132,11 +1156,11 @@ public class YGAlignContentTest {
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setMargin(YogaEdge.LEFT, 10f);
root_child3.setMargin(YogaEdge.TOP, 10f);
root_child3.setMargin(YogaEdge.RIGHT, 10f);
@@ -1144,7 +1168,7 @@ public class YGAlignContentTest {
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1216,18 +1240,20 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_padding() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setPadding(YogaEdge.LEFT, 10);
root_child1.setPadding(YogaEdge.TOP, 10);
root_child1.setPadding(YogaEdge.RIGHT, 10);
@@ -1235,11 +1261,11 @@ public class YGAlignContentTest {
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setPadding(YogaEdge.LEFT, 10);
root_child3.setPadding(YogaEdge.TOP, 10);
root_child3.setPadding(YogaEdge.RIGHT, 10);
@@ -1247,7 +1273,7 @@ public class YGAlignContentTest {
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1319,18 +1345,20 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_single_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -1372,31 +1400,33 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_fixed_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(60f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1468,31 +1498,33 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_max_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setMaxHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1564,31 +1596,33 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_row_with_min_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setMinHeight(80f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1660,38 +1694,40 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(150f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1f);
root_child0_child0.setFlexBasisPercent(0f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setHeight(50f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setHeight(50f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -1773,10 +1809,12 @@ public class YGAlignContentTest {
@Test
public void test_align_content_stretch_is_not_overriding_align_items() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignContent(YogaAlign.STRETCH);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setAlignContent(YogaAlign.STRETCH);
root_child0.setAlignItems(YogaAlign.CENTER);
@@ -1784,7 +1822,7 @@ public class YGAlignContentTest {
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0.setWidth(10f);
root_child0_child0.setHeight(10f);

View File

@@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals;
public class YGAlignItemsTest {
@Test
public void test_align_items_stretch() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
@@ -54,12 +56,14 @@ public class YGAlignItemsTest {
@Test
public void test_align_items_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -92,12 +96,14 @@ public class YGAlignItemsTest {
@Test
public void test_align_items_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -130,12 +136,14 @@ public class YGAlignItemsTest {
@Test
public void test_align_items_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.FLEX_END);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -168,18 +176,20 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
@@ -222,23 +232,25 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(10f);
root_child1.addChildAt(root_child1_child0, 0);
@@ -291,40 +303,42 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child_multiline() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexDirection(YogaFlexDirection.ROW);
root_child1.setWrap(YogaWrap.WRAP);
root_child1.setWidth(50f);
root_child1.setHeight(25f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(25f);
root_child1_child0.setHeight(20f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 = new YogaNode();
final YogaNode root_child1_child1 = new YogaNode(config);
root_child1_child1.setWidth(25f);
root_child1_child1.setHeight(10f);
root_child1.addChildAt(root_child1_child1, 1);
final YogaNode root_child1_child2 = new YogaNode();
final YogaNode root_child1_child2 = new YogaNode(config);
root_child1_child2.setWidth(25f);
root_child1_child2.setHeight(20f);
root_child1.addChildAt(root_child1_child2, 2);
final YogaNode root_child1_child3 = new YogaNode();
final YogaNode root_child1_child3 = new YogaNode(config);
root_child1_child3.setWidth(25f);
root_child1_child3.setHeight(10f);
root_child1.addChildAt(root_child1_child3, 3);
@@ -407,41 +421,43 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child_multiline_override() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexDirection(YogaFlexDirection.ROW);
root_child1.setWrap(YogaWrap.WRAP);
root_child1.setWidth(50f);
root_child1.setHeight(25f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(25f);
root_child1_child0.setHeight(20f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 = new YogaNode();
final YogaNode root_child1_child1 = new YogaNode(config);
root_child1_child1.setAlignSelf(YogaAlign.BASELINE);
root_child1_child1.setWidth(25f);
root_child1_child1.setHeight(10f);
root_child1.addChildAt(root_child1_child1, 1);
final YogaNode root_child1_child2 = new YogaNode();
final YogaNode root_child1_child2 = new YogaNode(config);
root_child1_child2.setWidth(25f);
root_child1_child2.setHeight(20f);
root_child1.addChildAt(root_child1_child2, 2);
final YogaNode root_child1_child3 = new YogaNode();
final YogaNode root_child1_child3 = new YogaNode(config);
root_child1_child3.setAlignSelf(YogaAlign.BASELINE);
root_child1_child3.setWidth(25f);
root_child1_child3.setHeight(10f);
@@ -525,40 +541,42 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child_multiline_no_override_on_secondline() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexDirection(YogaFlexDirection.ROW);
root_child1.setWrap(YogaWrap.WRAP);
root_child1.setWidth(50f);
root_child1.setHeight(25f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(25f);
root_child1_child0.setHeight(20f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child1_child1 = new YogaNode();
final YogaNode root_child1_child1 = new YogaNode(config);
root_child1_child1.setWidth(25f);
root_child1_child1.setHeight(10f);
root_child1.addChildAt(root_child1_child1, 1);
final YogaNode root_child1_child2 = new YogaNode();
final YogaNode root_child1_child2 = new YogaNode(config);
root_child1_child2.setWidth(25f);
root_child1_child2.setHeight(20f);
root_child1.addChildAt(root_child1_child2, 2);
final YogaNode root_child1_child3 = new YogaNode();
final YogaNode root_child1_child3 = new YogaNode(config);
root_child1_child3.setAlignSelf(YogaAlign.BASELINE);
root_child1_child3.setWidth(25f);
root_child1_child3.setHeight(10f);
@@ -642,24 +660,26 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child_top() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPosition(YogaEdge.TOP, 10f);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(10f);
root_child1.addChildAt(root_child1_child0, 0);
@@ -712,24 +732,26 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child_top2() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setPosition(YogaEdge.TOP, 5f);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(10f);
root_child1.addChildAt(root_child1_child0, 0);
@@ -782,28 +804,30 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_double_nested_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(50f);
root_child0_child0.setHeight(20f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(15f);
root_child1.addChildAt(root_child1_child0, 0);
@@ -866,17 +890,19 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
@@ -919,13 +945,15 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child_margin() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMargin(YogaEdge.LEFT, 5f);
root_child0.setMargin(YogaEdge.TOP, 5f);
root_child0.setMargin(YogaEdge.RIGHT, 5f);
@@ -934,12 +962,12 @@ public class YGAlignItemsTest {
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setMargin(YogaEdge.LEFT, 1f);
root_child1_child0.setMargin(YogaEdge.TOP, 1f);
root_child1_child0.setMargin(YogaEdge.RIGHT, 1f);
@@ -996,7 +1024,9 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_child_padding() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setPadding(YogaEdge.LEFT, 5);
@@ -1006,12 +1036,12 @@ public class YGAlignItemsTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setPadding(YogaEdge.LEFT, 5);
root_child1.setPadding(YogaEdge.TOP, 5);
root_child1.setPadding(YogaEdge.RIGHT, 5);
@@ -1020,7 +1050,7 @@ public class YGAlignItemsTest {
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(10f);
root_child1.addChildAt(root_child1_child0, 0);
@@ -1073,39 +1103,41 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_multiline() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(10f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(20f);
root.addChildAt(root_child2, 2);
final YogaNode root_child2_child0 = new YogaNode();
final YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.setWidth(50f);
root_child2_child0.setHeight(10f);
root_child2.addChildAt(root_child2_child0, 0);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(50f);
root.addChildAt(root_child3, 3);
@@ -1188,38 +1220,40 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_multiline_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.BASELINE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(20f);
root_child1_child0.setHeight(20f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(40f);
root_child2.setHeight(70f);
root.addChildAt(root_child2, 2);
final YogaNode root_child2_child0 = new YogaNode();
final YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.setWidth(10f);
root_child2_child0.setHeight(10f);
root_child2.addChildAt(root_child2_child0, 0);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(20f);
root.addChildAt(root_child3, 3);
@@ -1302,38 +1336,40 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_multiline_column2() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.BASELINE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(20f);
root_child1_child0.setHeight(20f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(40f);
root_child2.setHeight(70f);
root.addChildAt(root_child2, 2);
final YogaNode root_child2_child0 = new YogaNode();
final YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.setWidth(10f);
root_child2_child0.setHeight(10f);
root_child2.addChildAt(root_child2_child0, 0);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(20f);
root.addChildAt(root_child3, 3);
@@ -1416,39 +1452,41 @@ public class YGAlignItemsTest {
@Test
public void test_align_baseline_multiline_row_and_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(10f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(20f);
root.addChildAt(root_child2, 2);
final YogaNode root_child2_child0 = new YogaNode();
final YogaNode root_child2_child0 = new YogaNode(config);
root_child2_child0.setWidth(50f);
root_child2_child0.setHeight(10f);
root_child2.addChildAt(root_child2_child0, 0);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(50f);
root_child3.setHeight(20f);
root.addChildAt(root_child3, 3);

View File

@@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals;
public class YGAlignSelfTest {
@Test
public void test_align_self_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignSelf(YogaAlign.CENTER);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
@@ -56,11 +58,13 @@ public class YGAlignSelfTest {
@Test
public void test_align_self_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
@@ -94,11 +98,13 @@ public class YGAlignSelfTest {
@Test
public void test_align_self_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_START);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
@@ -132,12 +138,14 @@ public class YGAlignSelfTest {
@Test
public void test_align_self_flex_end_override_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
@@ -171,24 +179,26 @@ public class YGAlignSelfTest {
@Test
public void test_align_self_baseline() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignSelf(YogaAlign.BASELINE);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setAlignSelf(YogaAlign.BASELINE);
root_child1.setWidth(50f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidth(50f);
root_child1_child0.setHeight(10f);
root_child1.addChildAt(root_child1_child0, 0);

View File

@@ -18,7 +18,9 @@ import static org.junit.Assert.assertEquals;
public class YGBorderTest {
@Test
public void test_border_no_size() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setBorder(YogaEdge.LEFT, 10f);
root.setBorder(YogaEdge.TOP, 10f);
root.setBorder(YogaEdge.RIGHT, 10f);
@@ -42,13 +44,15 @@ public class YGBorderTest {
@Test
public void test_border_container_match_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setBorder(YogaEdge.LEFT, 10f);
root.setBorder(YogaEdge.TOP, 10f);
root.setBorder(YogaEdge.RIGHT, 10f);
root.setBorder(YogaEdge.BOTTOM, 10f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -81,7 +85,9 @@ public class YGBorderTest {
@Test
public void test_border_flex_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setBorder(YogaEdge.LEFT, 10f);
root.setBorder(YogaEdge.TOP, 10f);
root.setBorder(YogaEdge.RIGHT, 10f);
@@ -89,7 +95,7 @@ public class YGBorderTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
@@ -122,7 +128,9 @@ public class YGBorderTest {
@Test
public void test_border_stretch_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setBorder(YogaEdge.LEFT, 10f);
root.setBorder(YogaEdge.TOP, 10f);
root.setBorder(YogaEdge.RIGHT, 10f);
@@ -130,7 +138,7 @@ public class YGBorderTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
@@ -162,7 +170,9 @@ public class YGBorderTest {
@Test
public void test_border_center_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setAlignItems(YogaAlign.CENTER);
root.setBorder(YogaEdge.START, 10f);
@@ -171,7 +181,7 @@ public class YGBorderTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);

View File

@@ -18,9 +18,11 @@ import static org.junit.Assert.assertEquals;
public class YGDimensionTest {
@Test
public void test_wrap_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root_child0 = new YogaNode();
final YogaNode root = new YogaNode(config);
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
@@ -53,12 +55,14 @@ public class YGDimensionTest {
@Test
public void test_wrap_grandchild() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root_child0 = new YogaNode();
final YogaNode root = new YogaNode(config);
final YogaNode root_child0 = new YogaNode(config);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(100f);
root_child0_child0.setHeight(100f);
root_child0.addChildAt(root_child0_child0, 0);

View File

@@ -18,16 +18,18 @@ import static org.junit.Assert.assertEquals;
public class YGDisplayTest {
@Test
public void test_display_none() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
@@ -70,16 +72,18 @@ public class YGDisplayTest {
@Test
public void test_display_none_fixed_size() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(20f);
root_child1.setHeight(20f);
root_child1.setDisplay(YogaDisplay.NONE);
@@ -123,12 +127,14 @@ public class YGDisplayTest {
@Test
public void test_display_none_with_margin() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMargin(YogaEdge.LEFT, 10f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.RIGHT, 10f);
@@ -138,7 +144,7 @@ public class YGDisplayTest {
root_child0.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -180,25 +186,27 @@ public class YGDisplayTest {
@Test
public void test_display_none_with_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasisPercent(0f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setFlexGrow(1f);
root_child1_child0.setFlexShrink(1f);
root_child1_child0.setFlexBasisPercent(0f);
@@ -207,7 +215,7 @@ public class YGDisplayTest {
root_child1_child0.setMinHeight(0f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root_child2.setFlexShrink(1f);
root_child2.setFlexBasisPercent(0f);
@@ -271,16 +279,18 @@ public class YGDisplayTest {
@Test
public void test_display_none_with_position() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setPosition(YogaEdge.TOP, 10f);
root_child1.setDisplay(YogaDisplay.NONE);

View File

@@ -18,18 +18,20 @@ import static org.junit.Assert.assertEquals;
public class YGFlexDirectionTest {
@Test
public void test_flex_direction_column_no_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -81,19 +83,21 @@ public class YGFlexDirectionTest {
@Test
public void test_flex_direction_row_no_width() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -145,19 +149,21 @@ public class YGFlexDirectionTest {
@Test
public void test_flex_direction_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -209,20 +215,22 @@ public class YGFlexDirectionTest {
@Test
public void test_flex_direction_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -274,20 +282,22 @@ public class YGFlexDirectionTest {
@Test
public void test_flex_direction_column_reverse() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -339,20 +349,22 @@ public class YGFlexDirectionTest {
@Test
public void test_flex_direction_row_reverse() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);

View File

@@ -18,16 +18,18 @@ import static org.junit.Assert.assertEquals;
public class YGFlexTest {
@Test
public void test_flex_basis_flex_grow_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -69,17 +71,19 @@ public class YGFlexTest {
@Test
public void test_flex_basis_flex_grow_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -121,16 +125,18 @@ public class YGFlexTest {
@Test
public void test_flex_basis_flex_shrink_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasis(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexBasis(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -172,17 +178,19 @@ public class YGFlexTest {
@Test
public void test_flex_basis_flex_shrink_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasis(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexBasis(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -224,21 +232,23 @@ public class YGFlexTest {
@Test
public void test_flex_shrink_to_zero() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setHeight(75f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexShrink(1f);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
@@ -291,22 +301,24 @@ public class YGFlexTest {
@Test
public void test_flex_basis_overrides_main_size() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
@@ -359,14 +371,16 @@ public class YGFlexTest {
@Test
public void test_flex_grow_shrink_at_most() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1f);
root_child0.addChildAt(root_child0_child0, 0);

View File

@@ -18,26 +18,28 @@ import static org.junit.Assert.assertEquals;
public class YGFlexWrapTest {
@Test
public void test_wrap_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWrap(YogaWrap.WRAP);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(30f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(30f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(30f);
root.addChildAt(root_child3, 3);
@@ -100,27 +102,29 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(30f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(30f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(30f);
root.addChildAt(root_child3, 3);
@@ -183,28 +187,30 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_row_align_items_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.FLEX_END);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(30f);
root.addChildAt(root_child3, 3);
@@ -267,28 +273,30 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_row_align_items_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.CENTER);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(30f);
root.addChildAt(root_child3, 3);
@@ -351,18 +359,20 @@ public class YGFlexWrapTest {
@Test
public void test_flex_wrap_children_with_min_main_overriding_flex_basis() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWrap(YogaWrap.WRAP);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexBasis(50f);
root_child0.setMinWidth(55f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexBasis(50f);
root_child1.setMinWidth(55f);
root_child1.setHeight(50f);
@@ -406,24 +416,26 @@ public class YGFlexWrapTest {
@Test
public void test_flex_wrap_wrap_to_child_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root_child0 = new YogaNode();
final YogaNode root = new YogaNode(config);
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setAlignItems(YogaAlign.FLEX_START);
root_child0.setWrap(YogaWrap.WRAP);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(100f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = new YogaNode();
final YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.setWidth(100f);
root_child0_child0_child0.setHeight(100f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
@@ -486,17 +498,19 @@ public class YGFlexWrapTest {
@Test
public void test_flex_wrap_align_stretch_fits_one_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWrap(YogaWrap.WRAP);
root.setWidth(150f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -538,32 +552,34 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_reverse_row_align_content_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWrap(YogaWrap.WRAP_REVERSE);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(40f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(30f);
root_child4.setHeight(50f);
root.addChildAt(root_child4, 4);
@@ -636,33 +652,35 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_reverse_row_align_content_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.CENTER);
root.setWrap(YogaWrap.WRAP_REVERSE);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(40f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(30f);
root_child4.setHeight(50f);
root.addChildAt(root_child4, 4);
@@ -735,32 +753,34 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_reverse_row_single_line_different_size() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWrap(YogaWrap.WRAP_REVERSE);
root.setWidth(300f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(40f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(30f);
root_child4.setHeight(50f);
root.addChildAt(root_child4, 4);
@@ -833,33 +853,35 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_reverse_row_align_content_stretch() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setWrap(YogaWrap.WRAP_REVERSE);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(40f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(30f);
root_child4.setHeight(50f);
root.addChildAt(root_child4, 4);
@@ -932,33 +954,35 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_reverse_row_align_content_space_around() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.SPACE_AROUND);
root.setWrap(YogaWrap.WRAP_REVERSE);
root.setWidth(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(40f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(30f);
root_child4.setHeight(50f);
root.addChildAt(root_child4, 4);
@@ -1031,33 +1055,35 @@ public class YGFlexWrapTest {
@Test
public void test_wrap_reverse_column_fixed_size() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWrap(YogaWrap.WRAP_REVERSE);
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(30f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(30f);
root_child1.setHeight(20f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(30f);
root_child2.setHeight(30f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setWidth(30f);
root_child3.setHeight(40f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setWidth(30f);
root_child4.setHeight(50f);
root.addChildAt(root_child4, 4);
@@ -1130,22 +1156,24 @@ public class YGFlexWrapTest {
@Test
public void test_wrapped_row_within_align_items_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setWrap(YogaWrap.WRAP);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(150f);
root_child0_child0.setHeight(80f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = new YogaNode();
final YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.setWidth(80f);
root_child0_child1.setHeight(80f);
root_child0.addChildAt(root_child0_child1, 1);
@@ -1198,22 +1226,24 @@ public class YGFlexWrapTest {
@Test
public void test_wrapped_row_within_align_items_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setWrap(YogaWrap.WRAP);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(150f);
root_child0_child0.setHeight(80f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = new YogaNode();
final YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.setWidth(80f);
root_child0_child1.setHeight(80f);
root_child0.addChildAt(root_child0_child1, 1);
@@ -1266,22 +1296,24 @@ public class YGFlexWrapTest {
@Test
public void test_wrapped_row_within_align_items_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.FLEX_END);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setWrap(YogaWrap.WRAP);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(150f);
root_child0_child0.setHeight(80f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = new YogaNode();
final YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.setWidth(80f);
root_child0_child1.setHeight(80f);
root_child0.addChildAt(root_child0_child1, 1);

View File

@@ -18,20 +18,22 @@ import static org.junit.Assert.assertEquals;
public class YGJustifyContentTest {
@Test
public void test_justify_content_row_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -83,21 +85,23 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_row_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -149,21 +153,23 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_row_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -215,21 +221,23 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_row_space_between() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.SPACE_BETWEEN);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -281,21 +289,23 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_row_space_around() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.SPACE_AROUND);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -347,18 +357,20 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_column_flex_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -410,20 +422,22 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_column_flex_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -475,20 +489,22 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_column_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -540,20 +556,22 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_column_space_between() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.SPACE_BETWEEN);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -605,20 +623,22 @@ public class YGJustifyContentTest {
@Test
public void test_justify_content_column_space_around() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.SPACE_AROUND);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);

View File

@@ -18,12 +18,14 @@ import static org.junit.Assert.assertEquals;
public class YGMarginTest {
@Test
public void test_margin_start() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMargin(YogaEdge.START, 10f);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
@@ -56,11 +58,13 @@ public class YGMarginTest {
@Test
public void test_margin_top() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -93,13 +97,15 @@ public class YGMarginTest {
@Test
public void test_margin_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMargin(YogaEdge.END, 10f);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
@@ -132,12 +138,14 @@ public class YGMarginTest {
@Test
public void test_margin_bottom() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -170,12 +178,14 @@ public class YGMarginTest {
@Test
public void test_margin_and_flex_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.START, 10f);
root_child0.setMargin(YogaEdge.END, 10f);
@@ -209,11 +219,13 @@ public class YGMarginTest {
@Test
public void test_margin_and_flex_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
@@ -247,12 +259,14 @@ public class YGMarginTest {
@Test
public void test_margin_and_stretch_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
@@ -286,11 +300,13 @@ public class YGMarginTest {
@Test
public void test_margin_and_stretch_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.START, 10f);
root_child0.setMargin(YogaEdge.END, 10f);
@@ -324,17 +340,19 @@ public class YGMarginTest {
@Test
public void test_margin_with_sibling_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.END, 10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -376,16 +394,18 @@ public class YGMarginTest {
@Test
public void test_margin_with_sibling_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -427,18 +447,20 @@ public class YGMarginTest {
@Test
public void test_margin_auto_bottom() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -481,18 +503,20 @@ public class YGMarginTest {
@Test
public void test_margin_auto_top() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -535,19 +559,21 @@ public class YGMarginTest {
@Test
public void test_margin_auto_bottom_and_top() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -590,19 +616,21 @@ public class YGMarginTest {
@Test
public void test_margin_auto_bottom_and_top_justify_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -645,24 +673,26 @@ public class YGMarginTest {
@Test
public void test_margin_auto_mutiple_children_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(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();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
@@ -715,25 +745,27 @@ public class YGMarginTest {
@Test
public void test_margin_auto_mutiple_children_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(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();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
@@ -786,20 +818,22 @@ public class YGMarginTest {
@Test
public void test_margin_auto_left_and_right_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -842,18 +876,20 @@ public class YGMarginTest {
@Test
public void test_margin_auto_left_and_right() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1006,19 +1042,21 @@ public class YGMarginTest {
@Test
public void test_margin_auto_left_and_right_column_and_center() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1061,18 +1099,20 @@ public class YGMarginTest {
@Test
public void test_margin_auto_left() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1115,18 +1155,20 @@ public class YGMarginTest {
@Test
public void test_margin_auto_right() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1169,19 +1211,21 @@ public class YGMarginTest {
@Test
public void test_margin_auto_left_and_right_strech() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
@@ -1224,18 +1268,20 @@ public class YGMarginTest {
@Test
public void test_margin_auto_top_and_bottom_strech() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(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();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);

View File

@@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals;
public class YGMinMaxDimensionTest {
@Test
public void test_max_width() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMaxWidth(50f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -55,12 +57,14 @@ public class YGMinMaxDimensionTest {
@Test
public void test_max_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setMaxHeight(50f);
root.addChildAt(root_child0, 0);
@@ -93,16 +97,18 @@ public class YGMinMaxDimensionTest {
@Test
public void test_min_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMinHeight(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -144,17 +150,19 @@ public class YGMinMaxDimensionTest {
@Test
public void test_min_width() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMinWidth(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -196,13 +204,15 @@ public class YGMinMaxDimensionTest {
@Test
public void test_justify_content_min_max() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setWidth(100f);
root.setMinHeight(100f);
root.setMaxHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(60f);
root_child0.setHeight(60f);
root.addChildAt(root_child0, 0);
@@ -235,13 +245,15 @@ public class YGMinMaxDimensionTest {
@Test
public void test_align_items_min_max() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setMinWidth(100f);
root.setMaxWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(60f);
root_child0.setHeight(60f);
root.addChildAt(root_child0, 0);
@@ -274,22 +286,24 @@ public class YGMinMaxDimensionTest {
@Test
public void test_justify_content_overflow_min_max() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setMinHeight(100f);
root.setMaxHeight(110f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
@@ -342,19 +356,20 @@ public class YGMinMaxDimensionTest {
@Test
public void test_flex_grow_to_min() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setMinHeight(100f);
root.setMaxHeight(500f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexShrink(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -392,25 +407,24 @@ public class YGMinMaxDimensionTest {
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, false);
}
@Test
public void test_flex_grow_in_at_most_container() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.FLEX_START);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexBasis(0f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -449,22 +463,22 @@ public class YGMinMaxDimensionTest {
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, false);
}
@Test
public void test_flex_grow_within_max_width() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setMaxWidth(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setHeight(20f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -507,16 +521,18 @@ public class YGMinMaxDimensionTest {
@Test
public void test_flex_grow_within_constrained_max_width() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setMaxWidth(300f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setHeight(20f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -559,16 +575,18 @@ public class YGMinMaxDimensionTest {
@Test
public void test_flex_grow_within_constrained_min_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setMinWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setWidth(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -610,14 +628,16 @@ public class YGMinMaxDimensionTest {
@Test
public void test_flex_grow_within_constrained_min_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setMinHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -659,21 +679,23 @@ public class YGMinMaxDimensionTest {
@Test
public void test_flex_grow_within_constrained_max_row() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setMaxWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexShrink(1f);
root_child0_child0.setFlexBasis(100f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = new YogaNode();
final YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.setWidth(50f);
root_child0.addChildAt(root_child0_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -725,16 +747,18 @@ public class YGMinMaxDimensionTest {
@Test
public void test_flex_grow_within_constrained_max_column() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setMaxHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasis(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
@@ -776,7 +800,9 @@ public class YGMinMaxDimensionTest {
@Test
public void test_min_width_overrides_width() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(50f);
root.setMinWidth(100f);
root.setDirection(YogaDirection.LTR);
@@ -798,7 +824,9 @@ public class YGMinMaxDimensionTest {
@Test
public void test_max_width_overrides_width() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setMaxWidth(100f);
root.setDirection(YogaDirection.LTR);
@@ -820,7 +848,9 @@ public class YGMinMaxDimensionTest {
@Test
public void test_min_height_overrides_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setHeight(50f);
root.setMinHeight(100f);
root.setDirection(YogaDirection.LTR);
@@ -842,7 +872,9 @@ public class YGMinMaxDimensionTest {
@Test
public void test_max_height_overrides_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setHeight(200f);
root.setMaxHeight(100f);
root.setDirection(YogaDirection.LTR);
@@ -864,12 +896,14 @@ public class YGMinMaxDimensionTest {
@Test
public void test_min_max_percent_no_width_height() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setMinWidthPercent(10f);
root_child0.setMaxWidthPercent(10f);
root_child0.setMinHeightPercent(10f);

View File

@@ -18,7 +18,9 @@ import static org.junit.Assert.assertEquals;
public class YGPaddingTest {
@Test
public void test_padding_no_size() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
@@ -42,13 +44,15 @@ public class YGPaddingTest {
@Test
public void test_padding_container_match_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
root.setPadding(YogaEdge.BOTTOM, 10);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -81,7 +85,9 @@ public class YGPaddingTest {
@Test
public void test_padding_flex_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
@@ -89,7 +95,7 @@ public class YGPaddingTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
@@ -122,7 +128,9 @@ public class YGPaddingTest {
@Test
public void test_padding_stretch_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
@@ -130,7 +138,7 @@ public class YGPaddingTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
@@ -162,7 +170,9 @@ public class YGPaddingTest {
@Test
public void test_padding_center_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
root.setAlignItems(YogaAlign.CENTER);
root.setPadding(YogaEdge.START, 10);
@@ -171,7 +181,7 @@ public class YGPaddingTest {
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
@@ -204,13 +214,15 @@ public class YGPaddingTest {
@Test
public void test_child_with_padding_align_end() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setAlignItems(YogaAlign.FLEX_END);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPadding(YogaEdge.LEFT, 20);
root_child0.setPadding(YogaEdge.TOP, 20);
root_child0.setPadding(YogaEdge.RIGHT, 20);

View File

@@ -18,14 +18,15 @@ import static org.junit.Assert.assertEquals;
public class YGPercentageTest {
@Test
public void test_percentage_width_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidthPercent(30f);
root_child0.setHeightPercent(30f);
root.addChildAt(root_child0, 0);
@@ -54,20 +55,19 @@ public class YGPercentageTest {
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_position_left_top() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(400f);
root.setHeight(400f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionPercent(YogaEdge.LEFT, 10f);
root_child0.setPositionPercent(YogaEdge.TOP, 20f);
root_child0.setWidthPercent(45f);
@@ -98,20 +98,19 @@ public class YGPercentageTest {
assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(180f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(220f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_position_bottom_right() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(500f);
root.setHeight(500f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionPercent(YogaEdge.RIGHT, 20f);
root_child0.setPositionPercent(YogaEdge.BOTTOM, 10f);
root_child0.setWidthPercent(55f);
@@ -142,25 +141,24 @@ public class YGPercentageTest {
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(275f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexBasisPercent(25f);
root.addChildAt(root_child1, 1);
@@ -199,24 +197,23 @@ public class YGPercentageTest {
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(75f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexBasisPercent(25f);
root.addChildAt(root_child1, 1);
@@ -255,24 +252,23 @@ public class YGPercentageTest {
assertEquals(125f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_min_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMinHeightPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(2f);
root_child1.setMinHeightPercent(10f);
root.addChildAt(root_child1, 1);
@@ -311,26 +307,25 @@ public class YGPercentageTest {
assertEquals(140f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_max_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMaxHeightPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMaxHeightPercent(20f);
@@ -370,25 +365,24 @@ public class YGPercentageTest {
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(148f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_max_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMaxHeightPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMaxHeightPercent(20f);
@@ -428,26 +422,25 @@ public class YGPercentageTest {
assertEquals(120f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_max_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(15f);
root_child0.setMaxWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMaxWidthPercent(20f);
@@ -487,25 +480,24 @@ public class YGPercentageTest {
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_max_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMaxWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(15f);
root_child1.setMaxWidthPercent(20f);
@@ -545,26 +537,25 @@ public class YGPercentageTest {
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_min_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(15f);
root_child0.setMinWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMinWidthPercent(20f);
@@ -604,25 +595,24 @@ public class YGPercentageTest {
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_min_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMinWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(15f);
root_child1.setMinWidthPercent(20f);
@@ -662,19 +652,18 @@ public class YGPercentageTest {
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_multiple_nested_with_padding_margin_and_percentage_values() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMargin(YogaEdge.LEFT, 5f);
@@ -688,7 +677,7 @@ public class YGPercentageTest {
root_child0.setMinWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setMargin(YogaEdge.LEFT, 5f);
root_child0_child0.setMargin(YogaEdge.TOP, 5f);
root_child0_child0.setMargin(YogaEdge.RIGHT, 5f);
@@ -700,7 +689,7 @@ public class YGPercentageTest {
root_child0_child0.setWidthPercent(50f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = new YogaNode();
final YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.setMarginPercent(YogaEdge.LEFT, 5f);
root_child0_child0_child0.setMarginPercent(YogaEdge.TOP, 5f);
root_child0_child0_child0.setMarginPercent(YogaEdge.RIGHT, 5f);
@@ -712,7 +701,7 @@ public class YGPercentageTest {
root_child0_child0_child0.setWidthPercent(45f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(15f);
root_child1.setMinWidthPercent(20f);
@@ -772,19 +761,18 @@ public class YGPercentageTest {
assertEquals(58f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(142f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_margin_should_calculate_based_only_on_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setMarginPercent(YogaEdge.LEFT, 10f);
root_child0.setMarginPercent(YogaEdge.TOP, 10f);
@@ -792,7 +780,7 @@ public class YGPercentageTest {
root_child0.setMarginPercent(YogaEdge.BOTTOM, 10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(10f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -831,19 +819,18 @@ public class YGPercentageTest {
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_padding_should_calculate_based_only_on_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setPaddingPercent(YogaEdge.LEFT, 10);
root_child0.setPaddingPercent(YogaEdge.TOP, 10);
@@ -851,7 +838,7 @@ public class YGPercentageTest {
root_child0.setPaddingPercent(YogaEdge.BOTTOM, 10);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(10f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -890,19 +877,18 @@ public class YGPercentageTest {
assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_absolute_position() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionPercent(YogaEdge.LEFT, 30f);
root_child0.setPositionPercent(YogaEdge.TOP, 10f);
@@ -934,15 +920,15 @@ public class YGPercentageTest {
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_width_height_undefined_parent_size() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root_child0 = new YogaNode();
final YogaNode root = new YogaNode(config);
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidthPercent(50f);
root_child0.setHeightPercent(50f);
root.addChildAt(root_child0, 0);
@@ -975,24 +961,26 @@ public class YGPercentageTest {
@Test
public void test_percent_within_flex_grow() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(350f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = new YogaNode();
final YogaNode root_child1_child0 = new YogaNode(config);
root_child1_child0.setWidthPercent(100f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setWidth(100f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);

View File

@@ -18,22 +18,23 @@ import static org.junit.Assert.assertEquals;
public class YGRoundingTest {
@Test
public void test_rounding_flex_basis_flex_grow_row_width_of_100() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -81,36 +82,35 @@ public class YGRoundingTest {
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(33f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_flex_basis_flex_grow_row_prime_number_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(113f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = new YogaNode();
final YogaNode root_child3 = new YogaNode(config);
root_child3.setFlexGrow(1f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = new YogaNode();
final YogaNode root_child4 = new YogaNode(config);
root_child4.setFlexGrow(1f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
@@ -178,29 +178,28 @@ public class YGRoundingTest {
assertEquals(0f, root_child4.getLayoutY(), 0.0f);
assertEquals(23f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_flex_basis_flex_shrink_row() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(101f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasis(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexBasis(25f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexBasis(25f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
@@ -248,30 +247,29 @@ public class YGRoundingTest {
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_flex_basis_overrides_main_size() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(113f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
@@ -320,30 +318,29 @@ public class YGRoundingTest {
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_total_fractial() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(87.4f);
root.setHeight(113.4f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(0.7f);
root_child0.setFlexBasis(50.3f);
root_child0.setHeight(20.3f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1.6f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1.1f);
root_child2.setHeight(10.7f);
root.addChildAt(root_child2, 2);
@@ -392,44 +389,43 @@ public class YGRoundingTest {
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(87f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_total_fractial_nested() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(87.4f);
root.setHeight(113.4f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(0.7f);
root_child0.setFlexBasis(50.3f);
root_child0.setHeight(20.3f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexBasis(0.3f);
root_child0_child0.setPosition(YogaEdge.BOTTOM, 13.3f);
root_child0_child0.setHeight(9.9f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = new YogaNode();
final YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.setFlexGrow(4f);
root_child0_child1.setFlexBasis(0.3f);
root_child0_child1.setPosition(YogaEdge.TOP, 13.3f);
root_child0_child1.setHeight(1.1f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1.6f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1.1f);
root_child2.setHeight(10.7f);
root.addChildAt(root_child2, 2);
@@ -498,30 +494,29 @@ public class YGRoundingTest {
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(87f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_1() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(113.4f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
@@ -570,30 +565,29 @@ public class YGRoundingTest {
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_2() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(113.6f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
@@ -642,31 +636,30 @@ public class YGRoundingTest {
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_3() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setPosition(YogaEdge.TOP, 0.3f);
root.setWidth(100f);
root.setHeight(113.4f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
@@ -715,31 +708,30 @@ public class YGRoundingTest {
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_4() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
YogaConfig config = new YogaConfig();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
final YogaNode root = new YogaNode(config);
root.setPosition(YogaEdge.TOP, 0.7f);
root.setWidth(100f);
root.setHeight(113.4f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
final YogaNode root_child1 = new YogaNode(config);
root_child1.setFlexGrow(1f);
root_child1.setHeight(10f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = new YogaNode();
final YogaNode root_child2 = new YogaNode(config);
root_child2.setFlexGrow(1f);
root_child2.setHeight(10f);
root.addChildAt(root_child2, 2);
@@ -788,8 +780,6 @@ public class YGRoundingTest {
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
}

View File

@@ -18,14 +18,16 @@ import static org.junit.Assert.assertEquals;
public class YGSizeOverflowTest {
@Test
public void test_nested_overflowing_child() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(200f);
root_child0_child0.setHeight(200f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -68,16 +70,18 @@ public class YGSizeOverflowTest {
@Test
public void test_nested_overflowing_child_in_constraint_parent() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(200f);
root_child0_child0.setHeight(200f);
root_child0.addChildAt(root_child0_child0, 0);
@@ -120,15 +124,17 @@ public class YGSizeOverflowTest {
@Test
public void test_parent_wrap_child_size_overflowing_parent() {
final YogaNode root = new YogaNode();
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
final YogaNode root_child0 = new YogaNode(config);
root_child0.setWidth(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setWidth(100f);
root_child0_child0.setHeight(200f);
root_child0.addChildAt(root_child0_child0, 0);