Browse Source

Provide a RenderInterface for controls which use shapes.

pull/4858/head
Steven Kirk 6 years ago
parent
commit
9f8f4b224f
  1. 9
      tests/Avalonia.Controls.UnitTests/CanvasTests.cs
  2. 15
      tests/Avalonia.Controls.UnitTests/LayoutTransformControlTests.cs
  3. 6
      tests/Avalonia.Controls.UnitTests/RelativePanelTests.cs
  4. 13
      tests/Avalonia.Controls.UnitTests/ViewboxTests.cs

9
tests/Avalonia.Controls.UnitTests/CanvasTests.cs

@ -1,5 +1,6 @@
using System; using System;
using Avalonia.Controls.Shapes; using Avalonia.Controls.Shapes;
using Avalonia.UnitTests;
using Xunit; using Xunit;
namespace Avalonia.Controls.UnitTests namespace Avalonia.Controls.UnitTests
@ -9,6 +10,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Left_Property_Should_Work() public void Left_Property_Should_Work()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
Rectangle rect; Rectangle rect;
var target = new Canvas var target = new Canvas
{ {
@ -34,6 +37,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Top_Property_Should_Work() public void Top_Property_Should_Work()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
Rectangle rect; Rectangle rect;
var target = new Canvas var target = new Canvas
{ {
@ -59,6 +64,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Right_Property_Should_Work() public void Right_Property_Should_Work()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
Rectangle rect; Rectangle rect;
var target = new Canvas var target = new Canvas
{ {
@ -84,6 +91,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Bottom_Property_Should_Work() public void Bottom_Property_Should_Work()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
Rectangle rect; Rectangle rect;
var target = new Canvas var target = new Canvas
{ {

15
tests/Avalonia.Controls.UnitTests/LayoutTransformControlTests.cs

@ -1,5 +1,6 @@
using Avalonia.Controls.Shapes; using Avalonia.Controls.Shapes;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.UnitTests;
using Xunit; using Xunit;
namespace Avalonia.Controls.UnitTests namespace Avalonia.Controls.UnitTests
@ -171,6 +172,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Should_Generate_RotateTransform_90_degrees() public void Should_Generate_RotateTransform_90_degrees()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform( LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(
100, 100,
25, 25,
@ -193,6 +196,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Should_Generate_RotateTransform_minus_90_degrees() public void Should_Generate_RotateTransform_minus_90_degrees()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform( LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(
100, 100,
25, 25,
@ -215,6 +220,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Should_Generate_ScaleTransform_x2() public void Should_Generate_ScaleTransform_x2()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform( LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(
100, 100,
50, 50,
@ -236,6 +243,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Should_Generate_SkewTransform_45_degrees() public void Should_Generate_SkewTransform_45_degrees()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform( LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(
100, 100,
100, 100,
@ -258,6 +267,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Should_Generate_SkewTransform_minus_45_degrees() public void Should_Generate_SkewTransform_minus_45_degrees()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform( LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(
100, 100,
100, 100,
@ -279,6 +290,8 @@ namespace Avalonia.Controls.UnitTests
private static void TransformMeasureSizeTest(Size size, Transform transform, Size expectedSize) private static void TransformMeasureSizeTest(Size size, Transform transform, Size expectedSize)
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform( LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(
size.Width, size.Width,
size.Height, size.Height,
@ -292,6 +305,8 @@ namespace Avalonia.Controls.UnitTests
private static void TransformRootBoundsTest(Size size, Transform transform, Rect expectedBounds) private static void TransformRootBoundsTest(Size size, Transform transform, Rect expectedBounds)
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(size.Width, size.Height, transform); LayoutTransformControl lt = CreateWithChildAndMeasureAndTransform(size.Width, size.Height, transform);
Rect outBounds = lt.TransformRoot.Bounds; Rect outBounds = lt.TransformRoot.Bounds;

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

@ -1,4 +1,5 @@
using Avalonia.Controls.Shapes; using Avalonia.Controls.Shapes;
using Avalonia.UnitTests;
using Xunit; using Xunit;
namespace Avalonia.Controls.UnitTests namespace Avalonia.Controls.UnitTests
@ -8,6 +9,7 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Lays_Out_1_Child_Next_the_other() public void Lays_Out_1_Child_Next_the_other()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect1 = new Rectangle { Height = 20, Width = 20 };
var rect2 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 };
@ -34,6 +36,7 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Lays_Out_1_Child_Below_the_other() public void Lays_Out_1_Child_Below_the_other()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect1 = new Rectangle { Height = 20, Width = 20 };
var rect2 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 };
@ -60,6 +63,7 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void RelativePanel_Can_Center() public void RelativePanel_Can_Center()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect1 = new Rectangle { Height = 20, Width = 20 };
var rect2 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 };
@ -86,6 +90,7 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void LeftOf_Measures_Correctly() public void LeftOf_Measures_Correctly()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect1 = new Rectangle { Height = 20, Width = 20 };
var rect2 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 };
@ -111,6 +116,7 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Above_Measures_Correctly() public void Above_Measures_Correctly()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var rect1 = new Rectangle { Height = 20, Width = 20 }; var rect1 = new Rectangle { Height = 20, Width = 20 };
var rect2 = new Rectangle { Height = 20, Width = 20 }; var rect2 = new Rectangle { Height = 20, Width = 20 };

13
tests/Avalonia.Controls.UnitTests/ViewboxTests.cs

@ -1,5 +1,6 @@
using Avalonia.Controls.Shapes; using Avalonia.Controls.Shapes;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.UnitTests;
using Xunit; using Xunit;
namespace Avalonia.Controls.UnitTests namespace Avalonia.Controls.UnitTests
@ -9,6 +10,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Viewbox_Stretch_Uniform_Child() public void Viewbox_Stretch_Uniform_Child()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var target = new Viewbox() { Child = new Rectangle() { Width = 100, Height = 50 } }; var target = new Viewbox() { Child = new Rectangle() { Width = 100, Height = 50 } };
target.Measure(new Size(200, 200)); target.Measure(new Size(200, 200));
@ -25,6 +28,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Viewbox_Stretch_None_Child() public void Viewbox_Stretch_None_Child()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var target = new Viewbox() { Stretch = Stretch.None, Child = new Rectangle() { Width = 100, Height = 50 } }; var target = new Viewbox() { Stretch = Stretch.None, Child = new Rectangle() { Width = 100, Height = 50 } };
target.Measure(new Size(200, 200)); target.Measure(new Size(200, 200));
@ -41,6 +46,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Viewbox_Stretch_Fill_Child() public void Viewbox_Stretch_Fill_Child()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var target = new Viewbox() { Stretch = Stretch.Fill, Child = new Rectangle() { Width = 100, Height = 50 } }; var target = new Viewbox() { Stretch = Stretch.Fill, Child = new Rectangle() { Width = 100, Height = 50 } };
target.Measure(new Size(200, 200)); target.Measure(new Size(200, 200));
@ -57,6 +64,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Viewbox_Stretch_UniformToFill_Child() public void Viewbox_Stretch_UniformToFill_Child()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var target = new Viewbox() { Stretch = Stretch.UniformToFill, Child = new Rectangle() { Width = 100, Height = 50 } }; var target = new Viewbox() { Stretch = Stretch.UniformToFill, Child = new Rectangle() { Width = 100, Height = 50 } };
target.Measure(new Size(200, 200)); target.Measure(new Size(200, 200));
@ -73,6 +82,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Viewbox_Stretch_Uniform_Child_With_Unrestricted_Width() public void Viewbox_Stretch_Uniform_Child_With_Unrestricted_Width()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var target = new Viewbox() { Child = new Rectangle() { Width = 100, Height = 50 } }; var target = new Viewbox() { Child = new Rectangle() { Width = 100, Height = 50 } };
target.Measure(new Size(double.PositiveInfinity, 200)); target.Measure(new Size(double.PositiveInfinity, 200));
@ -89,6 +100,8 @@ namespace Avalonia.Controls.UnitTests
[Fact] [Fact]
public void Viewbox_Stretch_Uniform_Child_With_Unrestricted_Height() public void Viewbox_Stretch_Uniform_Child_With_Unrestricted_Height()
{ {
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface);
var target = new Viewbox() { Child = new Rectangle() { Width = 100, Height = 50 } }; var target = new Viewbox() { Child = new Rectangle() { Width = 100, Height = 50 } };
target.Measure(new Size(200, double.PositiveInfinity)); target.Measure(new Size(200, double.PositiveInfinity));

Loading…
Cancel
Save