Browse Source

Added tests for absolute and relative path commands.

Some of the tests are currently failing.
Steven Kirk 9 years ago
parent
commit
43e82e4e14

+ 214 - 0
tests/Avalonia.RenderTests/Shapes/PathTests.cs

@@ -24,6 +24,220 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes
         {
         }
 
+        [Fact]
+        public void Line_Absolute()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M 10,190 L 190,10 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void Line_Relative()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M10,190 l190,-190 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void HorizontalLine_Absolute()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M190,100 H10 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void HorizontalLine_Relative()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M190,100 h-180 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void VerticalLine_Absolute()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M100,190 V10 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void VerticalLine_Relative()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M100,190 V-180 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void CubicBezier_Absolute()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Fill = Brushes.Gray,
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M190,0 C10,10 190,190 10,190 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void CubicBezier_Relative()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Fill = Brushes.Gray,
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M190,0 c-180,10 0,190 -180,190 M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void Arc_Absolute()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Fill = Brushes.Gray,
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M190,100 A90,90 0 1,0 10,100  M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
+        [Fact]
+        public void Arc_Relative()
+        {
+            Decorator target = new Decorator
+            {
+                Width = 200,
+                Height = 200,
+                Child = new Path
+                {
+                    Fill = Brushes.Gray,
+                    Stroke = Brushes.Red,
+                    StrokeThickness = 1,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                    Data = StreamGeometry.Parse("M190,100 a90,90 0 1,0 -180,0  M0,0M200,200"),
+                }
+            };
+
+            RenderToFile(target);
+            CompareImages();
+        }
+
         [Fact]
         public void Path_100px_Triangle_Centered()
         {

BIN
tests/TestFiles/Direct2D1/Shapes/Path/Arc_Absolute.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/Arc_Relative.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/CubicBezier_Absolute.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/CubicBezier_Relative.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/HorizontalLine_Absolute.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/HorizontalLine_Relative.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/Line_Absolute.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/Line_Relative.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/VerticalLine_Absolute.expected.png


BIN
tests/TestFiles/Direct2D1/Shapes/Path/VerticalLine_Relative.expected.png