|
|
|
@ -72,6 +72,37 @@ public class InputTests |
|
|
|
Assert.True(_window.Position == newWindowPosition); |
|
|
|
} |
|
|
|
|
|
|
|
#if NUNIT
|
|
|
|
[AvaloniaTest, Timeout(10000)] |
|
|
|
#elif XUNIT
|
|
|
|
[AvaloniaFact] |
|
|
|
#endif
|
|
|
|
public void Should_Click_Button_After_Explicit_RunJobs() |
|
|
|
{ |
|
|
|
// Regression test for https://github.com/AvaloniaUI/Avalonia/issues/20309
|
|
|
|
// Ensure that calling Dispatcher.UIThread.RunJobs() before MouseDown does not throw
|
|
|
|
var button = new Button { Content = "Test content" }; |
|
|
|
_window.Content = button; |
|
|
|
_window.Show(); |
|
|
|
|
|
|
|
Dispatcher.UIThread.RunJobs(); |
|
|
|
|
|
|
|
var clickCount = 0; |
|
|
|
button.Click += (_, _) => clickCount++; |
|
|
|
|
|
|
|
var point = new Point(button.Bounds.Width / 2, button.Bounds.Height / 2); |
|
|
|
var translatePoint = button.TranslatePoint(point, _window); |
|
|
|
|
|
|
|
// Move
|
|
|
|
_window.MouseMove(translatePoint!.Value, RawInputModifiers.None); |
|
|
|
|
|
|
|
// Click
|
|
|
|
_window.MouseDown(translatePoint.Value, MouseButton.Left, RawInputModifiers.None); |
|
|
|
_window.MouseUp(translatePoint.Value, MouseButton.Left, RawInputModifiers.None); |
|
|
|
|
|
|
|
Assert.True(clickCount == 1); |
|
|
|
} |
|
|
|
|
|
|
|
#if NUNIT
|
|
|
|
[TearDown] |
|
|
|
public void TearDown() |
|
|
|
|