GeometryClippingTests.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Avalonia.Controls;
  2. using Avalonia.Controls.Shapes;
  3. using Avalonia.Media;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. using Xunit;
  8. using System.Threading.Tasks;
  9. #if AVALONIA_CAIRO
  10. namespace Avalonia.Cairo.RenderTests
  11. #elif AVALONIA_SKIA
  12. namespace Avalonia.Skia.RenderTests
  13. #else
  14. namespace Avalonia.Direct2D1.RenderTests
  15. #endif
  16. {
  17. public class GeometryClippingTests : TestBase
  18. {
  19. public GeometryClippingTests()
  20. :base("GeometryClipping")
  21. {
  22. }
  23. [Fact]
  24. public async Task Geometry_Clip_Clips_Path()
  25. {
  26. var target = new Canvas
  27. {
  28. Clip = StreamGeometry.Parse("F1 M 0,0 H 76 V 76 Z"),
  29. Width = 76,
  30. Height = 76,
  31. Children = new Avalonia.Controls.Controls
  32. {
  33. new Path
  34. {
  35. Width = 32,
  36. Height = 40,
  37. [Canvas.LeftProperty] = 23,
  38. [Canvas.TopProperty] = 18,
  39. Stretch = Stretch.Fill,
  40. Fill = Brushes.Black,
  41. Data = StreamGeometry.Parse("F1 M 27,18L 23,26L 33,30L 24,38L 33,46L 23,50L 27,58L 45,58L 55,38L 45,18L 27,18 Z")
  42. }
  43. }
  44. };
  45. await RenderToFile(target);
  46. CompareImages();
  47. }
  48. }
  49. }