[Test] public void dirtied_propagation() { YGNode root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNew(); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNew(); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); root.setContext(0); root.setDirtiedFunc(_dirtied); Assert.AreEqual(0, (int)root.getContext()); // `_dirtied` MUST be called for the first time. root_child0.markDirtyAndPropogate(); Assert.AreEqual(1, (int)root.getContext()); // `_dirtied` must NOT be called for the second time. root_child0.markDirtyAndPropogate(); Assert.AreEqual(1, (int)root.getContext()); }
public void dont_measure_when_min_equals_max() { YGNode root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNew(); root_child0.setContext(0); root_child0.setMeasureFunc(_measure); YGNodeStyleSetMinWidth(root_child0, 10); YGNodeStyleSetMaxWidth(root_child0, 10); YGNodeStyleSetMinHeight(root_child0, 10); YGNodeStyleSetMaxHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, (int)root_child0.getContext()); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); }
static void _dirtied(YGNode node) { int dirtiedCount = (int)node.getContext(); dirtiedCount++; node.setContext(dirtiedCount); }
[Test] public void remeasure_with_already_measured_value_smaller_but_still_float_equal() { YGNode root = YGNodeNew(); YGNodeStyleSetWidth(root, 288f); YGNodeStyleSetHeight(root, 288f); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNode root_child0 = YGNodeNew(); YGNodeStyleSetPadding(root_child0, YGEdge.All, 2.88f); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirection.Row); YGNodeInsertChild(root, root_child0, 0); YGNode root_child0_child0 = YGNodeNew(); root_child0_child0.setContext(0); root_child0_child0.setMeasureFunc(_measure_84_49); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(1, (int)root_child0_child0.getContext()); }
[Test] public void dirtied_hierarchy() { YGNode root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNew(); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 20); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNew(); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); root_child0.setContext(0); root_child0.setDirtiedFunc(_dirtied); Assert.AreEqual(0, (int)root_child0.getContext()); // `_dirtied` must NOT be called for descendants. root.markDirtyAndPropogate(); Assert.AreEqual(0, (int)root_child0.getContext()); // `_dirtied` must NOT be called for the sibling node. root_child1.markDirtyAndPropogate(); Assert.AreEqual(0, (int)root_child0.getContext()); // `_dirtied` MUST be called in case of explicit dirtying. root_child0.markDirtyAndPropogate(); Assert.AreEqual(1, (int)root_child0.getContext()); }
[Test] public void dirtied() { YGNode root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); //int dirtiedCount = 0; root.setContext(0); root.setDirtiedFunc(_dirtied); Assert.AreEqual(0, (int)root.getContext()); // `_dirtied` MUST be called in case of explicit dirtying. root.setDirty(true); Assert.AreEqual(1, (int)root.getContext()); // `_dirtied` MUST be called ONCE. root.setDirty(true); Assert.AreEqual(1, (int)root.getContext()); }
[Test] public void remeasure_with_same_exact_width_larger_than_needed_height() { YGNode root = YGNodeNew(); YGNode root_child0 = YGNodeNew(); root_child0.setContext(0); root_child0.setMeasureFunc(_measureMin); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, 100, 100, YGDirection.LTR); YGNodeCalculateLayout(root, 100, 50, YGDirection.LTR); Assert.AreEqual(1, (int)root_child0.getContext()); }
[Test] public void remeasure_with_atmost_computed_width_undefined_height() { YGNode root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNode root_child0 = YGNodeNew(); root_child0.setContext(0); root_child0.setMeasureFunc(_measureMin); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, 100, YGValue.YGUndefined, YGDirection.LTR); YGNodeCalculateLayout(root, 10, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(1, (int)root_child0.getContext()); }
[Test] public void remeasure_with_computed_width_larger_than_needed_height() { YGNode root = YGNodeNew(); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNode root_child0 = YGNodeNew(); root_child0.setContext(0); root_child0.setMeasureFunc(_measureMin); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, 100, 100, YGDirection.LTR); YGNodeStyleSetAlignItems(root, YGAlign.Stretch); YGNodeCalculateLayout(root, 10, 50, YGDirection.LTR); Assert.AreEqual(1, (int)root_child0.getContext()); }
public void measure_absolute_child_with_no_constraints() { YGNode root = YGNodeNew(); YGNode root_child0 = YGNodeNew(); YGNodeInsertChild(root, root_child0, 0); YGNode root_child0_child0 = YGNodeNew(); YGNodeStyleSetPositionType(root_child0_child0, YGPositionType.Absolute); root_child0_child0.setContext(0); root_child0_child0.setMeasureFunc(_measure); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(1, (int)root_child0_child0.getContext()); }
public void dont_measure_single_grow_shrink_child() { YGNode root = YGNodeNew(); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNew(); root_child0.setContext(0); root_child0.setMeasureFunc(_measure); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, (int)root_child0.getContext()); }
[Test] public void measure_once_single_flexible_child() { YGNode root = YGNodeNew(); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNew(); root_child0.setContext(0); root_child0.setMeasureFunc(_measureMax); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(1, (int)root_child0.getContext()); }