|
|
|
@ -1844,27 +1844,29 @@ namespace Avalonia.Controls.UnitTests.Primitives |
|
|
|
} |
|
|
|
|
|
|
|
[Fact(Timeout = 2000)] |
|
|
|
public async Task MoveSelection_Wrap_Does_Not_Hang_With_No_Focusable_Controls() |
|
|
|
{ |
|
|
|
// Issue #3094.
|
|
|
|
var target = new TestSelector |
|
|
|
public Task MoveSelection_Wrap_Does_Not_Hang_With_No_Focusable_Controls() => |
|
|
|
// Timeout in xUnit doesn't work with synchronous methods so we need to apply hack below.
|
|
|
|
// https://github.com/xunit/xunit/issues/2222
|
|
|
|
ThreadRunHelper.RunOnDedicatedThread(() => |
|
|
|
{ |
|
|
|
Template = Template(), |
|
|
|
Items = |
|
|
|
using var _ = UnitTestApplication.Start(); |
|
|
|
// Issue #3094.
|
|
|
|
var target = new TestSelector |
|
|
|
{ |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
}, |
|
|
|
SelectedIndex = 0, |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
Template = Template(), |
|
|
|
Items = |
|
|
|
{ |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
}, |
|
|
|
SelectedIndex = 0, |
|
|
|
}; |
|
|
|
|
|
|
|
// Timeout in xUnit doesn't work with synchronous methods so we need to apply hack below.
|
|
|
|
// https://github.com/xunit/xunit/issues/2222
|
|
|
|
await Task.Run(() => target.MoveSelection(NavigationDirection.Next, true)); |
|
|
|
} |
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
target.MoveSelection(NavigationDirection.Next, true); |
|
|
|
}); |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void MoveSelection_Skips_Non_Focusable_Controls_When_Moving_To_Last_Item() |
|
|
|
@ -1907,50 +1909,54 @@ namespace Avalonia.Controls.UnitTests.Primitives |
|
|
|
} |
|
|
|
|
|
|
|
[Fact(Timeout = 2000)] |
|
|
|
public async Task MoveSelection_Does_Not_Hang_When_All_Items_Are_Non_Focusable_And_We_Move_To_First_Item() |
|
|
|
{ |
|
|
|
var target = new TestSelector |
|
|
|
{ |
|
|
|
Template = Template(), |
|
|
|
Items = |
|
|
|
{ |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
public Task MoveSelection_Does_Not_Hang_When_All_Items_Are_Non_Focusable_And_We_Move_To_First_Item() => |
|
|
|
// Timeout in xUnit doesn't work with synchronous methods so we need to apply hack below.
|
|
|
|
// https://github.com/xunit/xunit/issues/2222
|
|
|
|
await Task.Run(() => target.MoveSelection(NavigationDirection.First, true)); |
|
|
|
ThreadRunHelper.RunOnDedicatedThread( |
|
|
|
() => |
|
|
|
{ |
|
|
|
using var _ = UnitTestApplication.Start(); |
|
|
|
var target = new TestSelector |
|
|
|
{ |
|
|
|
Template = Template(), |
|
|
|
Items = |
|
|
|
{ |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
Assert.Equal(-1, target.SelectedIndex); |
|
|
|
} |
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
target.MoveSelection(NavigationDirection.First, true); |
|
|
|
|
|
|
|
Assert.Equal(-1, target.SelectedIndex); |
|
|
|
}); |
|
|
|
|
|
|
|
[Fact(Timeout = 2000)] |
|
|
|
public async Task MoveSelection_Does_Not_Hang_When_All_Items_Are_Non_Focusable_And_We_Move_To_Last_Item() |
|
|
|
{ |
|
|
|
var target = new TestSelector |
|
|
|
public Task MoveSelection_Does_Not_Hang_When_All_Items_Are_Non_Focusable_And_We_Move_To_Last_Item() |
|
|
|
// Timeout in xUnit doesn't work with synchronous methods so we need to apply hack below.
|
|
|
|
// https://github.com/xunit/xunit/issues/2222
|
|
|
|
=> ThreadRunHelper.RunOnDedicatedThread(() => |
|
|
|
{ |
|
|
|
Template = Template(), |
|
|
|
Items = |
|
|
|
var target = new TestSelector |
|
|
|
{ |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
Template = Template(), |
|
|
|
Items = |
|
|
|
{ |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
new ListBoxItem { Focusable = false }, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// Timeout in xUnit doesn't work with synchronous methods so we need to apply hack below.
|
|
|
|
// https://github.com/xunit/xunit/issues/2222
|
|
|
|
await Task.Run(() => target.MoveSelection(NavigationDirection.Last, true)); |
|
|
|
target.Measure(new Size(100, 100)); |
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
target.MoveSelection(NavigationDirection.Last, true); |
|
|
|
|
|
|
|
Assert.Equal(-1, target.SelectedIndex); |
|
|
|
} |
|
|
|
Assert.Equal(-1, target.SelectedIndex); |
|
|
|
}); |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void MoveSelection_Does_Select_Disabled_Controls() |
|
|
|
@ -2247,9 +2253,7 @@ namespace Avalonia.Controls.UnitTests.Primitives |
|
|
|
[Fact] |
|
|
|
public void Setting_IsTextSearchEnabled_Enables_Or_Disables_Text_Search() |
|
|
|
{ |
|
|
|
var pti = Mock.Of<IDispatcherImpl>(x => x.CurrentThreadIsLoopThread == true); |
|
|
|
|
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow.With(dispatcherImpl: pti))) |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow.With())) |
|
|
|
{ |
|
|
|
var items = new[] |
|
|
|
{ |
|
|
|
|