|
|
|
@ -17,6 +17,46 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
{ |
|
|
|
public class TextBoxTests |
|
|
|
{ |
|
|
|
[Fact] |
|
|
|
public void Opening_Context_Menu_Does_not_Loose_Selection() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(FocusServices)) |
|
|
|
{ |
|
|
|
var target1 = new TextBox |
|
|
|
{ |
|
|
|
Template = CreateTemplate(), |
|
|
|
Text = "1234", |
|
|
|
ContextMenu = new TestContextMenu() |
|
|
|
}; |
|
|
|
|
|
|
|
var target2 = new TextBox |
|
|
|
{ |
|
|
|
Template = CreateTemplate(), |
|
|
|
Text = "5678" |
|
|
|
}; |
|
|
|
|
|
|
|
var sp = new StackPanel(); |
|
|
|
sp.Children.Add(target1); |
|
|
|
sp.Children.Add(target2); |
|
|
|
|
|
|
|
target1.ApplyTemplate(); |
|
|
|
target2.ApplyTemplate(); |
|
|
|
|
|
|
|
var root = new TestRoot() { Child = sp }; |
|
|
|
|
|
|
|
target1.SelectionStart = 0; |
|
|
|
target1.SelectionEnd = 3; |
|
|
|
|
|
|
|
target1.Focus(); |
|
|
|
Assert.False(target2.IsFocused); |
|
|
|
Assert.True(target1.IsFocused); |
|
|
|
|
|
|
|
target2.Focus(); |
|
|
|
|
|
|
|
Assert.Equal("123", target1.SelectedText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void DefaultBindingMode_Should_Be_TwoWay() |
|
|
|
{ |
|
|
|
@ -694,5 +734,13 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
|
|
|
|
public Task<object> GetDataAsync(string format) => Task.FromResult((object)null); |
|
|
|
} |
|
|
|
|
|
|
|
private class TestContextMenu : ContextMenu |
|
|
|
{ |
|
|
|
public TestContextMenu() |
|
|
|
{ |
|
|
|
IsOpen = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|