csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
using Avalonia.Controls;
|
|
using Avalonia.UnitTests;
|
|
using Xunit;
|
|
|
|
namespace Avalonia.Input.UnitTests
|
|
{
|
|
public class InputElement_Focus
|
|
{
|
|
[Fact]
|
|
public void Focus_Should_Set_FocusManager_Current()
|
|
{
|
|
Button target;
|
|
|
|
using (UnitTestApplication.Start(TestServices.RealFocus))
|
|
{
|
|
var root = new TestRoot
|
|
{
|
|
Child = target = new Button()
|
|
};
|
|
|
|
target.Focus();
|
|
|
|
Assert.Same(target, FocusManager.Instance.Current);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Focus_Should_Be_Cleared_When_Control_Is_Removed_From_VisualTree()
|
|
{
|
|
Button target;
|
|
|
|
using (UnitTestApplication.Start(TestServices.RealFocus))
|
|
{
|
|
var root = new TestRoot
|
|
{
|
|
Child = target = new Button()
|
|
};
|
|
|
|
target.Focus();
|
|
root.Child = null;
|
|
|
|
Assert.Null(FocusManager.Instance.Current);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|