A cross-platform UI framework for .NET
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.
 
 
 

84 lines
2.3 KiB

using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Xunit;
#if AVALONIA_SKIA
namespace Avalonia.Skia.RenderTests
#else
namespace Avalonia.Direct2D1.RenderTests.Media
#endif
{
public class ImageDrawingTests : TestBase
{
public ImageDrawingTests()
: base(@"Media\ImageDrawing")
{
}
private string BitmapPath
{
get { return System.IO.Path.Combine(OutputPath, "github_icon.png"); }
}
[Fact]
public async Task ImageDrawing_Fill()
{
Decorator target = new Decorator
{
Width = 200,
Height = 200,
Child = new Image
{
Source = new DrawingImage
{
Drawing = new ImageDrawing
{
ImageSource = new Bitmap(BitmapPath),
Rect = new Rect(0, 0, 200, 200),
}
}
}
};
await RenderToFile(target);
CompareImages();
}
[Fact]
public async Task ImageDrawing_BottomRight()
{
Decorator target = new Decorator
{
Width = 200,
Height = 200,
Child = new Image
{
Source = new DrawingImage
{
Drawing = new DrawingGroup
{
Children =
{
new GeometryDrawing
{
Geometry = StreamGeometry.Parse("m0,0 l200,200"),
Brush = Brushes.Black,
},
new ImageDrawing
{
ImageSource = new Bitmap(BitmapPath),
Rect = new Rect(100, 100, 100, 100),
}
}
}
}
}
};
await RenderToFile(target);
CompareImages();
}
}
}