GeometryClippingTests.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. Background = Brushes.Yellow,
  29. Clip = StreamGeometry.Parse("F1 M 0,0 H 76 V 76 Z"),
  30. Width = 76,
  31. Height = 76,
  32. Children = new Avalonia.Controls.Controls
  33. {
  34. new Path
  35. {
  36. Width = 32,
  37. Height = 40,
  38. [Canvas.LeftProperty] = 23,
  39. [Canvas.TopProperty] = 18,
  40. Stretch = Stretch.Fill,
  41. Fill = Brushes.Black,
  42. 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")
  43. }
  44. }
  45. };
  46. await RenderToFile(target);
  47. CompareImages();
  48. }
  49. }
  50. }