PolylineTests.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System.Threading.Tasks;
  4. using Avalonia.Controls;
  5. using Avalonia.Controls.Shapes;
  6. using Avalonia.Media;
  7. using Xunit;
  8. #if AVALONIA_CAIRO
  9. namespace Avalonia.Cairo.RenderTests.Shapes
  10. #elif AVALONIA_SKIA
  11. namespace Avalonia.Skia.RenderTests
  12. #else
  13. namespace Avalonia.Direct2D1.RenderTests.Shapes
  14. #endif
  15. {
  16. public class PolylineTests : TestBase
  17. {
  18. public PolylineTests()
  19. : base(@"Shapes\Polyline")
  20. {
  21. }
  22. #if AVALONIA_CAIRO
  23. [Fact(Skip = "Caused by cairo bug")]
  24. #elif AVALONIA_SKIA_SKIP_FAIL
  25. [Fact(Skip = "Waiting for https://github.com/mono/SkiaSharp/pull/63")]
  26. #else
  27. [Fact]
  28. #endif
  29. public async Task Polyline_1px_Stroke()
  30. {
  31. var polylinePoints = new Point[] { new Point(0, 0), new Point(5, 0), new Point(6, -2), new Point(7, 3), new Point(8, -3),
  32. new Point(9, 1), new Point(10, 0), new Point(15, 0) };
  33. Decorator target = new Decorator
  34. {
  35. Padding = new Thickness(8),
  36. Width = 400,
  37. Height = 200,
  38. Child = new Polyline
  39. {
  40. Stroke = Brushes.Brown,
  41. Points = polylinePoints,
  42. Stretch = Stretch.Uniform,
  43. StrokeThickness = 1
  44. }
  45. };
  46. await RenderToFile(target);
  47. CompareImages();
  48. }
  49. #if AVALONIA_CAIRO
  50. [Fact(Skip = "Caused by cairo bug")]
  51. #elif AVALONIA_SKIA_SKIP_FAIL
  52. [Fact(Skip = "Waiting for https://github.com/mono/SkiaSharp/pull/63")]
  53. #else
  54. [Fact]
  55. #endif
  56. public async Task Polyline_10px_Stroke_PenLineJoin()
  57. {
  58. var polylinePoints = new Point[] { new Point(0, 0), new Point(5, 0), new Point(6, -2), new Point(7, 3), new Point(8, -3),
  59. new Point(9, 1), new Point(10, 0), new Point(15, 0) };
  60. Decorator target = new Decorator
  61. {
  62. Padding = new Thickness(8),
  63. Width = 400,
  64. Height = 200,
  65. Child = new Polyline
  66. {
  67. Stroke = Brushes.Brown,
  68. Points = polylinePoints,
  69. Stretch = Stretch.Uniform,
  70. StrokeJoin = PenLineJoin.Round,
  71. StrokeStartLineCap = PenLineCap.Round,
  72. StrokeEndLineCap = PenLineCap.Round,
  73. StrokeThickness = 10
  74. }
  75. };
  76. await RenderToFile(target);
  77. CompareImages();
  78. }
  79. }
  80. }