Add tests for YogaNode#hasNewLayout() / #markLayoutSeen()

Summary:
@public

Adds test for the `hasNewLayout()` and `markLayoutSeen()` methods of `YogaNode`. The behavior of these methods wasn't previously covered by a test. This will allow us to change the implementation with confidence.

Reviewed By: SidharthGuglani

Differential Revision: D13534351

fbshipit-source-id: 23a9f9b70df18fd7c34023fd77b9df9fbd733f61
This commit is contained in:
David Aurelio
2018-12-21 03:12:17 -08:00
committed by Facebook Github Bot
parent 56e133ab4c
commit 5514722ce2

View File

@@ -386,6 +386,52 @@ public class YogaNodeTest {
assertFalse(root.getDoesLegacyStretchFlagAffectsLayout());
}
@Test
public void initiallyHasNewLayout() {
YogaNode root = createNode();
assertTrue(root.hasNewLayout());
}
@Test
public void initialLayoutCanBeMarkedSeen() {
YogaNode root = createNode();
root.markLayoutSeen();
assertFalse(root.hasNewLayout());
}
@Test
public void calculatingLayoutMarksLayoutAsUnseen() {
YogaNode root = createNode();
root.markLayoutSeen();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertTrue(root.hasNewLayout());
}
@Test
public void calculatedLayoutCanBeMarkedSeen() {
YogaNode root = createNode();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
root.markLayoutSeen();
assertFalse(root.hasNewLayout());
}
@Test
public void recalculatingLayoutDoesMarkAsUnseen() {
YogaNode root = createNode();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
root.markLayoutSeen();
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertTrue(root.hasNewLayout());
}
@Test
public void resetAlsoResetsLayoutSeen() {
YogaNode root = createNode();
root.markLayoutSeen();
root.reset();
assertTrue(root.hasNewLayout());
}
private YogaNode createNode() {
return mNodeFactory.create();
}