|
|
|
@ -11,9 +11,144 @@ namespace Perspex.Controls.UnitTests |
|
|
|
using System.Reactive.Linq; |
|
|
|
using Perspex.Controls.Presenters; |
|
|
|
using Xunit; |
|
|
|
using Perspex.Layout; |
|
|
|
|
|
|
|
public class ScrollContentPresenterTests |
|
|
|
{ |
|
|
|
[Fact] |
|
|
|
public void Content_Can_Be_Left_Aligned() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ScrollContentPresenter |
|
|
|
{ |
|
|
|
Content = (content = new Border |
|
|
|
{ |
|
|
|
Padding = new Thickness(8), |
|
|
|
HorizontalAlignment = HorizontalAlignment.Left |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(0, 0, 16, 100), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Content_Can_Be_Stretched() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ScrollContentPresenter |
|
|
|
{ |
|
|
|
Content = (content = new Border |
|
|
|
{ |
|
|
|
Padding = new Thickness(8), |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(0, 0, 100, 100), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Content_Can_Be_Right_Aligned() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ScrollContentPresenter |
|
|
|
{ |
|
|
|
Content = (content = new Border |
|
|
|
{ |
|
|
|
Padding = new Thickness(8), |
|
|
|
HorizontalAlignment = HorizontalAlignment.Right |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(84, 0, 16, 100), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Content_Can_Be_Bottom_Aligned() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ScrollContentPresenter |
|
|
|
{ |
|
|
|
Content = (content = new Border |
|
|
|
{ |
|
|
|
Padding = new Thickness(8), |
|
|
|
VerticalAlignment = VerticalAlignment.Bottom, |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(0, 84, 100, 16), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Content_Can_Be_TopRight_Aligned() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ScrollContentPresenter |
|
|
|
{ |
|
|
|
Content = (content = new Border |
|
|
|
{ |
|
|
|
Padding = new Thickness(8), |
|
|
|
HorizontalAlignment = HorizontalAlignment.Right, |
|
|
|
VerticalAlignment = VerticalAlignment.Top, |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(84, 0, 16, 16), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Content_Can_Be_Larger_Than_Viewport() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ScrollContentPresenter |
|
|
|
{ |
|
|
|
Content = (content = new Border |
|
|
|
{ |
|
|
|
Width = 150, |
|
|
|
Height = 150, |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(0, 0, 150, 150), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Content_Can_Be_Offset() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ScrollContentPresenter |
|
|
|
{ |
|
|
|
Content = (content = new Border |
|
|
|
{ |
|
|
|
Width = 150, |
|
|
|
Height = 150, |
|
|
|
}), |
|
|
|
Offset = new Vector(25, 25), |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(-25, -25, 150, 150), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Arrange_Should_Set_Viewport_And_Extent_In_That_Order() |
|
|
|
{ |
|
|
|
|