Browse Source

add more unit tests for relative panel

pull/3987/head
Dan Walmsley 6 years ago
parent
commit
b64ca7d5b7
  1. 29
      tests/Avalonia.Controls.UnitTests/RelativePanelTests.cs

29
tests/Avalonia.Controls.UnitTests/RelativePanelTests.cs

@ -6,13 +6,15 @@ namespace Avalonia.Controls.UnitTests
public class RelativePanelTests
{
[Fact]
public void Lays_Out_1_Child_Below_the_other()
public void Lays_Out_1_Child_Next_the_other()
{
var rect1 = new Rectangle { Height = 20, Width = 20 };
var rect2 = new Rectangle { Height = 20, Width = 20 };
var target = new RelativePanel
{
VerticalAlignment = Layout.VerticalAlignment.Top,
HorizontalAlignment = Layout.HorizontalAlignment.Left,
Children =
{
rect1, rect2
@ -20,6 +22,31 @@ namespace Avalonia.Controls.UnitTests
};
RelativePanel.SetAlignLeftWithPanel(rect1 , true);
RelativePanel.SetRightOf(rect2, rect1);
target.Measure(new Size(400, 400));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(new Size(40, 20), target.Bounds.Size);
Assert.Equal(new Rect(0, 0, 20, 20), target.Children[0].Bounds);
Assert.Equal(new Rect(20, 0, 20, 20), target.Children[1].Bounds);
}
public void Lays_Out_1_Child_Below_the_other()
{
var rect1 = new Rectangle { Height = 20, Width = 20 };
var rect2 = new Rectangle { Height = 20, Width = 20 };
var target = new RelativePanel
{
VerticalAlignment = Layout.VerticalAlignment.Top,
HorizontalAlignment = Layout.HorizontalAlignment.Left,
Children =
{
rect1, rect2
}
};
RelativePanel.SetAlignLeftWithPanel(rect1, true);
RelativePanel.SetBelow(rect2, rect1);
target.Measure(new Size(400, 400));
target.Arrange(new Rect(target.DesiredSize));

Loading…
Cancel
Save