Exemple #1
0
        public void pixels()
        {
            var size = LayoutSize.Pixels(30, 50);

            size.IsFixedAspectRatio().Should().BeFalse();
            size.IsMeasurableAlong(Orientation.Horizontal).Should().BeTrue();
            size.IsMeasurableAlong(Orientation.Vertical).Should().BeTrue();
            size.IsStretchedAlong(Orientation.Vertical).Should().BeFalse();
            size.IsStretchedPerpendicular(Orientation.Vertical).Should().BeFalse();
        }
Exemple #2
0
        public void fixed_aspect_with_alignment()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 80), new LayoutStyle(alignment: Alignment.Center),
                                                   LayoutNode.Leaf("fixed-aspect", LayoutSize.FixedAspectRatio(16, 9))
                                                   );

            var firstBakeResult = layout.Bake();

            Approvals.Verify(
                LayoutNodeUtils.DrawResult(firstBakeResult)
                );
        }
Exemple #3
0
        public void linear_layout_test_with_margin_and_padding()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 100), new LayoutStyle(padding: 5, margin: new Point(3, 6)),
                                                   LayoutNode.Leaf("item-1", LayoutSize.StretchedHorizontally(10)),
                                                   LayoutNode.Leaf("item-2", LayoutSize.StretchedHorizontally(20)),
                                                   LayoutNode.Leaf("item-3", LayoutSize.StretchedBoth())
                                                   );

            var layoutResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(layoutResult));
        }
Exemple #4
0
        public void linear_layout_test()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 100), LayoutStyle.Empty,
                                                   LayoutNode.Leaf("item-1", LayoutSize.StretchedHorizontally(10)),
                                                   LayoutNode.Leaf("item-2", LayoutSize.StretchedHorizontally(20)),
                                                   LayoutNode.Leaf("item-3", LayoutSize.StretchedBoth())
                                                   );

            var layoutResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(layoutResult));
        }
Exemple #5
0
        public void spacer_test()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(50, 20), LayoutStyle.Empty,
                                                     LayoutNode.StretchedSpacer(),
                                                     LayoutNode.Leaf("nudged-item", LayoutSize.StretchedVertically(10)),
                                                     LayoutNode.Spacer(5)
                                                     );

            var firstBakeResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(firstBakeResult));
        }
        public void flex_layout_supports_padding()
        {
            var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(style: new LayoutStyle(margin: new Point(5, 5), padding: 3)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void can_create_vertical_flex_layout()
        {
            var layout = FlexLayout.VerticalFlexParent("root", FlexLayoutStyle.Empty,
                                                       LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                       LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                       LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                       LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                       LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                       );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Exemple #8
0
        public void alignment_with_varied_height_things_top_right()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(68, 20), new LayoutStyle(padding: 3, alignment: Alignment.TopRight),
                                                     LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                     LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                     LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                     LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                     LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                     );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Exemple #9
0
        public void does_not_stretch_evenly()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft),
                                                     LayoutNode.Leaf("a", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("b", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("c", LayoutSize.StretchedBoth())
                                                     );

            var result = layout.Bake();

            Approvals.Verify(
                LayoutNodeUtils.DrawResult(result)
                );
        }
        public void flex_can_specify_a_min_width()
        {
            var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(minAlongSize: 100, style: new LayoutStyle(margin: new Point(5, 5), padding: 3, alignment: Alignment.BottomCenter)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void can_get_baked_layout_node_by_name()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft),
                                                     LayoutNode.Leaf("a", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("b", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("c", LayoutSize.StretchedBoth())
                                                     );

            var subject = layout.Bake();

            var acquiredNode = subject.GetNode("b");

            acquiredNode.Size.Should().Be(new Point(5, 3));
        }
        public void flex_considers_alignment_when_things_have_varied_perpendicular_size()
        {
            var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(style: new LayoutStyle(margin: new Point(5, 5), padding: 3, alignment: Alignment.BottomCenter)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_estimates_accurate_height()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 30), FlowLayoutStyle.Empty,
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 5)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(13, 7)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(12, 3)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(13, 12)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(8, 15)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 5))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_can_have_margin()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 40), new FlowLayoutStyle(margin: new Point(5)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_supports_padding_between_individual_items()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 30), new FlowLayoutStyle(paddingBetweenItemsInEachRow: 4),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(13, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_can_have_padding_between_rows()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(30, 30), new FlowLayoutStyle(paddingBetweenRows: 3),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_halts_on_illegal_but_keep_last_overflow()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 20), new FlowLayoutStyle(overflowRule: OverflowRule.LastRowKeepsGoing),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(13, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("really-wide-item", LayoutSize.Pixels(21, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void can_create_flow_layout()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(30, 30), FlowLayoutStyle.Empty,
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_supports_horizontal_alignment()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 30), new FlowLayoutStyle(alignment: Alignment.CenterRight),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_can_be_vertical_with_alignment()
        {
            var layout = FlowLayout.VerticalFlowParent("root", LayoutSize.Pixels(25, 40), new FlowLayoutStyle(alignment: Alignment.BottomRight),
                                                       LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                       LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                       LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                       LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                       LayoutNode.Leaf("itemE", LayoutSize.Pixels(13, 10)),
                                                       LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10))
                                                       );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_can_be_vertical()
        {
            var layout = FlowLayout.VerticalFlowParent("root", LayoutSize.Pixels(25, 40), new FlowLayoutStyle(paddingBetweenItemsInEachRow: 4),
                                                       LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                       LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                       LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                       LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                       LayoutNode.Leaf("itemE", LayoutSize.Pixels(13, 10)),
                                                       LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10))
                                                       );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
        public void flow_layout_halts_on_illegal_overflow()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 20), new FlowLayoutStyle(overflowRule: OverflowRule.EverythingMustBeInside),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(13, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(8, 12)),
                                                         LayoutNode.Leaf("itemG", LayoutSize.Pixels(9, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Exemple #23
0
        public void fixed_aspect_with_spacers()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 80), LayoutStyle.Empty,
                                                   LayoutNode.StretchedSpacer(),
                                                   LayoutNode.HorizontalParent("aligner", LayoutSize.StretchedBoth(), LayoutStyle.Empty,
                                                                               LayoutNode.StretchedSpacer(),
                                                                               LayoutNode.Leaf("fixed-aspect", LayoutSize.FixedAspectRatio(16, 9)),
                                                                               LayoutNode.StretchedSpacer()
                                                                               ),
                                                   LayoutNode.StretchedSpacer()
                                                   );

            var firstBakeResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(firstBakeResult));
        }
        public void can_obtain_all_result_nodes_in_order()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft),
                                                     LayoutNode.Leaf("a", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("b", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("c", LayoutSize.StretchedBoth())
                                                     );

            var subject = layout.Bake();

            var result = subject.GetAllResultNodesInHierarchyOrder();

            result.Should().HaveCount(4);

            result.Should().ContainInOrder(subject.GetNode("root"), subject.GetNode("a"), subject.GetNode("b"), subject.GetNode("c"));
        }
        public void flow_layout_can_address_individual_rows()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(25, 40), new FlowLayoutStyle(alignment: Alignment.Center),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         FlowLayoutInstruction.Linebreak,
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                         FlowLayoutInstruction.Linebreak,
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(13, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemG", LayoutSize.Pixels(7, 10))
                                                         );

            var result = layout.Bake();

            result.GetRow(0).ItemCount.Should().Be(2);
            result.GetRow(1).ItemCount.Should().Be(1);
            result.GetRow(2).ItemCount.Should().Be(2);
            result.GetRow(3).ItemCount.Should().Be(2);

            result.GetRow(2).GetItemNode(1).Size.Should().Be(new Point(13, 10));

            result.GetRow(0).Node.Rectangle.Should().Be(new Rectangle(new Point(0, 0), new Point(25, 10)));
            result.GetRow(1).Node.Rectangle.Should().Be(new Rectangle(new Point(0, 10), new Point(25, 10)));
            result.GetRow(2).Node.Rectangle.Should().Be(new Rectangle(new Point(0, 20), new Point(25, 10)));
            result.GetRow(3).Node.Rectangle.Should().Be(new Rectangle(new Point(0, 30), new Point(25, 10)));

            result.GetRow(0).UsedRectangle.Should().Be(new Rectangle(new Point(3, 0), new Point(19, 10)));
            result.GetRow(1).UsedRectangle.Should().Be(new Rectangle(new Point(8, 10), new Point(9, 10)));
            result.GetRow(2).UsedRectangle.Should().Be(new Rectangle(new Point(1, 20), new Point(23, 10)));
            result.GetRow(3).UsedRectangle.Should().Be(new Rectangle(new Point(5, 30), new Point(14, 10)));


            int totalItems = 0;

            foreach (var row in result.Rows)
            {
                foreach (var item in row)
                {
                    item.NestingLevel.Should().Be(3);
                    totalItems++;
                }
            }

            totalItems.Should().Be(7);
        }
Exemple #26
0
        public void create_window_test()
        {
            var headerHeight = 8;
            var layout       = LayoutNode.VerticalParent("root", LayoutSize.Pixels(80, 40), LayoutStyle.Empty,
                                                         LayoutNode.HorizontalParent("header", LayoutSize.StretchedHorizontally(headerHeight), new LayoutStyle(padding: 2),
                                                                                     LayoutNode.StretchedSpacer(),
                                                                                     LayoutNode.Leaf("minimize", LayoutSize.Square(headerHeight)),
                                                                                     LayoutNode.Leaf("fullscreen", LayoutSize.Square(headerHeight)),
                                                                                     LayoutNode.Leaf("close", LayoutSize.Square(headerHeight))
                                                                                     ),
                                                         LayoutNode.Leaf("canvas", LayoutSize.StretchedBoth())
                                                         );

            var firstBakeResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(firstBakeResult));
        }
        public void flow_layout_can_permit_overflow_extra_rows()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 20), new FlowLayoutStyle(overflowRule: OverflowRule.Free),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(13, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(8, 10)),
                                                         LayoutNode.Leaf("itemG", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemH", LayoutSize.Pixels(4, 4))
                                                         );

            var result = layout.Bake();

            Approvals.Verify("There are supposed to be a bunch of skipped pixels here: \n\n" + LayoutNodeUtils.DrawResult(result));
        }
        public void can_obtain_child_nodes_of_particular_node()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft),
                                                     LayoutNode.HorizontalParent("a", LayoutSize.StretchedBoth(), LayoutStyle.Empty,
                                                                                 LayoutNode.Leaf("a1", LayoutSize.StretchedBoth()),
                                                                                 LayoutNode.Leaf("a2", LayoutSize.StretchedBoth()),
                                                                                 LayoutNode.Leaf("a3", LayoutSize.StretchedBoth()),
                                                                                 LayoutNode.Leaf("a4", LayoutSize.StretchedBoth()),
                                                                                 LayoutNode.Leaf("a5", LayoutSize.StretchedBoth())
                                                                                 ),
                                                     LayoutNode.Leaf("b", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("c", LayoutSize.StretchedBoth())
                                                     );

            var subject = layout.Bake();

            subject.GetDirectChildrenOfNode("a").Should().ContainInOrder(subject.GetNode("a1"), subject.GetNode("a2"), subject.GetNode("a3"), subject.GetNode("a4"), subject.GetNode("a5"));
        }
Exemple #29
0
        public void vertical_stretch_test()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 80), LayoutStyle.Empty,
                                                   LayoutNode.HorizontalParent("group-1", LayoutSize.Pixels(50, 20), new LayoutStyle(margin: new Point(3, 3)),
                                                                               LayoutNode.Leaf("tall-item", LayoutSize.StretchedVertically(15)),
                                                                               LayoutNode.Leaf("both-item", LayoutSize.StretchedBoth())
                                                                               ),
                                                   LayoutNode.StretchedSpacer(),
                                                   LayoutNode.VerticalParent("group-2", LayoutSize.Pixels(50, 20), new LayoutStyle(margin: new Point(3, 3)),
                                                                             LayoutNode.Leaf("tall-item-2", LayoutSize.StretchedVertically(15)),
                                                                             LayoutNode.Leaf("both-item-2", LayoutSize.StretchedBoth())
                                                                             )
                                                   );

            var firstBakeResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(firstBakeResult));
        }
        public void flow_layout_allows_forced_linebreaks()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 40), FlowLayoutStyle.Empty,
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         FlowLayoutInstruction.Linebreak,
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 5)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(13, 7)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 5)),
                                                         FlowLayoutInstruction.Linebreak,
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(8, 10)),
                                                         LayoutNode.Leaf("itemG", LayoutSize.Pixels(9, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }