Browse Source
* Add regression test for subtree input hit testing * Fix subtree input hit test coordinatespull/20366/merge
committed by
GitHub
3 changed files with 52 additions and 12 deletions
@ -0,0 +1,49 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Input; |
|||
using Avalonia.Layout; |
|||
using Avalonia.Media; |
|||
using Avalonia.UnitTests; |
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Base.UnitTests.Input; |
|||
|
|||
public class InputExtensionsTests |
|||
{ |
|||
[Fact] |
|||
public void InputHitTest_Should_Use_Coordinates_Relative_To_The_Subtree_Root() |
|||
{ |
|||
Border target; |
|||
using var services = new CompositorTestServices(new Size(200, 200)) |
|||
{ |
|||
TopLevel = |
|||
{ |
|||
Content = new StackPanel |
|||
{ |
|||
Background = Brushes.White, |
|||
Children = |
|||
{ |
|||
new Border |
|||
{ |
|||
Width = 100, |
|||
Height = 200, |
|||
Background = Brushes.Red, |
|||
}, |
|||
(target = new Border |
|||
{ |
|||
Width = 100, |
|||
Height = 200, |
|||
Background = Brushes.Green, |
|||
}) |
|||
}, |
|||
Orientation = Orientation.Horizontal, |
|||
} |
|||
} |
|||
}; |
|||
|
|||
services.RunJobs(); |
|||
|
|||
var result = target.InputHitTest(new Point(50, 50), enabledElementsOnly: false); |
|||
|
|||
Assert.Same(target, result); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue