Ejemplo n.º 1
0
        public void percentage_position_left_top()
        {
            YogaNode rootChild0;
            YogaNode root = Node(flexDirection: FlexDirection.Row, width: 400, height: 400)
                            .Add(rootChild0 = Node(left: 10.Percent(), top: 20.Percent(), width: 45.Percent(), height: 55.Percent()));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(400, root.Layout.Width);
            Assert.AreEqual(400, root.Layout.Height);

            Assert.AreEqual(40, rootChild0.Layout.Left);
            Assert.AreEqual(80, rootChild0.Layout.Top);
            Assert.AreEqual(180, rootChild0.Layout.Width);
            Assert.AreEqual(220, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(400, root.Layout.Width);
            Assert.AreEqual(400, root.Layout.Height);

            Assert.AreEqual(260, rootChild0.Layout.Left);
            Assert.AreEqual(80, rootChild0.Layout.Top);
            Assert.AreEqual(180, rootChild0.Layout.Width);
            Assert.AreEqual(220, rootChild0.Layout.Height);
        }
Ejemplo n.º 2
0
        public void absolute_layout_width_height_start_top()
        {
            YogaNode rootChild0;
            YogaNode root = Node(width: 100, height: 100)
                            .Add(rootChild0 = Node(positionType: PositionType.Absolute, start: 10, top: 10, width: 10, height: 10));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(10, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(80, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 3
0
        public void align_baseline_parent_ht_not_specified()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(config, flexDirection: FlexDirection.Row, alignContent: YogaAlign.Stretch, alignItems: YogaAlign.Baseline, width: 340, maxHeight: 170, minHeight: 0)
                            .Add(rootChild0 = Node(flexGrow: 0, flexShrink: 1, measureFunc: _measure1))
                            .Add(rootChild1 = Node(flexGrow: 0, flexShrink: 1, measureFunc: _measure2));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(340, root.Layout.Width);
            Assert.AreEqual(126, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(42, rootChild0.Layout.Width);
            Assert.AreEqual(50, rootChild0.Layout.Height);
            Assert.AreEqual(76, rootChild0.Layout.Top);

            Assert.AreEqual(42, rootChild1.Layout.Left);
            Assert.AreEqual(0, rootChild1.Layout.Top);
            Assert.AreEqual(279, rootChild1.Layout.Width);
            Assert.AreEqual(126, rootChild1.Layout.Height);
        }
Ejemplo n.º 4
0
        public void min_max_percent_no_width_height()
        {
            YogaNode rootChild0;
            YogaNode root = Node(alignItems: YogaAlign.FlexStart, width: 100, height: 100)
                            .Add(rootChild0 = Node(minWidth: 10.Percent(), maxWidth: 10.Percent(), minHeight: 10.Percent(), maxHeight: 10.Percent()));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(90, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 5
0
        public void absolute_layout_align_items_and_justify_content_center_and_right_position()
        {
            YogaNode rootChild0;
            YogaNode root = Node(justifyContent: Justify.Center, alignItems: YogaAlign.Center, flexGrow: 1, width: 110, height: 100)
                            .Add(rootChild0 = Node(positionType: PositionType.Absolute, right: 5, width: 60, height: 40));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(110, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(45, rootChild0.Layout.Left);
            Assert.AreEqual(30, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(40, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(110, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(45, rootChild0.Layout.Left);
            Assert.AreEqual(30, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(40, rootChild0.Layout.Height);
        }
Ejemplo n.º 6
0
        public void justify_content_min_max()
        {
            YogaNode rootChild0;
            YogaNode root = Node(justifyContent: Justify.Center, width: 100, minHeight: 100, maxHeight: 200)
                            .Add(rootChild0 = Node(width: 60, height: 60));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(20, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(60, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(40, rootChild0.Layout.Left);
            Assert.AreEqual(20, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(60, rootChild0.Layout.Height);
        }
Ejemplo n.º 7
0
        public void flex_grow_child()
        {
            YogaNode rootChild0;
            YogaNode root = Node(flexDirection: FlexDirection.Row)
                            .Add(rootChild0 = Node(flexGrow: 1, flexBasis: 0, height: 100));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(0, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(0, rootChild0.Layout.Width);
            Assert.AreEqual(100, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(0, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(0, rootChild0.Layout.Width);
            Assert.AreEqual(100, rootChild0.Layout.Height);
        }
Ejemplo n.º 8
0
        public void measure_no_padding()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(margin: new Edges(top: 20), width: 50, height: 50)
                            .Add(rootChild0 = Node(config, measureFunc: _simulateWrappingText, flexShrink: 1))
                            .Add(rootChild1 = Node(config, width: 5, height: 5));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(20, root.Layout.Top);
            Assert.AreEqual(50, root.Layout.Width);
            Assert.AreEqual(50, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(50, rootChild0.Layout.Width);
            Assert.AreEqual(32, rootChild0.Layout.Height);

            Assert.AreEqual(0, rootChild1.Layout.Left);
            Assert.AreEqual(32, rootChild1.Layout.Top);
            Assert.AreEqual(5, rootChild1.Layout.Width);
            Assert.AreEqual(5, rootChild1.Layout.Height);
        }
Ejemplo n.º 9
0
        public void percent_with_text_node()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(flexDirection: FlexDirection.Row, justifyContent: Justify.SpaceBetween, alignItems: YogaAlign.Center, width: 100, height: 80)
                            .Add(rootChild0 = Node(config))
                            .Add(rootChild1 = Node(config, measureFunc: _measure9010, maxWidth: 50.Percent(), padding: new Edges(top: 50.Percent())));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(80, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(40, rootChild0.Layout.Top);
            Assert.AreEqual(0, rootChild0.Layout.Width);
            Assert.AreEqual(0, rootChild0.Layout.Height);

            Assert.AreEqual(50, rootChild1.Layout.Left);
            Assert.AreEqual(15, rootChild1.Layout.Top);
            Assert.AreEqual(50, rootChild1.Layout.Width);
            Assert.AreEqual(50, rootChild1.Layout.Height);
        }
Ejemplo n.º 10
0
        public void measure_flex_direction_row_and_padding()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(config, flexDirection: FlexDirection.Row, padding: new Edges(25), width: 50, height: 50)
                            .Add(rootChild0 = Node(config, measureFunc: _simulateWrappingText))
                            .Add(rootChild1 = Node(config, width: 5, height: 5));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(50, root.Layout.Width);
            Assert.AreEqual(50, root.Layout.Height);

            Assert.AreEqual(25, rootChild0.Layout.Left);
            Assert.AreEqual(25, rootChild0.Layout.Top);
            Assert.AreEqual(50, rootChild0.Layout.Width);
            Assert.AreEqual(0, rootChild0.Layout.Height);

            Assert.AreEqual(75, rootChild1.Layout.Left);
            Assert.AreEqual(25, rootChild1.Layout.Top);
            Assert.AreEqual(5, rootChild1.Layout.Width);
            Assert.AreEqual(5, rootChild1.Layout.Height);
        }
Ejemplo n.º 11
0
        public void measure_flex_direction_row_no_padding_align_items_flexstart()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(config, flexDirection: FlexDirection.Row, margin: new Edges(top: 20), width: 50, height: 50, alignItems: YogaAlign.FlexStart)
                            .Add(rootChild0 = Node(config, measureFunc: _simulateWrappingText))
                            .Add(rootChild1 = Node(config, width: 5, height: 5));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(20, root.Layout.Top);
            Assert.AreEqual(50, root.Layout.Width);
            Assert.AreEqual(50, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(50, rootChild0.Layout.Width);
            Assert.AreEqual(32, rootChild0.Layout.Height);

            Assert.AreEqual(50, rootChild1.Layout.Left);
            Assert.AreEqual(0, rootChild1.Layout.Top);
            Assert.AreEqual(5, rootChild1.Layout.Width);
            Assert.AreEqual(5, rootChild1.Layout.Height);
        }
Ejemplo n.º 12
0
        public void percentage_position_bottom_right()
        {
            YogaNode rootChild0;
            YogaNode root = Node(flexDirection: FlexDirection.Row, width: 500, height: 500)
                            .Add(rootChild0 = Node(right: 20.Percent(), bottom: 10.Percent(), width: 55.Percent(), height: 15.Percent()));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(500, root.Layout.Width);
            Assert.AreEqual(500, root.Layout.Height);

            Assert.AreEqual(-100, rootChild0.Layout.Left);
            Assert.AreEqual(-50, rootChild0.Layout.Top);
            Assert.AreEqual(275, rootChild0.Layout.Width);
            Assert.AreEqual(75, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(500, root.Layout.Width);
            Assert.AreEqual(500, root.Layout.Height);

            Assert.AreEqual(125, rootChild0.Layout.Left);
            Assert.AreEqual(-50, rootChild0.Layout.Top);
            Assert.AreEqual(275, rootChild0.Layout.Width);
            Assert.AreEqual(75, rootChild0.Layout.Height);
        }
Ejemplo n.º 13
0
        public void percentage_width_height_undefined_parent_size()
        {
            YogaNode rootChild0;
            YogaNode root = Node()
                            .Add(rootChild0 = Node(width: 50.Percent(), height: 50.Percent()));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(0, root.Layout.Width);
            Assert.AreEqual(0, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(0, rootChild0.Layout.Width);
            Assert.AreEqual(0, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(0, root.Layout.Width);
            Assert.AreEqual(0, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(0, rootChild0.Layout.Width);
            Assert.AreEqual(0, rootChild0.Layout.Height);
        }
Ejemplo n.º 14
0
        public void percentage_absolute_position()
        {
            YogaNode rootChild0;
            YogaNode root = Node(width: 200, height: 100)
                            .Add(rootChild0 = Node(positionType: PositionType.Absolute, left: 30.Percent(), top: 10.Percent(), width: 10, height: 10));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(200, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(60, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(200, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(60, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 15
0
        public void wrap_child()
        {
            var config = new YogaConfig();

            YogaNode rootChild0;
            YogaNode root = Node(config)
                            .Add(rootChild0 = Node(width: 100, height: 100));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(100, rootChild0.Layout.Width);
            Assert.AreEqual(100, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(100, rootChild0.Layout.Width);
            Assert.AreEqual(100, rootChild0.Layout.Height);
        }
Ejemplo n.º 16
0
        public void justify_content_row_min_width_and_margin()
        {
            YogaNode rootChild0;
            YogaNode root = Node(flexDirection: FlexDirection.Row, justifyContent: Justify.Center, margin: new Edges(left: 100), minWidth: 50)
                            .Add(rootChild0 = Node(width: 20, height: 20));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(100, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(50, root.Layout.Width);
            Assert.AreEqual(20, root.Layout.Height);

            Assert.AreEqual(15, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(20, rootChild0.Layout.Width);
            Assert.AreEqual(20, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(100, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(50, root.Layout.Width);
            Assert.AreEqual(20, root.Layout.Height);

            Assert.AreEqual(15, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(20, rootChild0.Layout.Width);
            Assert.AreEqual(20, rootChild0.Layout.Height);
        }
Ejemplo n.º 17
0
        public void flex_shrink_flex_grow_child_flex_shrink_other_child()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(config, flexDirection: FlexDirection.Row, width: 500, height: 500)
                            .Add(rootChild0 = Node(flexGrow: 0, flexShrink: 1, width: 500, height: 100))
                            .Add(rootChild1 = Node(flexGrow: 1, flexShrink: 1, width: 500, height: 100));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(500, root.Layout.Width);
            Assert.AreEqual(500, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(250, rootChild0.Layout.Width);
            Assert.AreEqual(100, rootChild0.Layout.Height);

            Assert.AreEqual(250, rootChild1.Layout.Left);
            Assert.AreEqual(0, rootChild1.Layout.Top);
            Assert.AreEqual(250, rootChild1.Layout.Width);
            Assert.AreEqual(100, rootChild1.Layout.Height);
        }
Ejemplo n.º 18
0
        public void justify_content_column_max_height_and_margin()
        {
            YogaNode rootChild0;
            YogaNode root = Node(justifyContent: Justify.Center, margin: new Edges(top: 100), height: 100, maxHeight: 80)
                            .Add(rootChild0 = Node(width: 20, height: 20));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(100, root.Layout.Top);
            Assert.AreEqual(20, root.Layout.Width);
            Assert.AreEqual(80, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(30, rootChild0.Layout.Top);
            Assert.AreEqual(20, rootChild0.Layout.Width);
            Assert.AreEqual(20, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(100, root.Layout.Top);
            Assert.AreEqual(20, root.Layout.Width);
            Assert.AreEqual(80, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(30, rootChild0.Layout.Top);
            Assert.AreEqual(20, rootChild0.Layout.Width);
            Assert.AreEqual(20, rootChild0.Layout.Height);
        }
Ejemplo n.º 19
0
        public void align_items_min_max()
        {
            YogaNode rootChild0;
            YogaNode root = Node(alignItems: YogaAlign.Center, minWidth: 100, maxWidth: 200, height: 100)
                            .Add(rootChild0 = Node(width: 60, height: 60));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(20, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(60, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(20, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(60, rootChild0.Layout.Height);
        }
Ejemplo n.º 20
0
        public void border_stretch_child()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0;
            YogaNode root = Node(config, border: new Edges(left: 10, top: 10, right: 10, bottom: 10), width: 100, height: 100)
                            .Add(rootChild0 = Node(height: 10));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(10, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(80, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(10, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(80, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 21
0
        public void max_width()
        {
            YogaNode rootChild0;
            YogaNode root = Node(width: 100, height: 100)
                            .Add(rootChild0 = Node(maxWidth: 50, height: 10));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(50, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(50, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(50, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 22
0
        public void padding_center_child()
        {
            YogaNode rootChild0;
            YogaNode root = Node(
                justifyContent: Justify.Center,
                alignItems: YogaAlign.Center,
                padding: new Edges(start: 10, end: 20, bottom: 20),
                width: 100, height: 100)
                            .Add(rootChild0 = Node(width: 10, height: 10));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(40, rootChild0.Layout.Left);
            Assert.AreEqual(35, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(50, rootChild0.Layout.Left);
            Assert.AreEqual(35, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 23
0
        public void absolute_layout_align_items_center_on_child_only()
        {
            YogaNode rootChild0;
            YogaNode root = Node(flexGrow: 1, width: 110, height: 100)
                            .Add(rootChild0 = Node(alignSelf: YogaAlign.Center, positionType: PositionType.Absolute, width: 60, height: 40));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(110, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(25, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(40, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(110, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(25, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(40, rootChild0.Layout.Height);
        }
Ejemplo n.º 24
0
        public void child_with_padding_align_end()
        {
            YogaNode rootChild0;
            YogaNode root = Node(justifyContent: Justify.FlexEnd, alignItems: YogaAlign.FlexEnd, width: 200, height: 200)
                            .Add(rootChild0 = Node(width: 100, height: 100, padding: new Edges(20)));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(200, root.Layout.Width);
            Assert.AreEqual(200, root.Layout.Height);

            Assert.AreEqual(100, rootChild0.Layout.Left);
            Assert.AreEqual(100, rootChild0.Layout.Top);
            Assert.AreEqual(100, rootChild0.Layout.Width);
            Assert.AreEqual(100, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(200, root.Layout.Width);
            Assert.AreEqual(200, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(100, rootChild0.Layout.Top);
            Assert.AreEqual(100, rootChild0.Layout.Width);
            Assert.AreEqual(100, rootChild0.Layout.Height);
        }
Ejemplo n.º 25
0
        public void absolute_layout_in_wrap_reverse_row_container_flex_end()
        {
            YogaNode rootChild0;
            YogaNode root = Node(flexDirection: FlexDirection.Row, flexWrap: Wrap.WrapReverse, width: 100, height: 100)
                            .Add(rootChild0 = Node(alignSelf: YogaAlign.FlexEnd, positionType: PositionType.Absolute, width: 20, height: 20));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(20, rootChild0.Layout.Width);
            Assert.AreEqual(20, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(80, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(20, rootChild0.Layout.Width);
            Assert.AreEqual(20, rootChild0.Layout.Height);
        }
Ejemplo n.º 26
0
        public void padding_stretch_child()
        {
            YogaNode rootChild0;
            YogaNode root = Node(padding: new Edges(10), width: 100, height: 100)
                            .Add(rootChild0 = Node(height: 10));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(10, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(80, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(10, rootChild0.Layout.Left);
            Assert.AreEqual(10, rootChild0.Layout.Top);
            Assert.AreEqual(80, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 27
0
        public void dirtied_hierarchy()
        {
            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(alignItems: YogaAlign.FlexStart, width: 100, height: 100)
                            .Add(rootChild0 = Node(width: 50, height: 20))
                            .Add(rootChild1 = Node(width: 50, height: 20));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            rootChild0.Context     = 0;
            rootChild0.DirtiedFunc = _dirtied;

            Assert.AreEqual(0, (int)rootChild0.Context);

            // `_dirtied` must NOT be called for descendants.
            root.MarkDirtyAndPropagate();
            Assert.AreEqual(0, (int)rootChild0.Context);

            // `_dirtied` must NOT be called for the sibling node.
            rootChild1.MarkDirtyAndPropagate();
            Assert.AreEqual(0, (int)rootChild0.Context);

            // `_dirtied` MUST be called in case of explicit dirtying.
            rootChild0.MarkDirtyAndPropagate();
            Assert.AreEqual(1, (int)rootChild0.Context);
        }
Ejemplo n.º 28
0
        public void align_self_flex_start()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0;
            YogaNode root = Node(config, width: 100, height: 100)
               .Add(rootChild0 = Node(alignSelf:YogaAlign.FlexStart, width:10, height:10));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(100, root.Layout.Width);
            Assert.AreEqual(100, root.Layout.Height);

            Assert.AreEqual(90, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(10, rootChild0.Layout.Width);
            Assert.AreEqual(10, rootChild0.Layout.Height);
        }
Ejemplo n.º 29
0
        public void align_baseline_with_no_baseline_func_and_no_parent_ht()
        {
            YogaConfig config = new YogaConfig();

            YogaNode rootChild0, rootChild1;
            YogaNode root = Node(config, flexDirection: FlexDirection.Row, alignItems: YogaAlign.Baseline, width: 150)
                            .Add(rootChild0 = Node(width: 50, height: 80))
                            .Add(rootChild1 = Node(width: 50, height: 50));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(150, root.Layout.Width);
            Assert.AreEqual(80, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(50, rootChild0.Layout.Width);
            Assert.AreEqual(80, rootChild0.Layout.Height);

            Assert.AreEqual(50, rootChild1.Layout.Left);
            Assert.AreEqual(30, rootChild1.Layout.Top);
            Assert.AreEqual(50, rootChild1.Layout.Width);
            Assert.AreEqual(50, rootChild1.Layout.Height);
        }
Ejemplo n.º 30
0
        public void percentage_width_height()
        {
            YogaNode rootChild0;
            YogaNode root = Node(flexDirection: FlexDirection.Row, width: 200, height: 200)
                            .Add(rootChild0 = Node(width: 30.Percent(), height: 30.Percent()));

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.LTR);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(200, root.Layout.Width);
            Assert.AreEqual(200, root.Layout.Height);

            Assert.AreEqual(0, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(60, rootChild0.Layout.Height);

            YogaArrange.CalculateLayout(root, YogaValue.YGUndefined, YogaValue.YGUndefined, Direction.RTL);

            Assert.AreEqual(0, root.Layout.Left);
            Assert.AreEqual(0, root.Layout.Top);
            Assert.AreEqual(200, root.Layout.Width);
            Assert.AreEqual(200, root.Layout.Height);

            Assert.AreEqual(140, rootChild0.Layout.Left);
            Assert.AreEqual(0, rootChild0.Layout.Top);
            Assert.AreEqual(60, rootChild0.Layout.Width);
            Assert.AreEqual(60, rootChild0.Layout.Height);
        }