From 29dc1a2aef803fac59a873a6cf8a84d2100dbaa4 Mon Sep 17 00:00:00 2001 From: Jakub Florkowski Date: Tue, 9 Apr 2024 00:47:59 +0200 Subject: [PATCH 1/4] [Android] Added null checks (#21437) --- .../Platform/Android/InnerGestureListener.cs | 2 +- .../TestCases.HostApp/Issues/Issue21437.xaml | 21 ++++++++++++++++ .../Issues/Issue21437.xaml.cs | 24 +++++++++++++++++++ .../Tests/Issues/Issue21437.cs | 23 ++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs diff --git a/src/Controls/src/Core/Platform/Android/InnerGestureListener.cs b/src/Controls/src/Core/Platform/Android/InnerGestureListener.cs index 5d9d1ced94aa..9c6ef68c7f14 100644 --- a/src/Controls/src/Core/Platform/Android/InnerGestureListener.cs +++ b/src/Controls/src/Core/Platform/Android/InnerGestureListener.cs @@ -62,7 +62,7 @@ public InnerGestureListener( bool HasAnyGestures() { - return _panGestureHandler.HasAnyGestures() || _tapGestureHandler.HasAnyGestures() || _swipeGestureHandler.HasAnyGestures(); + return (_panGestureHandler?.HasAnyGestures() ?? false) || (_tapGestureHandler?.HasAnyGestures() ?? false) || (_swipeGestureHandler?.HasAnyGestures() ?? false); } // This is needed because GestureRecognizer callbacks can be delayed several hundred milliseconds diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml new file mode 100644 index 000000000000..d54f9cee7400 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs new file mode 100644 index 000000000000..89ddb090ea80 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs @@ -0,0 +1,24 @@ +using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Xaml; +using System.Collections.ObjectModel; + +namespace Maui.Controls.Sample.Issues; + +[XamlCompilation(XamlCompilationOptions.Compile)] +[Issue(IssueTracker.Github, 21437, "Removing TapGestureRecognizer with at least 2 taps causes Exception", PlatformAffected.Android)] + +public partial class Issue21437 : ContentPage +{ + public ObservableCollection Items { get; } = new() { "Item1", "Item2", "Item3" }; + + public Command TapCommand => new Command(obj => + { + Items.Remove(obj); + }); + + public Issue21437() + { + InitializeComponent(); + BindingContext = this; + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs new file mode 100644 index 000000000000..ff4fe0abd8ad --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs @@ -0,0 +1,23 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.AppiumTests.Issues; + +public class Issue21437 : _IssuesUITest +{ + public override string Issue => "Removing TapGestureRecognizer with at least 2 taps causes Exception"; + + public Issue21437(TestDevice device) + : base(device) + { } + + [Test] + public void ExceptionShouldNotBeThrown() + { + _ = App.WaitForElement("Item2"); + App.DoubleClick("Item2"); + + //The test passes if no exception is thrown + } +} From 037a2fe20aac01c6d588d0409fa32831cd629a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Mon, 10 Jun 2024 16:26:11 +0200 Subject: [PATCH 2/4] Updated test --- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs index ff4fe0abd8ad..1015b505d49e 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs @@ -2,7 +2,7 @@ using UITest.Appium; using UITest.Core; -namespace Microsoft.Maui.AppiumTests.Issues; +namespace Microsoft.Maui.TestCases.Tests.Issues; public class Issue21437 : _IssuesUITest { From 4ab602ba1ed7178ef50406607611b6acfe6a685a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Tue, 11 Jun 2024 13:14:44 +0200 Subject: [PATCH 3/4] Updated test --- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs index 1015b505d49e..75e2f3af543a 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if ANDROID +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -21,3 +22,4 @@ public void ExceptionShouldNotBeThrown() //The test passes if no exception is thrown } } +#endif \ No newline at end of file From f89cd1b9a63f97744f8baf53d4ac6aa36a0e0b05 Mon Sep 17 00:00:00 2001 From: Jakub Florkowski Date: Sat, 17 Aug 2024 00:23:12 +0200 Subject: [PATCH 4/4] Update Issue21513.cs --- src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs | 3 --- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs index 89ddb090ea80..ee9b934a4c5f 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs @@ -1,10 +1,7 @@ -using Microsoft.Maui.Controls; -using Microsoft.Maui.Controls.Xaml; using System.Collections.ObjectModel; namespace Maui.Controls.Sample.Issues; -[XamlCompilation(XamlCompilationOptions.Compile)] [Issue(IssueTracker.Github, 21437, "Removing TapGestureRecognizer with at least 2 taps causes Exception", PlatformAffected.Android)] public partial class Issue21437 : ContentPage diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs index 75e2f3af543a..ca7396e9c686 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs @@ -14,6 +14,7 @@ public Issue21437(TestDevice device) { } [Test] + [Category(UITestCategories.Gestures)] public void ExceptionShouldNotBeThrown() { _ = App.WaitForElement("Item2");