LineTests.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 LineTests : TestBase
  17. {
  18. public LineTests()
  19. : base(@"Shapes\Line")
  20. {
  21. }
  22. [Fact]
  23. public async Task Line_1px_Stroke()
  24. {
  25. Decorator target = new Decorator
  26. {
  27. Width = 200,
  28. Height = 200,
  29. Child = new Line
  30. {
  31. Stroke = Brushes.Black,
  32. StrokeThickness = 1,
  33. StartPoint = new Point(0, 0),
  34. EndPoint = new Point(200, 200)
  35. }
  36. };
  37. await RenderToFile(target);
  38. CompareImages();
  39. }
  40. [Fact]
  41. public async Task Line_1px_Stroke_Reversed()
  42. {
  43. Decorator target = new Decorator
  44. {
  45. Width = 200,
  46. Height = 200,
  47. Child = new Line
  48. {
  49. Stroke = Brushes.Black,
  50. StrokeThickness = 1,
  51. StartPoint = new Point(200, 0),
  52. EndPoint = new Point(0, 200)
  53. }
  54. };
  55. await RenderToFile(target);
  56. CompareImages();
  57. }
  58. [Fact]
  59. public async Task Line_1px_Stroke_Vertical()
  60. {
  61. Decorator target = new Decorator
  62. {
  63. Width = 200,
  64. Height = 200,
  65. Child = new Line
  66. {
  67. Stroke = Brushes.Black,
  68. StrokeThickness = 1,
  69. StartPoint = new Point(100, 200),
  70. EndPoint = new Point(100, 0)
  71. }
  72. };
  73. await RenderToFile(target);
  74. CompareImages();
  75. }
  76. }
  77. }