fix: fix various nullable warning issues in test project.
This commit is contained in:
@@ -7,7 +7,6 @@ using Avalonia.Input;
|
|||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
using Avalonia.LogicalTree;
|
using Avalonia.LogicalTree;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Avalonia.VisualTree;
|
|
||||||
using HeadlessTest.Ursa.TestHelpers;
|
using HeadlessTest.Ursa.TestHelpers;
|
||||||
using Ursa.Controls;
|
using Ursa.Controls;
|
||||||
using DatePicker = Ursa.Controls.DatePicker;
|
using DatePicker = Ursa.Controls.DatePicker;
|
||||||
@@ -176,7 +175,7 @@ public class DatePickerTests
|
|||||||
window.MouseDown(new Point(10, 10), MouseButton.Left);
|
window.MouseDown(new Point(10, 10), MouseButton.Left);
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
var popup = picker.GetTemplateChildOfType<Popup>(DatePicker.PART_Popup);
|
var popup = picker.GetTemplateChildOfType<Popup>(DatePicker.PART_Popup);
|
||||||
var calendar = popup.GetLogicalDescendants().OfType<CalendarView>().FirstOrDefault();
|
var calendar = popup?.GetLogicalDescendants().OfType<CalendarView>().FirstOrDefault();
|
||||||
calendar?.RaiseEvent(new CalendarDayButtonEventArgs(new DateTime(2025, 2, 17))
|
calendar?.RaiseEvent(new CalendarDayButtonEventArgs(new DateTime(2025, 2, 17))
|
||||||
{ RoutedEvent = CalendarView.DateSelectedEvent });
|
{ RoutedEvent = CalendarView.DateSelectedEvent });
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
@@ -203,7 +202,7 @@ public class DatePickerTests
|
|||||||
window.MouseDown(new Point(10, 10), MouseButton.Left);
|
window.MouseDown(new Point(10, 10), MouseButton.Left);
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
var popup = picker.GetTemplateChildOfType<Popup>(DatePicker.PART_Popup);
|
var popup = picker.GetTemplateChildOfType<Popup>(DatePicker.PART_Popup);
|
||||||
var calendar = popup.GetLogicalDescendants().OfType<CalendarView>().FirstOrDefault();
|
var calendar = popup?.GetLogicalDescendants().OfType<CalendarView>().FirstOrDefault();
|
||||||
calendar?.RaiseEvent(new CalendarDayButtonEventArgs(new DateTime(2025, 2, 17))
|
calendar?.RaiseEvent(new CalendarDayButtonEventArgs(new DateTime(2025, 2, 17))
|
||||||
{ RoutedEvent = CalendarView.DateSelectedEvent });
|
{ RoutedEvent = CalendarView.DateSelectedEvent });
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
@@ -270,13 +269,13 @@ public class DatePickerTests
|
|||||||
HorizontalAlignment = HorizontalAlignment.Left,
|
HorizontalAlignment = HorizontalAlignment.Left,
|
||||||
VerticalAlignment = VerticalAlignment.Top
|
VerticalAlignment = VerticalAlignment.Top
|
||||||
};
|
};
|
||||||
var focustextBox = new TextBox();
|
var focusTextBox = new TextBox();
|
||||||
window.Content = new StackPanel()
|
window.Content = new StackPanel()
|
||||||
{
|
{
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
picker,
|
picker,
|
||||||
focustextBox,
|
focusTextBox,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.Show();
|
window.Show();
|
||||||
@@ -289,7 +288,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();
|
focusTextBox.Focus();
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
Assert.Null(picker.SelectedDate);
|
Assert.Null(picker.SelectedDate);
|
||||||
}
|
}
|
||||||
@@ -356,7 +355,6 @@ public class DatePickerTests
|
|||||||
var position = nextButton.TranslatePoint(new Point(5, 5), window);
|
var position = nextButton.TranslatePoint(new Point(5, 5), window);
|
||||||
Assert.NotNull(position);
|
Assert.NotNull(position);
|
||||||
window.MouseDown(new Point(10, 10), MouseButton.Left);
|
window.MouseDown(new Point(10, 10), MouseButton.Left);
|
||||||
var renderRoot = popup.GetVisualRoot();
|
|
||||||
|
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
Assert.True(picker.IsDropdownOpen);
|
Assert.True(picker.IsDropdownOpen);
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
using System;
|
using Avalonia.Controls;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Interactivity;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Ursa.Controls;
|
using Ursa.Controls;
|
||||||
|
|
||||||
namespace HeadlessTest.Ursa.Controls;
|
namespace HeadlessTest.Ursa.Controls;
|
||||||
@@ -19,7 +12,7 @@ public partial class DrawerCloseTestPopupControl : UserControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly string _hostid = Path.GetRandomFileName();
|
private readonly string _hostid = Path.GetRandomFileName();
|
||||||
public DrawerCloseTestPopupControl Popup { get; set; }
|
public DrawerCloseTestPopupControl? Popup { get; set; }
|
||||||
public int LResult { get; set; }
|
public int LResult { get; set; }
|
||||||
public int RResult { get; set; }
|
public int RResult { get; set; }
|
||||||
|
|
||||||
@@ -32,7 +25,7 @@ public partial class DrawerCloseTestPopupControl : UserControl
|
|||||||
|
|
||||||
public void ClosePopup()
|
public void ClosePopup()
|
||||||
{
|
{
|
||||||
(Popup.DataContext as DrawerCloseTestPopupControlVM)?.Close();
|
(Popup?.DataContext as DrawerCloseTestPopupControlVM)?.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class DrawerMeasureTest
|
|||||||
};
|
};
|
||||||
window.Show();
|
window.Show();
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
Drawer.ShowModal(textBlock, "hello world", null,
|
_ = Drawer.ShowModal(textBlock, "hello world", null,
|
||||||
new DrawerOptions { Position = position, TopLevelHashCode = window.GetHashCode() });
|
new DrawerOptions { Position = position, TopLevelHashCode = window.GetHashCode() });
|
||||||
await Task.Delay(TimeSpan.FromSeconds(0.1));
|
await Task.Delay(TimeSpan.FromSeconds(0.1));
|
||||||
var dialogControl = window.GetVisualDescendants().OfType<DefaultDrawerControl>().SingleOrDefault();
|
var dialogControl = window.GetVisualDescendants().OfType<DefaultDrawerControl>().SingleOrDefault();
|
||||||
@@ -57,7 +57,6 @@ public class DrawerMeasureTest
|
|||||||
};
|
};
|
||||||
window.Show();
|
window.Show();
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
var d = window.GetVisualDescendants().ToList();
|
|
||||||
Drawer.ShowCustom(textBlock, "hello world", null,
|
Drawer.ShowCustom(textBlock, "hello world", null,
|
||||||
new DrawerOptions { Position = position, TopLevelHashCode = window.GetHashCode() });
|
new DrawerOptions { Position = position, TopLevelHashCode = window.GetHashCode() });
|
||||||
await Task.Delay(TimeSpan.FromSeconds(0.1));
|
await Task.Delay(TimeSpan.FromSeconds(0.1));
|
||||||
|
|||||||
Reference in New Issue
Block a user