PolylineTests.cs 2.4 KB

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