From 186424b84858a5851bcd855e33a30188b31f6062 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Wed, 6 Nov 2024 18:44:49 +0800 Subject: [PATCH] fix: fix warnings in test related code. --- src/Ursa/Controls/PinCode/PinCode.cs | 3 ++- .../Controls/UrsaWindowTests/UrsaWindowTest.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Ursa/Controls/PinCode/PinCode.cs b/src/Ursa/Controls/PinCode/PinCode.cs index 4c9bc62..a04fb6d 100644 --- a/src/Ursa/Controls/PinCode/PinCode.cs +++ b/src/Ursa/Controls/PinCode/PinCode.cs @@ -162,10 +162,11 @@ public class PinCode: TemplatedControl protected async void OnPreviewKeyDown(KeyEventArgs e) { TextBox b = new TextBox(); - var pasteKeys = Application.Current?.PlatformSettings.HotkeyConfiguration.Paste; + var pasteKeys = Application.Current?.PlatformSettings?.HotkeyConfiguration.Paste; if (pasteKeys?.Any(a => a.Matches(e)) == true) { var clipboard = TopLevel.GetTopLevel(this)?.Clipboard; + if (clipboard is null) return; var text = await clipboard.GetTextAsync(); if (text is not null) { diff --git a/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs index 101e2d6..b0825c7 100644 --- a/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs +++ b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs @@ -17,7 +17,7 @@ public class UrsaWindowTest } [AvaloniaFact] - public async void Inferenced_Window_Closing_Called_Once_When_Yes() + public void Inferenced_Window_Closing_Called_Once_When_Yes() { var window = new UrsaWindowWithCloseInference(); window.Show(); @@ -29,7 +29,7 @@ public class UrsaWindowTest } [AvaloniaFact] - public async void Inferenced_Window_Closing_Called_Once_When_No() + public void Inferenced_Window_Closing_Called_Once_When_No() { var window = new UrsaWindowWithCloseInference(); window.Show();