diff --git a/java/com/facebook/yoga/YogaNode.java b/java/com/facebook/yoga/YogaNode.java index 3b706815..baa0c517 100644 --- a/java/com/facebook/yoga/YogaNode.java +++ b/java/com/facebook/yoga/YogaNode.java @@ -213,7 +213,5 @@ public abstract class YogaNode { public abstract void print(); - public abstract void setStyleInputs(float[] styleInputs, int size); - public abstract YogaNode cloneWithoutChildren(); } diff --git a/java/com/facebook/yoga/YogaNodeJNIBase.java b/java/com/facebook/yoga/YogaNodeJNIBase.java index 036e6114..c08e43de 100644 --- a/java/com/facebook/yoga/YogaNodeJNIBase.java +++ b/java/com/facebook/yoga/YogaNodeJNIBase.java @@ -678,13 +678,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable { YogaNative.jni_YGNodePrint(mNativePointer); } - public void setStyleInputs(float[] styleInputsArray, int size) { - if (useVanillaJNI) - YogaNative.jni_YGNodeSetStyleInputsJNI(mNativePointer, styleInputsArray, size); - else - YogaNative.jni_YGNodeSetStyleInputs(mNativePointer, styleInputsArray, size); - } - /** * This method replaces the child at childIndex position with the newNode received by parameter. * This is different than calling removeChildAt and addChildAt because this method ONLY replaces diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index a377f17a..8691b8bf 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -531,16 +531,6 @@ void jni_YGConfigSetLogger( } } -void jni_YGNodeSetStyleInputs( - alias_ref, - jlong nativePointer, - alias_ref styleInputs, - jint size) { - float result[size]; - styleInputs->getRegion(0, size, result); - YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size); -} - jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) { YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) { @@ -706,7 +696,6 @@ jint YGJNI::registerNativeMethods(JavaVM* vm) { YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio), YGMakeCriticalNativeMethod(jni_YGNodePrint), YGMakeNativeMethod(jni_YGNodeClone), - YGMakeNativeMethod(jni_YGNodeSetStyleInputs), YGMakeNativeMethod(jni_YGConfigNew), YGMakeNativeMethod(jni_YGConfigFree), YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled), diff --git a/java/jni/YGJNI.h b/java/jni/YGJNI.h index 7bafdd52..dbff73f9 100644 --- a/java/jni/YGJNI.h +++ b/java/jni/YGJNI.h @@ -5,49 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -enum YGStyleInput { - LayoutDirection, - FlexDirection, - Flex, - FlexGrow, - FlexShrink, - FlexBasis, - FlexBasisPercent, - FlexBasisAuto, - FlexWrap, - Width, - WidthPercent, - WidthAuto, - MinWidth, - MinWidthPercent, - MaxWidth, - MaxWidthPercent, - Height, - HeightPercent, - HeightAuto, - MinHeight, - MinHeightPercent, - MaxHeight, - MaxHeightPercent, - JustifyContent, - AlignItems, - AlignSelf, - AlignContent, - PositionType, - AspectRatio, - Overflow, - Display, - Margin, - MarginPercent, - MarginAuto, - Padding, - PaddingPercent, - Border, - Position, - PositionPercent, - IsReferenceBaseline, -}; - const short int LAYOUT_EDGE_SET_FLAG_INDEX = 0; const short int LAYOUT_WIDTH_INDEX = 1; const short int LAYOUT_HEIGHT_INDEX = 2; @@ -113,171 +70,3 @@ struct YogaValue { } }; } // namespace - -static void YGNodeSetStyleInputs( - const YGNodeRef node, - float* styleInputs, - int size) { - const auto end = styleInputs + size; - auto edgesSet = YGNodeEdges{node}; - while (styleInputs < end) { - auto styleInputKey = static_cast((int) *styleInputs++); - switch (styleInputKey) { - case LayoutDirection: - YGNodeStyleSetDirection(node, static_cast(*styleInputs++)); - break; - case FlexDirection: - YGNodeStyleSetFlexDirection( - node, static_cast(*styleInputs++)); - break; - case Flex: - YGNodeStyleSetFlex(node, *styleInputs++); - break; - case FlexGrow: - YGNodeStyleSetFlexGrow(node, *styleInputs++); - break; - case FlexShrink: - YGNodeStyleSetFlexShrink(node, *styleInputs++); - break; - case FlexBasis: - YGNodeStyleSetFlexBasis(node, *styleInputs++); - break; - case FlexBasisPercent: - YGNodeStyleSetFlexBasisPercent(node, *styleInputs++); - break; - case FlexBasisAuto: - YGNodeStyleSetFlexBasisAuto(node); - break; - case FlexWrap: - YGNodeStyleSetFlexWrap(node, static_cast(*styleInputs++)); - break; - case Width: - YGNodeStyleSetWidth(node, *styleInputs++); - break; - case WidthPercent: - YGNodeStyleSetWidthPercent(node, *styleInputs++); - break; - case WidthAuto: - YGNodeStyleSetWidthAuto(node); - break; - case MinWidth: - YGNodeStyleSetMinWidth(node, *styleInputs++); - break; - case MinWidthPercent: - YGNodeStyleSetMinWidthPercent(node, *styleInputs++); - break; - case MaxWidth: - YGNodeStyleSetMaxWidth(node, *styleInputs++); - break; - case MaxWidthPercent: - YGNodeStyleSetMaxWidthPercent(node, *styleInputs++); - break; - case Height: - YGNodeStyleSetHeight(node, *styleInputs++); - break; - case HeightPercent: - YGNodeStyleSetHeightPercent(node, *styleInputs++); - break; - case HeightAuto: - YGNodeStyleSetHeightAuto(node); - break; - case MinHeight: - YGNodeStyleSetMinHeight(node, *styleInputs++); - break; - case MinHeightPercent: - YGNodeStyleSetMinHeightPercent(node, *styleInputs++); - break; - case MaxHeight: - YGNodeStyleSetMaxHeight(node, *styleInputs++); - break; - case MaxHeightPercent: - YGNodeStyleSetMaxHeightPercent(node, *styleInputs++); - break; - case JustifyContent: - YGNodeStyleSetJustifyContent( - node, static_cast(*styleInputs++)); - break; - case AlignItems: - YGNodeStyleSetAlignItems(node, static_cast(*styleInputs++)); - break; - case AlignSelf: - YGNodeStyleSetAlignSelf(node, static_cast(*styleInputs++)); - break; - case AlignContent: - YGNodeStyleSetAlignContent(node, static_cast(*styleInputs++)); - break; - case PositionType: - YGNodeStyleSetPositionType( - node, static_cast(*styleInputs++)); - break; - case AspectRatio: - YGNodeStyleSetAspectRatio(node, *styleInputs++); - break; - case Overflow: - YGNodeStyleSetOverflow(node, static_cast(*styleInputs++)); - break; - case Display: - YGNodeStyleSetDisplay(node, static_cast(*styleInputs++)); - break; - case Margin: { - auto edge = static_cast(*styleInputs++); - float marginValue = *styleInputs++; - edgesSet.add(YGNodeEdges::MARGIN); - YGNodeStyleSetMargin(node, edge, marginValue); - break; - } - case MarginPercent: { - auto edge = static_cast(*styleInputs++); - float marginPercent = *styleInputs++; - edgesSet.add(YGNodeEdges::MARGIN); - YGNodeStyleSetMarginPercent(node, edge, marginPercent); - break; - } - case MarginAuto: { - edgesSet.add(YGNodeEdges::MARGIN); - YGNodeStyleSetMarginAuto(node, static_cast(*styleInputs++)); - break; - } - case Padding: { - auto edge = static_cast(*styleInputs++); - float paddingValue = *styleInputs++; - edgesSet.add(YGNodeEdges::PADDING); - YGNodeStyleSetPadding(node, edge, paddingValue); - break; - } - case PaddingPercent: { - auto edge = static_cast(*styleInputs++); - float paddingPercent = *styleInputs++; - edgesSet.add(YGNodeEdges::PADDING); - YGNodeStyleSetPaddingPercent(node, edge, paddingPercent); - break; - } - case Border: { - auto edge = static_cast(*styleInputs++); - float borderValue = *styleInputs++; - edgesSet.add(YGNodeEdges::BORDER); - YGNodeStyleSetBorder(node, edge, borderValue); - break; - } - case Position: { - auto edge = static_cast(*styleInputs++); - float positionValue = *styleInputs++; - YGNodeStyleSetPosition(node, edge, positionValue); - break; - } - case PositionPercent: { - auto edge = static_cast(*styleInputs++); - float positionPercent = *styleInputs++; - YGNodeStyleSetPositionPercent(node, edge, positionPercent); - break; - } - case IsReferenceBaseline: { - YGNodeSetIsReferenceBaseline(node, *styleInputs++ == 1 ? true : false); - break; - } - default: - break; - } - } - edgesSet.setOn(node); -} diff --git a/java/jni/YGJNIVanilla.cpp b/java/jni/YGJNIVanilla.cpp index 9a38c575..3ac88ac1 100644 --- a/java/jni/YGJNIVanilla.cpp +++ b/java/jni/YGJNIVanilla.cpp @@ -721,17 +721,6 @@ static jlong jni_YGNodeCloneJNI(JNIEnv* env, jobject obj, jlong nativePointer) { // Yoga specific properties, not compatible with flexbox specification YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); -static void jni_YGNodeSetStyleInputsJNI( - JNIEnv* env, - jobject obj, - jlong nativePointer, - jfloatArray styleInputs, - jint size) { - float result[size]; - env->GetFloatArrayRegion(styleInputs, 0, size, result); - YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size); -} - static JNINativeMethod methods[] = { {"jni_YGConfigNewJNI", "()J", (void*) jni_YGConfigNewJNI}, {"jni_YGConfigFreeJNI", "(J)V", (void*) jni_YGConfigFreeJNI}, @@ -969,9 +958,6 @@ static JNINativeMethod methods[] = { "(JZ)V", (void*) jni_YGNodeSetHasBaselineFuncJNI}, {"jni_YGNodePrintJNI", "(J)V", (void*) jni_YGNodePrintJNI}, - {"jni_YGNodeSetStyleInputsJNI", - "(J[FI)V", - (void*) jni_YGNodeSetStyleInputsJNI}, {"jni_YGNodeCloneJNI", "(J)J", (void*) jni_YGNodeCloneJNI}, }; diff --git a/java/tests/com/facebook/yoga/BatchingAPITests.java b/java/tests/com/facebook/yoga/BatchingAPITests.java deleted file mode 100644 index 93e00db0..00000000 --- a/java/tests/com/facebook/yoga/BatchingAPITests.java +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.yoga; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; - -@RunWith(Parameterized.class) -public class BatchingAPITests { - - @Parameterized.Parameters(name = "{0}") - public static Iterable nodeFactories() { - return TestParametrization.nodeFactories(); - } - - @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; - - @Test - public void testStyleInputLayoutDirection() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.LAYOUT_DIRECTION, YogaDirection.LTR.intValue()}; - root.setStyleInputs(arr, 2); - root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); - assertEquals(root.getLayoutDirection(), YogaDirection.LTR); - } - - @Test - public void testStyleInputFlexDirection() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX_DIRECTION, YogaFlexDirection.ROW.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getFlexDirection(), YogaFlexDirection.ROW); - } - - @Test - public void testStyleInputFlex() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getFlex(), 5f, 0.0f); - } - - @Test - public void testStyleInputFlexGrow() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX_GROW, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getFlexGrow(), 5f, 0.0f); - } - - @Test - public void testStyleInputFlexShrink() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX_SHRINK, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getFlexShrink(), 5f, 0.0f); - } - - @Test - public void testStyleInputFlexBasis() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX_BASIS, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getFlexBasis(), new YogaValue(5f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputFlexBasisPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX_BASIS_PERCENT, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getFlexBasis(), new YogaValue(5f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputFlexBasisAuto() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX_BASIS_AUTO}; - root.setStyleInputs(arr, 1); - assertEquals(root.getFlexBasis(), YogaValue.AUTO); - } - - @Test - public void testStyleInputFlexWrap() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.FLEX_WRAP, YogaWrap.WRAP.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getWrap(), YogaWrap.WRAP); - } - - @Test - public void testStyleInputWidth() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.WIDTH, 50f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getWidth(), new YogaValue(50f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputWidthPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.WIDTH_PERCENT, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getWidth(), new YogaValue(5f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputWidthAuto() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.WIDTH_AUTO}; - root.setStyleInputs(arr, 1); - assertEquals(root.getWidth(), YogaValue.AUTO); - } - - @Test - public void testStyleInputMinWidth() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MIN_WIDTH, 50f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMinWidth(), new YogaValue(50f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputMinWidthPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MIN_WIDTH_PERCENT, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMinWidth(), new YogaValue(5f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputMaxWidth() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MAX_WIDTH, 50f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMaxWidth(), new YogaValue(50f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputMaxWidthPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MAX_WIDTH_PERCENT, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMaxWidth(), new YogaValue(5f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputHeight() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.HEIGHT, 50f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getHeight(), new YogaValue(50f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputHeightPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.HEIGHT_PERCENT, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getHeight(), new YogaValue(5f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputHeightAuto() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.HEIGHT_AUTO}; - root.setStyleInputs(arr, 1); - assertEquals(root.getHeight(), YogaValue.AUTO); - } - - @Test - public void testStyleInputMinHeight() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MIN_HEIGHT, 50f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMinHeight(), new YogaValue(50f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputMinHeightPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MIN_HEIGHT_PERCENT, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMinHeight(), new YogaValue(5f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputMaxHeight() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MAX_HEIGHT, 50f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMaxHeight(), new YogaValue(50f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputMaxHeightPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MAX_HEIGHT_PERCENT, 5f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMaxHeight(), new YogaValue(5f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputJustiyContent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.JUSTIFY_CONTENT, YogaJustify.CENTER.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getJustifyContent(), YogaJustify.CENTER); - } - - @Test - public void testStyleInputAlignItems() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.ALIGN_ITEMS, YogaAlign.BASELINE.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getAlignItems(), YogaAlign.BASELINE); - } - - @Test - public void testStyleInputAlignSelf() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.ALIGN_SELF, YogaAlign.BASELINE.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getAlignSelf(), YogaAlign.BASELINE); - } - - @Test - public void testStyleInputAlignContent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.ALIGN_CONTENT, YogaAlign.BASELINE.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getAlignContent(), YogaAlign.BASELINE); - } - - @Test - public void testStyleInputPositionType() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.POSITION_TYPE, YogaPositionType.ABSOLUTE.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getPositionType(), YogaPositionType.ABSOLUTE); - } - - @Test - public void testStyleInputAspectRatio() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.ASPECT_RATIO, 2f}; - root.setStyleInputs(arr, 2); - assertEquals(root.getAspectRatio(), 2f, 0.0f); - } - - @Test - public void testStyleInputOverflow() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.OVERFLOW, YogaOverflow.HIDDEN.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getOverflow(), YogaOverflow.HIDDEN); - } - - @Test - public void testStyleInputDisplay() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.DISPLAY, YogaDisplay.NONE.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getDisplay(), YogaDisplay.NONE); - } - - @Test - public void testStyleInputMargin() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MARGIN, YogaEdge.LEFT.intValue(), 12f}; - root.setStyleInputs(arr, 3); - assertEquals(root.getMargin(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputMarginPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MARGIN_PERCENT, YogaEdge.LEFT.intValue(), 12f}; - root.setStyleInputs(arr, 3); - assertEquals(root.getMargin(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputMarginAuto() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.MARGIN_AUTO, YogaEdge.LEFT.intValue()}; - root.setStyleInputs(arr, 2); - assertEquals(root.getMargin(YogaEdge.LEFT), YogaValue.AUTO); - } - - @Test - public void testStyleInputPadding() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.PADDING, YogaEdge.LEFT.intValue(), 12f}; - root.setStyleInputs(arr, 3); - assertEquals(root.getPadding(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputPaddingPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.PADDING_PERCENT, YogaEdge.LEFT.intValue(), 12f}; - root.setStyleInputs(arr, 3); - assertEquals(root.getPadding(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputBorder() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.BORDER, YogaEdge.LEFT.intValue(), 12f}; - root.setStyleInputs(arr, 3); - assertEquals(root.getBorder(YogaEdge.LEFT), 12f, 0.0f); - } - - @Test - public void testStyleInputPosition() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.POSITION, YogaEdge.LEFT.intValue(), 12f}; - root.setStyleInputs(arr, 3); - assertEquals(root.getPosition(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.POINT)); - } - - @Test - public void testStyleInputPositionPercent() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.POSITION_PERCENT, YogaEdge.LEFT.intValue(), 12f}; - root.setStyleInputs(arr, 3); - assertEquals(root.getPosition(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.PERCENT)); - } - - @Test - public void testStyleInputIsReferenceBaseline() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - float[] arr = new float[]{YogaStyleInputs.IS_REFERENCE_BASELINE, 1f}; - root.setStyleInputs(arr, 2); - assertEquals(root.isReferenceBaseline(), true); - } - - @Test - public void testStyleInputs() { - YogaConfig config = YogaConfigFactory.create(); - final YogaNode root = createNode(config); - int count = 0; - float[] arr = new float[100]; - arr[count++] = YogaStyleInputs.FLEX_DIRECTION; - arr[count++] = YogaFlexDirection.ROW.intValue(); - - arr[count++] = YogaStyleInputs.FLEX; - arr[count++] = 5f; - - arr[count++] = YogaStyleInputs.FLEX_GROW; - arr[count++] = 5f; - - arr[count++] = YogaStyleInputs.FLEX_SHRINK; - arr[count++] = 5f; - - arr[count++] = YogaStyleInputs.FLEX_BASIS_AUTO; - - arr[count++] = YogaStyleInputs.FLEX_WRAP; - arr[count++] = YogaWrap.WRAP.intValue(); - - arr[count++] = YogaStyleInputs.WIDTH; - arr[count++] = 50f; - - arr[count++] = YogaStyleInputs.MIN_WIDTH; - arr[count++] = 50f; - - arr[count++] = YogaStyleInputs.MAX_WIDTH; - arr[count++] = 50f; - - arr[count++] = YogaStyleInputs.HEIGHT; - arr[count++] = 5f; - - arr[count++] = YogaStyleInputs.MIN_HEIGHT; - arr[count++] = 50f; - - arr[count++] = YogaStyleInputs.MAX_HEIGHT; - arr[count++] = 50f; - - arr[count++] = YogaStyleInputs.JUSTIFY_CONTENT; - arr[count++] = YogaJustify.CENTER.intValue(); - - arr[count++] = YogaStyleInputs.ALIGN_ITEMS; - arr[count++] = YogaAlign.BASELINE.intValue(); - - arr[count++] = YogaStyleInputs.ALIGN_SELF; - arr[count++] = YogaAlign.BASELINE.intValue(); - - arr[count++] = YogaStyleInputs.ALIGN_CONTENT; - arr[count++] = YogaAlign.BASELINE.intValue(); - - arr[count++] = YogaStyleInputs.POSITION_TYPE; - arr[count++] = YogaPositionType.ABSOLUTE.intValue(); - - arr[count++] = YogaStyleInputs.ASPECT_RATIO; - arr[count++] = 2f; - - arr[count++] = YogaStyleInputs.OVERFLOW; - arr[count++] = YogaOverflow.HIDDEN.intValue(); - - arr[count++] = YogaStyleInputs.DISPLAY; - arr[count++] = YogaDisplay.NONE.intValue(); - - arr[count++] = YogaStyleInputs.MARGIN_AUTO; - arr[count++] = YogaEdge.LEFT.intValue(); - - arr[count++] = YogaStyleInputs.PADDING; - arr[count++] = YogaEdge.LEFT.intValue(); - arr[count++] = 12f; - - arr[count++] = YogaStyleInputs.BORDER; - arr[count++] = YogaEdge.LEFT.intValue(); - arr[count++] = 12f; - - arr[count++] = YogaStyleInputs.POSITION_PERCENT; - arr[count++] = YogaEdge.LEFT.intValue(); - arr[count++] = 12f; - - arr[count++] = YogaStyleInputs.IS_REFERENCE_BASELINE; - arr[count++] = 1f; - - root.setStyleInputs(arr, count); - - assertEquals(root.getFlexDirection(), YogaFlexDirection.ROW); - assertEquals(root.getFlex(), 5f, 0.0f); - assertEquals(root.getFlexGrow(), 5f, 0.0f); - assertEquals(root.getFlexShrink(), 5f, 0.0f); - assertEquals(root.getFlexBasis(), YogaValue.AUTO); - assertEquals(root.getWrap(), YogaWrap.WRAP); - assertEquals(root.getWidth(), new YogaValue(50f, YogaUnit.POINT)); - assertEquals(root.getMinWidth(), new YogaValue(50f, YogaUnit.POINT)); - assertEquals(root.getMaxWidth(), new YogaValue(50f, YogaUnit.POINT)); - assertEquals(root.getHeight(), new YogaValue(5f, YogaUnit.POINT)); - assertEquals(root.getMinHeight(), new YogaValue(50f, YogaUnit.POINT)); - assertEquals(root.getMaxHeight(), new YogaValue(50f, YogaUnit.POINT)); - assertEquals(root.getJustifyContent(), YogaJustify.CENTER); - assertEquals(root.getAlignItems(), YogaAlign.BASELINE); - assertEquals(root.getAlignSelf(), YogaAlign.BASELINE); - assertEquals(root.getAlignContent(), YogaAlign.BASELINE); - assertEquals(root.getPositionType(), YogaPositionType.ABSOLUTE); - assertEquals(root.getAspectRatio(), 2f, 0.0f); - assertEquals(root.getOverflow(), YogaOverflow.HIDDEN); - assertEquals(root.getDisplay(), YogaDisplay.NONE); - assertEquals(root.getMargin(YogaEdge.LEFT), YogaValue.AUTO); - assertEquals(root.getPadding(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.POINT)); - assertEquals(root.getBorder(YogaEdge.LEFT), 12f, 0.0f); - assertEquals(root.getPosition(YogaEdge.LEFT), new YogaValue(12f, YogaUnit.PERCENT)); - assertEquals(root.isReferenceBaseline(), true); - } - - private YogaNode createNode(YogaConfig config) { - return mNodeFactory.create(config); - } -}