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 ChildMeasureAccountsForPadding(Size viewSize, Thickness padding, Size measureConstraints, Size expectedMeasureConstraint) { var view = LayoutTestHelpers.CreateTestView(new Size(viewSize.Width, viewSize.Height)); var stack = CreateTestLayout(new List <IView>() { view }); stack.Padding.Returns(padding); var manager = new HorizontalStackLayoutManager(stack); var measuredSize = manager.Measure(measureConstraints.Width, measureConstraints.Height); view.Received().Measure(Arg.Is(expectedMeasureConstraint.Width), Arg.Is(expectedMeasureConstraint.Height)); }
public void StackAppliesWidth(double viewWidth, double stackWidth, double expectedWidth) { var view = LayoutTestHelpers.CreateTestView(new Size(viewWidth, 100)); var stack = CreateTestLayout(new List <IView>() { view }); stack.Width.Returns(stackWidth); var manager = new HorizontalStackLayoutManager(stack); var measurement = manager.Measure(double.PositiveInfinity, 100); Assert.Equal(expectedWidth, measurement.Width); }
protected IStackLayout BuildStack(int viewCount, double viewWidth, double viewHeight) { var stack = CreateTestLayout(); var children = new List <IView>(); for (int n = 0; n < viewCount; n++) { var view = LayoutTestHelpers.CreateTestView(new Size(viewWidth, viewHeight)); children.Add(view); } SubstituteChildren(stack, children); return(stack); }
public void StackAppliesHeight(double viewHeight, double stackHeight, double expectedHeight) { var view = LayoutTestHelpers.CreateTestView(new Size(100, viewHeight)); var stack = CreateTestLayout(new List <IView>() { view }); stack.Height.Returns(stackHeight); var manager = new VerticalStackLayoutManager(stack); var measurement = manager.Measure(100, double.PositiveInfinity); Assert.Equal(expectedHeight, measurement.Height); }