[Test] public void cloning_and_freeing() { //int initialInstanceCount = YGNodeGetInstanceCount(); YGConfig config = YGConfigNew(); YGConfigSetPrintTreeFlag(config, true); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); YGNode root2 = YGNodeClone(root); // Freeing the original root should be safe as long as we don't free its // children. YGNodeCalculateLayout(root2, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); //Assert.AreEqual(initialInstanceCount, YGNodeGetInstanceCount()); }
[Test] public void display_none_with_margin() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root_child0, YGEdge.Left, 10); YGNodeStyleSetMargin(root_child0, YGEdge.Top, 10); YGNodeStyleSetMargin(root_child0, YGEdge.Right, 10); YGNodeStyleSetMargin(root_child0, YGEdge.Bottom, 10); YGNodeStyleSetWidth(root_child0, 20); YGNodeStyleSetHeight(root_child0, 20); YGNodeStyleSetDisplay(root_child0, YGDisplay.None); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child1)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child1)); }
int _unmanagedLogger(YGConfig config, YGNode node, YGLogLevel level, object context, string message) { writeBuffer.Append(message); return(writeBuffer.Length); }
[Test] public void flex_basis_flex_shrink_row() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetFlexBasis(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasis(root_child1, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child1)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child1)); }
public void nested_overflowing_child_in_constraint_parent() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 100); YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); YGNode root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0_child0, 200); YGNodeStyleSetHeight(root_child0_child0, 200); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0_child0)); Assert.AreEqual(200, YGNodeLayoutGetWidth(root_child0_child0)); Assert.AreEqual(200, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(-100, YGNodeLayoutGetLeft(root_child0_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0_child0)); Assert.AreEqual(200, YGNodeLayoutGetWidth(root_child0_child0)); Assert.AreEqual(200, YGNodeLayoutGetHeight(root_child0_child0)); }
[Test] public void flex_grow_shrink_at_most() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child0, 0); YGNode root_child0_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetFlexShrink(root_child0_child0, 1); YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0_child0)); }
public void logger_default_node_should_print_no_style_info() { YGConfig config = YGConfigNew(); YGConfigSetLogger(config, _unmanagedLogger); YGNode root = YGNodeNewWithConfig(config); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); YGNodePrint(root, (YGPrintOptions.Layout | YGPrintOptions.Children | YGPrintOptions.Style)); YGConfigSetLogger(config, null); string expected = "<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" ></div>"; Assert.AreEqual(expected, writeBuffer.ToString()); }
[Test] public void rounding_feature_with_custom_measure_func_ceil() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNode root_child0 = YGNodeNewWithConfig(config); root_child0.setMeasureFunc(_measureCeil); YGNodeInsertChild(root, root_child0, 0); YGConfigSetPointScaleFactor(config, 1.0f); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(11, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(11, YGNodeLayoutGetHeight(root_child0)); }
public void cant_call_negative_measure_horizontal() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetWidth(root, 10); YGNodeStyleSetHeight(root, 20); YGNode root_child0 = YGNodeNewWithConfig(config); root_child0.setMeasureFunc(_measure_assert_negative); YGNodeStyleSetMargin(root_child0, YGEdge.Start, 20); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); }
[Test] public void child_with_padding_align_end() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustify.FlexEnd); YGNodeStyleSetAlignItems(root, YGAlign.FlexEnd); YGNodeStyleSetWidth(root, 200); YGNodeStyleSetHeight(root, 200); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root_child0, YGEdge.Left, 20); YGNodeStyleSetPadding(root_child0, YGEdge.Top, 20); YGNodeStyleSetPadding(root_child0, YGEdge.Right, 20); YGNodeStyleSetPadding(root_child0, YGEdge.Bottom, 20); YGNodeStyleSetWidth(root_child0, 100); YGNodeStyleSetHeight(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(200, YGNodeLayoutGetWidth(root)); Assert.AreEqual(200, YGNodeLayoutGetHeight(root)); Assert.AreEqual(100, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(200, YGNodeLayoutGetWidth(root)); Assert.AreEqual(200, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); }
public void align_baseline_parent_ht_not_specified() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetAlignContent(root, YGAlign.Stretch); YGNodeStyleSetAlignItems(root, YGAlign.Baseline); YGNodeStyleSetWidth(root, 340); YGNodeStyleSetMaxHeight(root, 170); YGNodeStyleSetMinHeight(root, 0); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 0); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeSetMeasureFunc(root_child0, _measure1); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 0); YGNodeStyleSetFlexShrink(root_child1, 1); YGNodeSetMeasureFunc(root_child1, _measure2); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(340, YGNodeLayoutGetWidth(root)); Assert.AreEqual(126, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(42, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(76, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(42, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(279, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(126, YGNodeLayoutGetHeight(root_child1)); }
[Test] public void mutating_children_of_a_clone_clones() { YGConfig config = YGConfigNew(); YGConfigSetPrintTreeFlag(config, true); YGNode root = YGNodeNewWithConfig(config); Assert.AreEqual(0, YGNodeGetChildCount(root)); YGNode root2 = YGNodeClone(root); Assert.AreEqual(0, YGNodeGetChildCount(root2)); YGNode root2_child0 = YGNodeNewWithConfig(config); YGNodeInsertChild(root2, root2_child0, 0); Assert.AreEqual(0, YGNodeGetChildCount(root)); Assert.AreEqual(1, YGNodeGetChildCount(root2)); YGNode root3 = YGNodeClone(root2); Assert.AreEqual(1, YGNodeGetChildCount(root2)); Assert.AreEqual(1, YGNodeGetChildCount(root3)); Assert.AreEqual(root2.Children[0], root3.Children[0]); YGNode root3_child1 = YGNodeNewWithConfig(config); YGNodeInsertChild(root3, root3_child1, 1); Assert.AreEqual(1, YGNodeGetChildCount(root2)); Assert.AreEqual(2, YGNodeGetChildCount(root3)); Assert.AreEqual(root3_child1, root3.Children[1]); Assert.IsFalse(ReferenceEquals(root2.Children[0], root3.Children[1])); YGNode root4 = YGNodeClone(root3); Assert.AreEqual(root3_child1, root4.Children[1]); YGNodeRemoveChild(root4, root3_child1); Assert.AreEqual(2, YGNodeGetChildCount(root3)); Assert.AreEqual(1, YGNodeGetChildCount(root4)); Assert.IsFalse(ReferenceEquals(root3.Children[0], root4.Children[0])); }
[Test] public void rounding_feature_with_custom_measure_and_fractial_matching_scale() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPosition(root_child0, YGEdge.Left, 73.625f); root_child0.setMeasureFunc(_measureFractial); YGNodeInsertChild(root, root_child0, 0); YGConfigSetPointScaleFactor(config, 2.0f); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0.5, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(0.5, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(73.5, YGNodeLayoutGetLeft(root_child0)); }
[Test] public void border_center_child() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetJustifyContent(root, YGJustify.Center); YGNodeStyleSetAlignItems(root, YGAlign.Center); YGNodeStyleSetBorder(root, YGEdge.Start, 10); YGNodeStyleSetBorder(root, YGEdge.End, 20); YGNodeStyleSetBorder(root, YGEdge.Bottom, 20); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(40, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(35, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(35, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); }
[Test] public void border_flex_child() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetBorder(root, YGEdge.Left, 10); YGNodeStyleSetBorder(root, YGEdge.Top, 10); YGNodeStyleSetBorder(root, YGEdge.Right, 10); YGNodeStyleSetBorder(root, YGEdge.Bottom, 10); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetWidth(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(10, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(80, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(80, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(80, YGNodeLayoutGetHeight(root_child0)); }
public void measure_flex_direction_row_and_padding() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetPadding(root, YGEdge.Left, 25); YGNodeStyleSetPadding(root, YGEdge.Top, 25); YGNodeStyleSetPadding(root, YGEdge.Right, 25); YGNodeStyleSetPadding(root, YGEdge.Bottom, 25); YGNodeStyleSetWidth(root, 50); YGNodeStyleSetHeight(root, 50); YGNode root_child0 = YGNodeNewWithConfig(config); root_child0.setMeasureFunc(_simulate_wrapping_text); // YGNodeSetMeasureFunc(root_child0, _simulate_wrapping_text); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 5); YGNodeStyleSetHeight(root_child1, 5); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root)); Assert.AreEqual(50, YGNodeLayoutGetHeight(root)); Assert.AreEqual(25, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(25, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(75, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(25, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(5, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(5, YGNodeLayoutGetHeight(root_child1)); }
public void config_print_tree_disabled() { YGConfig config = YGConfigNew(); YGConfigSetPrintTreeFlag(config, false); YGConfigSetLogger(config, _unmanagedLogger); YGNode root = YGNodeNewWithConfig(config); YGNode child0 = YGNodeNewWithConfig(config); YGNode child1 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, child0, 0); YGNodeInsertChild(root, child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); YGConfigSetLogger(config, null); string expected = ""; Assert.AreEqual(expected, writeBuffer.ToString()); }
[Test] public void dont_cache_computed_flex_basis_between_layouts() { YGConfig config = YGConfigNew(); YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeature.WebFlexBasis, true); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetHeightPercent(root, 100); YGNodeStyleSetWidthPercent(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexBasisPercent(root_child0, 100); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, 100, YGValue.YGUndefined, YGDirection.LTR); YGNodeCalculateLayout(root, 100, 100, YGDirection.LTR); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); }
public void config_print_tree_enabled() { YGConfig config = YGConfigNew(); YGConfigSetPrintTreeFlag(config, true); YGConfigSetLogger(config, _unmanagedLogger); YGNode root = YGNodeNewWithConfig(config); YGNode child0 = YGNodeNewWithConfig(config); YGNode child1 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, child0, 0); YGNodeInsertChild(root, child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); YGConfigSetLogger(config, null); string expected = "<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" >\n <div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" ></div>\n <div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"\" ></div>\n</div>"; Assert.AreEqual(expected, writeBuffer.ToString()); }
// This test isn't correct from the Flexbox standard standpoint, // because percentages are calculated with parent constraints. // However, we need to make sure we fail gracefully in this case, not returning NaN [Test] public void percent_absolute_position_infinite_height() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetWidth(root, 300); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 300); YGNodeStyleSetHeight(root_child0, 300); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root_child1, YGPositionType.Absolute); YGNodeStyleSetPositionPercent(root_child1, YGEdge.Left, 20); YGNodeStyleSetPositionPercent(root_child1, YGEdge.Top, 20); YGNodeStyleSetWidthPercent(root_child1, 20); YGNodeStyleSetHeightPercent(root_child1, 20); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(300, YGNodeLayoutGetWidth(root)); Assert.AreEqual(300, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(300, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(300, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(60, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(60, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child1)); }
public void percent_with_text_node() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetJustifyContent(root, YGJustify.SpaceBetween); YGNodeStyleSetAlignItems(root, YGAlign.Center); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 80); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); root_child1.setMeasureFunc(_measure_90_10); YGNodeStyleSetMaxWidthPercent(root_child1, 50); YGNodeStyleSetPaddingPercent(root_child1, YGEdge.Top, 50); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(80, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(40, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(15, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(50, YGNodeLayoutGetHeight(root_child1)); }
public void measure_with_fixed_size() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetMargin(root, YGEdge.Top, 20); YGNodeStyleSetPadding(root, YGEdge.All, 25); YGNodeStyleSetWidth(root, 50); YGNodeStyleSetHeight(root, 50); YGNode root_child0 = YGNodeNewWithConfig(config); root_child0.setMeasureFunc(_simulate_wrapping_text); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 5); YGNodeStyleSetHeight(root_child1, 5); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(20, YGNodeLayoutGetTop(root)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root)); Assert.AreEqual(50, YGNodeLayoutGetHeight(root)); Assert.AreEqual(25, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(25, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(25, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(35, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(5, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(5, YGNodeLayoutGetHeight(root_child1)); }
public void align_baseline_with_no_parent_ht() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetAlignItems(root, YGAlign.Baseline); YGNodeStyleSetWidth(root, 150); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 50); YGNodeStyleSetHeight(root_child0, 50); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 50); YGNodeStyleSetHeight(root_child1, 40); YGNodeSetBaselineFunc(root_child1, _baselineFunc); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(150, YGNodeLayoutGetWidth(root)); Assert.AreEqual(70, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(30, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(40, YGNodeLayoutGetHeight(root_child1)); }
[Test] public void align_self_flex_end_override_flex_start() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlign.FlexEnd); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(90, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); }
[Test] public void padding_container_match_child() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetPadding(root, YGEdge.Left, 10); YGNodeStyleSetPadding(root, YGEdge.Top, 10); YGNodeStyleSetPadding(root, YGEdge.Right, 10); YGNodeStyleSetPadding(root, YGEdge.Bottom, 10); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(30, YGNodeLayoutGetWidth(root)); Assert.AreEqual(30, YGNodeLayoutGetHeight(root)); Assert.AreEqual(10, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(30, YGNodeLayoutGetWidth(root)); Assert.AreEqual(30, YGNodeLayoutGetHeight(root)); Assert.AreEqual(10, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); }
[Test] public void align_self_center() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetAlignSelf(root_child0, YGAlign.Center); YGNodeStyleSetWidth(root_child0, 10); YGNodeStyleSetHeight(root_child0, 10); YGNodeInsertChild(root, root_child0, 0); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(45, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(45, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(10, YGNodeLayoutGetHeight(root_child0)); }
public void measure_flex_direction_row_no_padding_align_items_flexstart() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetMargin(root, YGEdge.Top, 20); YGNodeStyleSetWidth(root, 50); YGNodeStyleSetHeight(root, 50); YGNodeStyleSetAlignItems(root, YGAlign.FlexStart); YGNode root_child0 = YGNodeNewWithConfig(config); root_child0.setMeasureFunc(_simulate_wrapping_text); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root_child1, 5); YGNodeStyleSetHeight(root_child1, 5); YGNodeInsertChild(root, root_child1, 1); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(20, YGNodeLayoutGetTop(root)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root)); Assert.AreEqual(50, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(32, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(5, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(5, YGNodeLayoutGetHeight(root_child1)); }
public void logger_node_with_percentage_absolute_position_and_margin() { YGConfig config = YGConfigNew(); YGConfigSetLogger(config, _unmanagedLogger); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetPositionType(root, YGPositionType.Absolute); YGNodeStyleSetWidthPercent(root, 50); YGNodeStyleSetHeightPercent(root, 75); YGNodeStyleSetFlex(root, 1); YGNodeStyleSetMargin(root, YGEdge.Right, 10); YGNodeStyleSetMarginAuto(root, YGEdge.Left); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); YGNodePrint(root, (YGPrintOptions.Layout | YGPrintOptions.Children | YGPrintOptions.Style)); YGConfigSetLogger(config, null); string expected = "<div layout=\"width: 0; height: 0; top: 0; left: 0;\" style=\"flex: 1; margin-left: auto; margin-right: 10px; width: 50%; height: 75%; position: absolute; \" ></div>"; Assert.AreEqual(expected, writeBuffer.ToString()); }
[Test] public void border_no_size() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetBorder(root, YGEdge.Left, 10); YGNodeStyleSetBorder(root, YGEdge.Top, 10); YGNodeStyleSetBorder(root, YGEdge.Right, 10); YGNodeStyleSetBorder(root, YGEdge.Bottom, 10); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(20, YGNodeLayoutGetWidth(root)); Assert.AreEqual(20, YGNodeLayoutGetHeight(root)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(20, YGNodeLayoutGetWidth(root)); Assert.AreEqual(20, YGNodeLayoutGetHeight(root)); }
[Test] public void display_none_with_child() { YGConfig config = YGConfigNew(); YGNode root = YGNodeNewWithConfig(config); YGNodeStyleSetFlexDirection(root, YGFlexDirection.Row); YGNodeStyleSetWidth(root, 100); YGNodeStyleSetHeight(root, 100); YGNode root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexShrink(root_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child0, 0); YGNodeInsertChild(root, root_child0, 0); YGNode root_child1 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1, 1); YGNodeStyleSetFlexShrink(root_child1, 1); YGNodeStyleSetFlexBasisPercent(root_child1, 0); YGNodeStyleSetDisplay(root_child1, YGDisplay.None); YGNodeInsertChild(root, root_child1, 1); YGNode root_child1_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child1_child0, 1); YGNodeStyleSetFlexShrink(root_child1_child0, 1); YGNodeStyleSetFlexBasisPercent(root_child1_child0, 0); YGNodeStyleSetWidth(root_child1_child0, 20); YGNodeStyleSetMinWidth(root_child1_child0, 0); YGNodeStyleSetMinHeight(root_child1_child0, 0); YGNodeInsertChild(root_child1, root_child1_child0, 0); YGNode root_child2 = YGNodeNewWithConfig(config); YGNodeStyleSetFlexGrow(root_child2, 1); YGNodeStyleSetFlexShrink(root_child2, 1); YGNodeStyleSetFlexBasisPercent(root_child2, 0); YGNodeInsertChild(root, root_child2, 2); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.LTR); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child1_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1_child0)); Assert.AreEqual(0, YGNodeLayoutGetWidth(root_child1_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child1_child0)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child2)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child2)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child2)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child2)); YGNodeCalculateLayout(root, YGValue.YGUndefined, YGValue.YGUndefined, YGDirection.RTL); Assert.AreEqual(0, YGNodeLayoutGetLeft(root)); Assert.AreEqual(0, YGNodeLayoutGetTop(root)); Assert.AreEqual(100, YGNodeLayoutGetWidth(root)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root)); Assert.AreEqual(50, YGNodeLayoutGetLeft(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child0)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child0)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetWidth(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child1)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child1_child0)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child1_child0)); Assert.AreEqual(0, YGNodeLayoutGetWidth(root_child1_child0)); Assert.AreEqual(0, YGNodeLayoutGetHeight(root_child1_child0)); Assert.AreEqual(0, YGNodeLayoutGetLeft(root_child2)); Assert.AreEqual(0, YGNodeLayoutGetTop(root_child2)); Assert.AreEqual(50, YGNodeLayoutGetWidth(root_child2)); Assert.AreEqual(100, YGNodeLayoutGetHeight(root_child2)); }