|
|
|
@ -13,7 +13,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_For_No_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.None; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -26,7 +26,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_For_Fill_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.Fill; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -39,7 +39,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_For_Uniform_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.Uniform; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -52,7 +52,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_For_UniformToFill_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.UniformToFill; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -62,10 +62,59 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
Assert.Equal(new Size(50, 50), target.DesiredSize); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_With_StretchDirection_DownOnly() |
|
|
|
{ |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.StretchDirection = StretchDirection.DownOnly; |
|
|
|
target.Source = bitmap; |
|
|
|
|
|
|
|
target.Measure(new Size(150, 150)); |
|
|
|
|
|
|
|
Assert.Equal(new Size(50, 100), target.DesiredSize); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_For_Infinite_Height() |
|
|
|
{ |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var image = new Image(); |
|
|
|
image.Source = bitmap; |
|
|
|
|
|
|
|
image.Measure(new Size(200, double.PositiveInfinity)); |
|
|
|
|
|
|
|
Assert.Equal(new Size(200, 400), image.DesiredSize); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_For_Infinite_Width() |
|
|
|
{ |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var image = new Image(); |
|
|
|
image.Source = bitmap; |
|
|
|
|
|
|
|
image.Measure(new Size(double.PositiveInfinity, 400)); |
|
|
|
|
|
|
|
Assert.Equal(new Size(200, 400), image.DesiredSize); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Measure_Should_Return_Correct_Size_For_Infinite_Width_Height() |
|
|
|
{ |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var image = new Image(); |
|
|
|
image.Source = bitmap; |
|
|
|
|
|
|
|
image.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); |
|
|
|
|
|
|
|
Assert.Equal(new Size(50, 100), image.DesiredSize); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Arrange_Should_Return_Correct_Size_For_No_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.None; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -79,7 +128,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
[Fact] |
|
|
|
public void Arrange_Should_Return_Correct_Size_For_Fill_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.Fill; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -93,7 +142,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
[Fact] |
|
|
|
public void Arrange_Should_Return_Correct_Size_For_Uniform_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.Uniform; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -107,7 +156,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
[Fact] |
|
|
|
public void Arrange_Should_Return_Correct_Size_For_UniformToFill_Stretch() |
|
|
|
{ |
|
|
|
var bitmap = Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(50, 100)); |
|
|
|
var bitmap = CreateBitmap(50, 100); |
|
|
|
var target = new Image(); |
|
|
|
target.Stretch = Stretch.UniformToFill; |
|
|
|
target.Source = bitmap; |
|
|
|
@ -117,5 +166,10 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
|
|
|
|
Assert.Equal(new Size(25, 100), target.Bounds.Size); |
|
|
|
} |
|
|
|
|
|
|
|
private IBitmap CreateBitmap(int width, int height) |
|
|
|
{ |
|
|
|
return Mock.Of<IBitmap>(x => x.PixelSize == new PixelSize(width, height)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|