csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.2 KiB
117 lines
3.2 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="ImageTests.cs" company="Steven Kirk">
|
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
namespace Perspex.Direct2D1.RenderTests.Controls
|
|
{
|
|
using System.IO;
|
|
using Perspex.Controls;
|
|
using Perspex.Media;
|
|
using Perspex.Media.Imaging;
|
|
using Xunit;
|
|
|
|
public class ImageTests : TestBase
|
|
{
|
|
private Bitmap bitmap;
|
|
|
|
public ImageTests()
|
|
: base(@"Controls\Image")
|
|
{
|
|
this.bitmap = new Bitmap(Path.Combine(this.OutputPath, "test.png"));
|
|
}
|
|
|
|
[Fact]
|
|
public void Image_Stretch_None()
|
|
{
|
|
Decorator target = new Decorator
|
|
{
|
|
Padding = new Thickness(20, 8),
|
|
Width = 200,
|
|
Height = 200,
|
|
Child = new Border
|
|
{
|
|
Background = Brushes.Red,
|
|
Child = new Image
|
|
{
|
|
Source = this.bitmap,
|
|
Stretch = Stretch.None,
|
|
}
|
|
}
|
|
};
|
|
|
|
this.RenderToFile(target);
|
|
this.CompareImages();
|
|
}
|
|
|
|
[Fact]
|
|
public void Image_Stretch_Fill()
|
|
{
|
|
Decorator target = new Decorator
|
|
{
|
|
Padding = new Thickness(20, 8),
|
|
Width = 200,
|
|
Height = 200,
|
|
Child = new Border
|
|
{
|
|
Background = Brushes.Red,
|
|
Child = new Image
|
|
{
|
|
Source = this.bitmap,
|
|
Stretch = Stretch.Fill,
|
|
}
|
|
}
|
|
};
|
|
|
|
this.RenderToFile(target);
|
|
this.CompareImages();
|
|
}
|
|
|
|
[Fact]
|
|
public void Image_Stretch_Uniform()
|
|
{
|
|
Decorator target = new Decorator
|
|
{
|
|
Padding = new Thickness(20, 8),
|
|
Width = 200,
|
|
Height = 200,
|
|
Child = new Border
|
|
{
|
|
Background = Brushes.Red,
|
|
Child = new Image
|
|
{
|
|
Source = this.bitmap,
|
|
Stretch = Stretch.Uniform,
|
|
}
|
|
}
|
|
};
|
|
|
|
this.RenderToFile(target);
|
|
this.CompareImages();
|
|
}
|
|
|
|
[Fact]
|
|
public void Image_Stretch_UniformToFill()
|
|
{
|
|
Decorator target = new Decorator
|
|
{
|
|
Padding = new Thickness(20, 8),
|
|
Width = 200,
|
|
Height = 200,
|
|
Child = new Border
|
|
{
|
|
Background = Brushes.Red,
|
|
Child = new Image
|
|
{
|
|
Source = this.bitmap,
|
|
Stretch = Stretch.UniformToFill,
|
|
}
|
|
}
|
|
};
|
|
|
|
this.RenderToFile(target);
|
|
this.CompareImages();
|
|
}
|
|
}
|
|
}
|
|
|