public void DoesNotIgnoreHiddenViews() { var view = LayoutTestHelpers.CreateTestView(new Size(100, 100)); var hiddenView = LayoutTestHelpers.CreateTestView(new Size(100, 100)); hiddenView.Visibility.Returns(Visibility.Hidden); var stack = CreateTestLayout(new List <IView>() { view, hiddenView }); var manager = new HorizontalStackLayoutManager(stack); var measure = manager.Measure(double.PositiveInfinity, 100); manager.ArrangeChildren(new Rect(Point.Zero, measure)); // View is visible, so we expect it to be measured and arranged view.Received().Measure(Arg.Any <double>(), Arg.Any <double>()); view.Received().Arrange(Arg.Any <Rect>()); // View is hidden, so we expect it to be measured and arranged (since it'll need to take up space) hiddenView.Received().Measure(Arg.Any <double>(), Arg.Any <double>()); hiddenView.Received().Arrange(Arg.Any <Rect>()); }
public void IgnoresCollapsedViews() { var view = LayoutTestHelpers.CreateTestView(new Size(100, 100)); var collapsedView = LayoutTestHelpers.CreateTestView(new Size(100, 100)); collapsedView.Visibility.Returns(Visibility.Collapsed); var stack = CreateTestLayout(new List <IView>() { view, collapsedView }); var manager = new HorizontalStackLayoutManager(stack); var measure = manager.Measure(double.PositiveInfinity, 100); manager.ArrangeChildren(new Rect(Point.Zero, measure)); // View is visible, so we expect it to be measured and arranged view.Received().Measure(Arg.Any <double>(), Arg.Any <double>()); view.Received().Arrange(Arg.Any <Rect>()); // View is collapsed, so we expect it not to be measured or arranged collapsedView.DidNotReceive().Measure(Arg.Any <double>(), Arg.Any <double>()); collapsedView.DidNotReceive().Arrange(Arg.Any <Rect>()); }
public void ArrangeRespectsBounds() { var stack = BuildStack(viewCount: 1, viewWidth: 100, viewHeight: 100); var manager = new HorizontalStackLayoutManager(stack); var measuredSize = manager.Measure(double.PositiveInfinity, 100); manager.ArrangeChildren(new Rect(new Point(10, 15), measuredSize)); var expectedRectangle0 = new Rect(10, 15, 100, 100); stack[0].Received().Arrange(Arg.Is(expectedRectangle0)); }
public void ArrangeAccountsForPadding(double left, double top, double right, double bottom) { var viewWidth = 100d; var viewHeight = 100d; var padding = new Thickness(left, top, right, bottom); var stack = BuildPaddedStack(padding, viewWidth, viewHeight); var manager = new HorizontalStackLayoutManager(stack); var measuredSize = manager.Measure(double.PositiveInfinity, double.PositiveInfinity); manager.ArrangeChildren(new Rect(Point.Zero, measuredSize)); AssertArranged(stack[0], padding.Left, padding.Top, viewWidth, viewHeight); }
public void SpacingArrangementOneItem(int spacing) { var stack = BuildStack(1, 100, 100); stack.Spacing.Returns(spacing); var manager = new HorizontalStackLayoutManager(stack); var measuredSize = manager.Measure(double.PositiveInfinity, 100); manager.ArrangeChildren(new Rect(Point.Zero, measuredSize)); var expectedRectangle = new Rect(0, 0, 100, 100); stack[0].Received().Arrange(Arg.Is(expectedRectangle)); }
public void LtrShouldHaveFirstItemOnTheLeft() { var stack = BuildStack(viewCount: 2, viewWidth: 100, viewHeight: 100); stack.FlowDirection.Returns(FlowDirection.LeftToRight); var manager = new HorizontalStackLayoutManager(stack); var measuredSize = manager.Measure(double.PositiveInfinity, 100); manager.ArrangeChildren(new Rect(Point.Zero, measuredSize)); // We expect that the starting view (0) should be arranged on the left, // and the next rectangle (1) should be on the right var expectedRectangle0 = new Rect(0, 0, 100, 100); var expectedRectangle1 = new Rect(100, 0, 100, 100); stack[0].Received().Arrange(Arg.Is(expectedRectangle0)); stack[1].Received().Arrange(Arg.Is(expectedRectangle1)); }
public void SpacingArrangementTwoItems(int spacing) { var stack = BuildStack(2, 100, 100); stack.Spacing.Returns(spacing); stack.FlowDirection.Returns(FlowDirection.LeftToRight); var manager = new HorizontalStackLayoutManager(stack); var measuredSize = manager.Measure(double.PositiveInfinity, 100); manager.ArrangeChildren(new Rect(Point.Zero, measuredSize)); var expectedRectangle0 = new Rect(0, 0, 100, 100); stack[0].Received().Arrange(Arg.Is(expectedRectangle0)); var expectedRectangle1 = new Rect(100 + spacing, 0, 100, 100); stack[1].Received().Arrange(Arg.Is(expectedRectangle1)); }
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); }
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)); }