From 2a243c90f5d41af9ff50113cf0d8a31352cf3819 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 4 Dec 2024 16:28:17 +0100 Subject: [PATCH 1/4] feat: Allow simulating touch input in Samples app --- .../Presentation/SampleChooserViewMode.Properties.cs | 11 +++++++++++ .../UITests/Views/Controls/SampleChooserControl.xaml | 5 +++++ src/Uno.UWP/Devices/Input/PointerDevice.cs | 8 ++++++++ .../FeatureConfiguration/WinRTFeatureConfiguration.cs | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs index c2937137c60b..472179de116e 100644 --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs @@ -25,6 +25,7 @@ using Uno.UI.Xaml.Core; using WinUICoreServices = Uno.UI.Xaml.Core.CoreServices; using Uno.UI; +using Uno; #endif namespace SampleControl.Presentation @@ -448,6 +449,16 @@ public bool UseRtl } } + public bool SimulateTouch + { + get => WinRTFeatureConfiguration.DebugOptions.SimulateTouch; + set + { + WinRTFeatureConfiguration.DebugOptions.SimulateTouch = value; + RaisePropertyChanged(); + } + } + #if HAS_UNO public bool PreventLightDismissOnWindowDeactivated { diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Controls/SampleChooserControl.xaml b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Controls/SampleChooserControl.xaml index f6b720d11032..ea8c4821a919 100644 --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Controls/SampleChooserControl.xaml +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Controls/SampleChooserControl.xaml @@ -573,6 +573,11 @@ + + + + + diff --git a/src/Uno.UWP/Devices/Input/PointerDevice.cs b/src/Uno.UWP/Devices/Input/PointerDevice.cs index d5370fb7f7ea..e434727b98d1 100644 --- a/src/Uno.UWP/Devices/Input/PointerDevice.cs +++ b/src/Uno.UWP/Devices/Input/PointerDevice.cs @@ -1,4 +1,5 @@ using System.Runtime.Serialization.Formatters; +using Uno; namespace Windows.Devices.Input { @@ -10,6 +11,13 @@ public partial class PointerDevice internal static PointerDevice For(PointerDeviceType type) { +#if DEBUG + if (WinRTFeatureConfiguration.DebugOptions.SimulateTouch) + { + type = PointerDeviceType.Touch; + } +#endif + // We cache them as we don't implement any other properties than the PointerDeviceType // but this is probably not really valid... switch (type) diff --git a/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs b/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs index 22fd4c4d4d5b..59e1c9568650 100644 --- a/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs +++ b/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs @@ -45,4 +45,12 @@ public static class StoreContext public static bool TestMode { get; set; } } #endif + + internal static class DebugOptions + { + /// + /// Adjusts all PointerPoint instances as if they were of type Touch. + /// + public static bool SimulateTouch { get; set; } + } } From ddf132e2c8e7051e2f7435f0eeb1902d7865355e Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 4 Dec 2024 23:52:26 +0100 Subject: [PATCH 2/4] chore: Adjust WinUI build --- .../UITests/Presentation/SampleChooserViewMode.Properties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs index 472179de116e..98689c22f676 100644 --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs @@ -449,6 +449,7 @@ public bool UseRtl } } +#if HAS_UNO public bool SimulateTouch { get => WinRTFeatureConfiguration.DebugOptions.SimulateTouch; @@ -459,7 +460,6 @@ public bool SimulateTouch } } -#if HAS_UNO public bool PreventLightDismissOnWindowDeactivated { get => FeatureConfiguration.Popup.PreventLightDismissOnWindowDeactivated; From aa04c5c406c931ee58d88f7134a4bf0e26816c1d Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Thu, 5 Dec 2024 11:27:26 +0100 Subject: [PATCH 3/4] chore: Address comment Co-authored-by: Youssef Victor --- .../Presentation/SampleChooserViewMode.Properties.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs index 98689c22f676..ae8ff1259625 100644 --- a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs +++ b/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs @@ -452,11 +452,17 @@ public bool UseRtl #if HAS_UNO public bool SimulateTouch { +#if DEBUG get => WinRTFeatureConfiguration.DebugOptions.SimulateTouch; +#else + get => false; +#endif set { +#if DEBUG WinRTFeatureConfiguration.DebugOptions.SimulateTouch = value; RaisePropertyChanged(); +#endif } } From 1c58db9ce136b2aacdf9aff035889a72d6001d76 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Thu, 5 Dec 2024 11:28:54 +0100 Subject: [PATCH 4/4] chore: Keep debug flags debug only --- src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs b/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs index 59e1c9568650..d18e6a7ee8c9 100644 --- a/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs +++ b/src/Uno.UWP/FeatureConfiguration/WinRTFeatureConfiguration.cs @@ -46,6 +46,7 @@ public static class StoreContext } #endif +#if DEBUG internal static class DebugOptions { /// @@ -53,4 +54,5 @@ internal static class DebugOptions /// public static bool SimulateTouch { get; set; } } +#endif }