diff --git a/Perspex.sln b/Perspex.sln
index 04167cd725..ad41eabbeb 100644
--- a/Perspex.sln
+++ b/Perspex.sln
@@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Direct2D1.RenderTes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Input.UnitTests", "Tests\Perspex.Input.UnitTests\Perspex.Input.UnitTests.csproj", "{AC18926A-E784-40FE-B09D-BB0FE2B599F0}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Direct2D1.UnitTests", "Tests\Perspex.Direct2D1.UnitTests\Perspex.Direct2D1.UnitTests.csproj", "{EFB11458-9CDF-41C0-BE4F-44AF45A4CAB8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -153,6 +155,10 @@ Global
{AC18926A-E784-40FE-B09D-BB0FE2B599F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC18926A-E784-40FE-B09D-BB0FE2B599F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC18926A-E784-40FE-B09D-BB0FE2B599F0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EFB11458-9CDF-41C0-BE4F-44AF45A4CAB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EFB11458-9CDF-41C0-BE4F-44AF45A4CAB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EFB11458-9CDF-41C0-BE4F-44AF45A4CAB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EFB11458-9CDF-41C0-BE4F-44AF45A4CAB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -169,5 +175,6 @@ Global
{08478EF5-44E8-42E9-92D6-15E00EC038D8} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{DABFD304-D6A4-4752-8123-C2CCF7AC7831} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{AC18926A-E784-40FE-B09D-BB0FE2B599F0} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
+ {EFB11458-9CDF-41C0-BE4F-44AF45A4CAB8} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
EndGlobalSection
EndGlobal
diff --git a/Tests/Perspex.Direct2D1.UnitTests/Controls/Shapes/PathTests.cs b/Tests/Perspex.Direct2D1.UnitTests/Controls/Shapes/PathTests.cs
new file mode 100644
index 0000000000..f77e98c449
--- /dev/null
+++ b/Tests/Perspex.Direct2D1.UnitTests/Controls/Shapes/PathTests.cs
@@ -0,0 +1,72 @@
+// -----------------------------------------------------------------------
+//
+// Copyright 2015 MIT Licence. See licence.md for more information.
+//
+// -----------------------------------------------------------------------
+
+namespace Perspex.Direct2D1.UnitTests.Controls.Shapes
+{
+ using Perspex.Controls.Shapes;
+ using Perspex.Layout;
+ using Perspex.Media;
+ using Splat;
+ using Xunit;
+
+ public class PathTests
+ {
+ private static readonly RectComparer compare = new RectComparer();
+
+ [Fact]
+ void Should_Measure_Expander_Triangle_Correctly()
+ {
+ using (Locator.CurrentMutable.WithResolver())
+ {
+ Direct2D1Platform.Initialize();
+
+ var target = new Path
+ {
+ Data = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
+ StrokeThickness = 0,
+ HorizontalAlignment = HorizontalAlignment.Left,
+ VerticalAlignment = VerticalAlignment.Top,
+ UseLayoutRounding = false,
+ };
+
+ target.Measure(new Size(100, 100));
+ target.Arrange(new Rect(0, 0, 100, 100));
+
+ Assert.Equal(new Rect(0, 0, 4, 10), target.Bounds, compare);
+ }
+ }
+
+ [Fact]
+ void Should_Measure_Expander_Triangle_With_Stroke_Correctly()
+ {
+ using (Locator.CurrentMutable.WithResolver())
+ {
+ Direct2D1Platform.Initialize();
+
+ var target = new Path
+ {
+ Data = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
+ Stroke = Brushes.Black,
+ StrokeThickness = 2,
+ HorizontalAlignment = HorizontalAlignment.Left,
+ VerticalAlignment = VerticalAlignment.Top,
+ UseLayoutRounding = false,
+ };
+
+ target.Measure(new Size(100, 100));
+ target.Arrange(new Rect(0, 0, 100, 100));
+
+ // Measured geometry with stroke of 2px is:
+ // {-1, -0.414, 6.414, 12.828} (see GeometryTests)
+ // With origin at 0,0 the bounds equal:
+ Assert.Equal(new Rect(0, 0, 5.414, 12.414), target.Bounds, compare);
+ }
+ }
+ }
+}
+
+//{-0.5,0.79289323091507,5.207106590271,10.4142133593559}
+//{-1,-0.414213567972183,6.41421365737915,12.8284267485142}
\ No newline at end of file
diff --git a/Tests/Perspex.Direct2D1.UnitTests/Media/GeometryTests.cs b/Tests/Perspex.Direct2D1.UnitTests/Media/GeometryTests.cs
new file mode 100644
index 0000000000..9c1b018113
--- /dev/null
+++ b/Tests/Perspex.Direct2D1.UnitTests/Media/GeometryTests.cs
@@ -0,0 +1,43 @@
+// -----------------------------------------------------------------------
+//
+// Copyright 2015 MIT Licence. See licence.md for more information.
+//
+// -----------------------------------------------------------------------
+
+namespace Perspex.Direct2D1.UnitTests.Media
+{
+ using Perspex.Media;
+ using Splat;
+ using Xunit;
+
+ public class GeometryTests
+ {
+ private static readonly RectComparer compare = new RectComparer();
+
+ [Fact]
+ void Should_Measure_Expander_Triangle_Correctly()
+ {
+ using (Locator.CurrentMutable.WithResolver())
+ {
+ Direct2D1Platform.Initialize();
+
+ var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z");
+
+ Assert.Equal(new Rect(0, 2, 4, 8), target.Bounds, compare);
+ }
+ }
+
+ [Fact]
+ void Should_Measure_Expander_Triangle_With_Stroke_Correctly()
+ {
+ using (Locator.CurrentMutable.WithResolver())
+ {
+ Direct2D1Platform.Initialize();
+
+ var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z");
+
+ Assert.Equal(new Rect(-1, -0.414, 6.414, 12.828), target.GetRenderBounds(2), compare);
+ }
+ }
+ }
+}
diff --git a/Tests/Perspex.Direct2D1.UnitTests/Perspex.Direct2D1.UnitTests.csproj b/Tests/Perspex.Direct2D1.UnitTests/Perspex.Direct2D1.UnitTests.csproj
new file mode 100644
index 0000000000..46066396ea
--- /dev/null
+++ b/Tests/Perspex.Direct2D1.UnitTests/Perspex.Direct2D1.UnitTests.csproj
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+ Debug
+ AnyCPU
+ {EFB11458-9CDF-41C0-BE4F-44AF45A4CAB8}
+ Library
+ Properties
+ Perspex.Direct2D1.UnitTests
+ Perspex.Direct2D1.UnitTests
+ v4.5
+ 512
+
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll
+ True
+
+
+
+
+
+
+
+
+
+
+ ..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll
+ True
+
+
+ ..\..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll
+ True
+
+
+ ..\..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll
+ True
+
+
+
+
+
+
+
+
+
+
+ {d211e587-d8bc-45b9-95a4-f297c8fa5200}
+ Perspex.Animation
+
+
+ {b09b78d8-9b26-48b0-9149-d64a2f120f3f}
+ Perspex.Base
+
+
+ {d2221c82-4a25-4583-9b43-d791e3f6820c}
+ Perspex.Controls
+
+
+ {62024b2d-53eb-4638-b26b-85eeaa54866e}
+ Perspex.Input
+
+
+ {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}
+ Perspex.Interactivity
+
+
+ {42472427-4774-4c81-8aff-9f27b8e31721}
+ Perspex.Layout
+
+
+ {eb582467-6abb-43a1-b052-e981ba910e3a}
+ Perspex.SceneGraph
+
+
+ {f1baa01a-f176-4c6a-b39d-5b40bb1b148f}
+ Perspex.Styling
+
+
+ {3e908f67-5543-4879-a1dc-08eace79b3cd}
+ Perspex.Direct2D1
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/Perspex.Direct2D1.UnitTests/Properties/AssemblyInfo.cs b/Tests/Perspex.Direct2D1.UnitTests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..4b45a17ce2
--- /dev/null
+++ b/Tests/Perspex.Direct2D1.UnitTests/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Perspex.Direct2D1.UnitTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Perspex.Direct2D1.UnitTests")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("efb11458-9cdf-41c0-be4f-44af45a4cab8")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tests/Perspex.Direct2D1.UnitTests/RectComparer.cs b/Tests/Perspex.Direct2D1.UnitTests/RectComparer.cs
new file mode 100644
index 0000000000..6f8b62f4fa
--- /dev/null
+++ b/Tests/Perspex.Direct2D1.UnitTests/RectComparer.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Perspex.Direct2D1.UnitTests
+{
+ public class RectComparer : IEqualityComparer
+ {
+ public bool Equals(Rect a, Rect b)
+ {
+ return Math.Round(a.X, 3) == Math.Round(b.X, 3) &&
+ Math.Round(a.Y, 3) == Math.Round(b.Y, 3) &&
+ Math.Round(a.Width, 3) == Math.Round(b.Width, 3) &&
+ Math.Round(a.Height, 3) == Math.Round(b.Height, 3);
+ }
+
+ public int GetHashCode(Rect obj)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Tests/Perspex.Direct2D1.UnitTests/packages.config b/Tests/Perspex.Direct2D1.UnitTests/packages.config
new file mode 100644
index 0000000000..3f1fa6963f
--- /dev/null
+++ b/Tests/Perspex.Direct2D1.UnitTests/packages.config
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/Perspex.RenderTests/Shapes/PathTests.cs b/Tests/Perspex.RenderTests/Shapes/PathTests.cs
index db1b11bb85..413d257297 100644
--- a/Tests/Perspex.RenderTests/Shapes/PathTests.cs
+++ b/Tests/Perspex.RenderTests/Shapes/PathTests.cs
@@ -41,7 +41,6 @@ namespace Perspex.Direct2D1.RenderTests.Shapes
this.CompareImages();
}
-
[Fact]
public void Path_Tick_Scaled()
{
@@ -65,6 +64,29 @@ namespace Perspex.Direct2D1.RenderTests.Shapes
this.CompareImages();
}
+ [Fact]
+ public void Path_Tick_Scaled_Stroke_8px()
+ {
+ Decorator target = new Decorator
+ {
+ Width = 200,
+ Height = 200,
+ Content = new Path
+ {
+ Fill = Brushes.Gray,
+ Stroke = Brushes.Red,
+ StrokeThickness = 8,
+ Stretch = Stretch.Uniform,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ Data = StreamGeometry.Parse("M 1145.607177734375,430 C1145.607177734375,430 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1138,434.5538330078125 1138,434.5538330078125 1138,434.5538330078125 1141.482177734375,438 1141.482177734375,438 1141.482177734375,438 1141.96875,437.9375 1141.96875,437.9375 1141.96875,437.9375 1147,431.34619140625 1147,431.34619140625 1147,431.34619140625 1145.607177734375,430 1145.607177734375,430 z"),
+ }
+ };
+
+ this.RenderToFile(target);
+ this.CompareImages();
+ }
+
[Fact]
public void Path_Expander_With_Border()
{
diff --git a/Tests/Perspex.RenderTests/TestBase.cs b/Tests/Perspex.RenderTests/TestBase.cs
index f64a3f5693..3cf61a04f9 100644
--- a/Tests/Perspex.RenderTests/TestBase.cs
+++ b/Tests/Perspex.RenderTests/TestBase.cs
@@ -70,7 +70,7 @@ namespace Perspex.Direct2D1.RenderTests
if (error > 0.02)
{
- Assert.True(false, "Error = " + error);
+ Assert.True(false, actualPath + ": Error = " + error);
}
}
}