fix: fix a ut after behavior change.

This commit is contained in:
Dong Bin
2025-02-19 22:28:26 +08:00
parent d6b50ce150
commit fa86d34e2b

View File

@@ -270,9 +270,18 @@ public class DatePickerTests
HorizontalAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top VerticalAlignment = VerticalAlignment.Top
}; };
window.Content = picker; var focustextBox = new TextBox();
window.Content = new StackPanel()
{
Children =
{
picker,
focustextBox,
}
};
window.Show(); window.Show();
Dispatcher.UIThread.RunJobs(); Dispatcher.UIThread.RunJobs();
picker.Focus();
var textBox = picker.GetTemplateChildOfType<TextBox>(DatePicker.PART_TextBox); var textBox = picker.GetTemplateChildOfType<TextBox>(DatePicker.PART_TextBox);
Dispatcher.UIThread.RunJobs(); Dispatcher.UIThread.RunJobs();
Assert.Null(picker.SelectedDate); Assert.Null(picker.SelectedDate);
@@ -280,6 +289,7 @@ public class DatePickerTests
Dispatcher.UIThread.RunJobs(); Dispatcher.UIThread.RunJobs();
Assert.Equal(new DateTime(2025, 2, 18), picker.SelectedDate); Assert.Equal(new DateTime(2025, 2, 18), picker.SelectedDate);
textBox?.SetValue(TextBox.TextProperty, "2025-02-18-"); textBox?.SetValue(TextBox.TextProperty, "2025-02-18-");
focustextBox.Focus();
Dispatcher.UIThread.RunJobs(); Dispatcher.UIThread.RunJobs();
Assert.Null(picker.SelectedDate); Assert.Null(picker.SelectedDate);
} }