InputExtensionsTests.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Avalonia.Controls;
  2. using Avalonia.Input;
  3. using Avalonia.Layout;
  4. using Avalonia.Media;
  5. using Avalonia.UnitTests;
  6. using Xunit;
  7. namespace Avalonia.Base.UnitTests.Input;
  8. public class InputExtensionsTests
  9. {
  10. [Fact]
  11. public void InputHitTest_Should_Use_Coordinates_Relative_To_The_Subtree_Root()
  12. {
  13. Border target;
  14. using var services = new CompositorTestServices(new Size(200, 200))
  15. {
  16. TopLevel =
  17. {
  18. Content = new StackPanel
  19. {
  20. Background = Brushes.White,
  21. Children =
  22. {
  23. new Border
  24. {
  25. Width = 100,
  26. Height = 200,
  27. Background = Brushes.Red,
  28. },
  29. (target = new Border
  30. {
  31. Width = 100,
  32. Height = 200,
  33. Background = Brushes.Green,
  34. })
  35. },
  36. Orientation = Orientation.Horizontal,
  37. }
  38. }
  39. };
  40. services.RunJobs();
  41. var result = target.InputHitTest(new Point(50, 50), enabledElementsOnly: false);
  42. Assert.Same(target, result);
  43. }
  44. }