Expose layout diffing flag to java

Summary:
This diff exposes `shouldDiffLayoutWithoutLegacyStretchBehaviour` from YGConfig and `doesLegacyStretchFlagAffectsLayout` from YGLayout to YogaConfig and YogaNode respectively

Also added a positive test case. Didn't find the negative test case example. @[508947467:ianc] or @[759512522:emilsj], can you suggest a negative test case example.

Reviewed By: emilsjolander

Differential Revision: D7272067

fbshipit-source-id: e67e82eb057e4c7124904c715f9dca4dcfea21ea
This commit is contained in:
Pritesh Nandgaonkar
2018-03-14 08:37:55 -07:00
committed by Facebook Github Bot
parent d567885070
commit 3dfb68887d
6 changed files with 93 additions and 16 deletions

View File

@@ -8,6 +8,7 @@
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -302,4 +303,27 @@ public class YogaNodeTest {
}
fail("YogaConfig leaked");
}
@Test
public void testFlagShouldDiffLayoutWithoutLegacyStretchBehaviour() throws Exception {
YogaConfig config = new YogaConfig();
config.setShouldDiffLayoutWithoutLegacyStretchBehaviour(true);
config.setUseLegacyStretchBehaviour(true);
YogaNode root = new YogaNode(config);
root.setWidth(500);
root.setHeight(500);
YogaNode root_child0 = new YogaNode(config);
root_child0.setAlignItems(YogaAlign.FLEX_START);
root.addChildAt(root_child0, 0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1);
root_child0_child0.setFlexShrink(1);
root_child0.addChildAt(root_child0_child0, 0);
YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.setFlexGrow(1);
root_child0_child0_child0.setFlexShrink(1);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertFalse(root.getDoesLegacyStretchFlagAffectsLayout());
}
}