Browse Source

Failing unit tests for ComboBox losing focus on detach and Popup.Close raising Closed events for already closed popup.

pull/3492/head
Dariusz Komosinski 6 years ago
parent
commit
01d26ed2ee
  1. 31
      tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs
  2. 28
      tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs

31
tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs

@ -108,5 +108,36 @@ namespace Avalonia.Controls.UnitTests
};
});
}
[Fact]
public void Detaching_Closed_ComboBox_Keeps_Current_Focus()
{
using (UnitTestApplication.Start(TestServices.RealFocus))
{
var target = new ComboBox
{
Items = new[] { new Canvas() },
SelectedIndex = 0,
Template = GetTemplate(),
};
var other = new Control { Focusable = true };
StackPanel panel;
var root = new TestRoot { Child = panel = new StackPanel { Children = { target, other } } };
target.ApplyTemplate();
target.Presenter.ApplyTemplate();
other.Focus();
Assert.True(other.IsFocused);
panel.Children.Remove(target);
Assert.True(other.IsFocused);
}
}
}
}

28
tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs

@ -223,7 +223,33 @@ namespace Avalonia.Controls.UnitTests.Primitives
}
}
[Fact]
public void Popup_Close_On_Closed_Popup_Should_Not_Raise_Closed_Event()
{
using (CreateServices())
{
var window = PreparedWindow();
var target = new Popup() { PlacementMode = PlacementMode.Pointer };
window.Content = target;
window.ApplyTemplate();
int closedCount = 0;
target.Closed += (sender, args) =>
{
closedCount++;
};
target.Close();
target.Close();
target.Close();
target.Close();
Assert.Equal(0, closedCount);
}
}
[Fact]
public void Templated_Control_With_Popup_In_Template_Should_Set_TemplatedParent()
{

Loading…
Cancel
Save