Extract abstract class YogaNode

Summary:
@public

Here, we extract an abstract class from `YogaNode`, in order to allow for experimentation with different implementations.

The reason for not choosing an interface is to keep ABI compatibility for `YogaNode.create()`.

Reviewed By: pasqualeanatriello

Differential Revision: D14044990

fbshipit-source-id: f8eb246338b55f34f0401198c0655abfcb7c9f37
This commit is contained in:
David Aurelio
2019-02-19 11:15:11 -08:00
committed by Facebook Github Bot
parent 016a10df26
commit 2643b96589
5 changed files with 996 additions and 787 deletions

View File

@@ -30,9 +30,9 @@ public class YogaNodeTest {
@Test
public void testInit() {
final int refCount = YogaNode.jni_YGNodeGetInstanceCount();
final int refCount = YogaNodeJNI.jni_YGNodeGetInstanceCount();
final YogaNode node = createNode();
assertEquals(refCount + 1, YogaNode.jni_YGNodeGetInstanceCount());
assertEquals(refCount + 1, YogaNodeJNI.jni_YGNodeGetInstanceCount());
}
@Test
@@ -243,7 +243,7 @@ public class YogaNodeTest {
child.addChildAt(grandChild, 0);
child.setFlexDirection(YogaFlexDirection.ROW);
YogaNode clonedChild = child.clone();
YogaNode clonedChild = ((YogaNodeJNI) child).clone();
assertNotSame(clonedChild, child);
@@ -270,7 +270,7 @@ public class YogaNodeTest {
child.addChildAt(grandChild, 0);
child.setFlexDirection(YogaFlexDirection.ROW);
YogaNode clonedChild = child.cloneWithNewChildren();
YogaNode clonedChild = ((YogaNodeJNI) child).cloneWithNewChildren();
assertNotSame(clonedChild, child);
assertEquals(YogaFlexDirection.ROW, clonedChild.getFlexDirection());
@@ -288,7 +288,7 @@ public class YogaNodeTest {
@Override
public YogaNode cloneNode(YogaNode oldNode, YogaNode owner, int childIndex) {
onNodeClonedExecuted.set(true);
return oldNode.clone();
return ((YogaNodeJNI) oldNode).clone();
}
});
YogaNode root = createNode(config);
@@ -300,7 +300,7 @@ public class YogaNodeTest {
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
// Force a clone to happen.
final YogaNode root2 = root.clone();
final YogaNode root2 = ((YogaNodeJNI) root).clone();
root2.setWidth(200f);
root2.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
@@ -319,7 +319,7 @@ public class YogaNodeTest {
new YogaNodeCloneFunction() {
@Override
public YogaNode cloneNode(YogaNode oldNode, YogaNode owner, int childIndex) {
return oldNode.clone();
return ((YogaNodeJNI) oldNode).clone();
}
});
config.setOnCloneNode(null);
@@ -359,7 +359,7 @@ public class YogaNodeTest {
root_child0_child0_child0.setFlexShrink(1);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertFalse(root.getDoesLegacyStretchFlagAffectsLayout());
assertFalse(((YogaNodeJNI) root).getDoesLegacyStretchFlagAffectsLayout());
}
@Test