public void SpacingArrangementTwoItems(int spacing)
        {
            var stack = BuildStack(2, 100, 100);

            stack.Spacing.Returns(spacing);

            var manager = new HorizontalStackLayoutManager(stack);

            var measuredSize = manager.Measure(double.PositiveInfinity, 100);

            manager.Arrange(new Rectangle(Point.Zero, measuredSize));

            var expectedRectangle0 = new Rectangle(0, 0, 100, 100);

            stack.Children[0].Received().Arrange(Arg.Is(expectedRectangle0));

            var expectedRectangle1 = new Rectangle(100 + spacing, 0, 100, 100);

            stack.Children[1].Received().Arrange(Arg.Is(expectedRectangle1));
        }
Exemple #2
0
        public void ArrangeAccountsForFill()
        {
            var stack = BuildStack(viewCount: 1, viewWidth: 100, viewHeight: 100);

            stack.HorizontalLayoutAlignment.Returns(LayoutAlignment.Fill);
            stack.VerticalLayoutAlignment.Returns(LayoutAlignment.Fill);

            var layoutManager = new HorizontalStackLayoutManager(stack);

            _ = layoutManager.Measure(double.PositiveInfinity, double.PositiveInfinity);

            var arrangedWidth  = 1000;
            var arrangedHeight = 1000;

            var target = new Rect(Point.Zero, new Size(arrangedWidth, arrangedHeight));

            var actual = layoutManager.ArrangeChildren(target);

            // Since we're arranging in a space larger than needed and the layout is set to Fill in both directions,
            // we expect the returned actual arrangement size to be as large as the target space
            Assert.Equal(arrangedWidth, actual.Width);
            Assert.Equal(arrangedHeight, actual.Height);
        }
Exemple #3
0
        public void RtlShouldStartAtRightEdge()
        {
            var stack = BuildStack(viewCount: 2, viewWidth: 100, viewHeight: 100);

            stack.FlowDirection.Returns(FlowDirection.RightToLeft);
            stack.HorizontalLayoutAlignment.Returns(LayoutAlignment.Fill);
            stack.Spacing.Returns(0);

            var manager      = new HorizontalStackLayoutManager(stack);
            var measuredSize = manager.Measure(double.PositiveInfinity, 100);

            // Arranging in a larger space than measured to simulate a Fill situation
            var rightEdge = measuredSize.Width * 2;

            manager.ArrangeChildren(new Rect(0, 0, rightEdge, measuredSize.Height));

            // We expect that the starting view (0) should be arranged on the right,
            // and the next rectangle (1) should be on the left
            var expectedRectangle0 = new Rect(rightEdge - 100, 0, 100, 100);
            var expectedRectangle1 = new Rect(rightEdge - 200, 0, 100, 100);

            stack[0].Received().Arrange(Arg.Is(expectedRectangle0));
            stack[1].Received().Arrange(Arg.Is(expectedRectangle1));
        }