-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Removing TapGestureRecognizer with at least 2 taps causes E…
…xception - fix (#21714) * [Android] Added null checks (#21437) * Updated test * Updated test * Update Issue21513.cs --------- Co-authored-by: Javier Suárez <[email protected]>
- Loading branch information
1 parent
fe89b55
commit 61e984e
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue21437" | ||
xmlns:issues="clr-namespace:Maui.Controls.Sample.Issues" | ||
Title="Issue21437"> | ||
<VerticalStackLayout BindableLayout.ItemsSource="{Binding Items}" HorizontalOptions="Start"> | ||
<BindableLayout.ItemTemplate> | ||
<DataTemplate> | ||
<Label Text="{Binding .}" AutomationId="{Binding .}" HorizontalOptions="Start"> | ||
<Label.GestureRecognizers> | ||
<TapGestureRecognizer | ||
NumberOfTapsRequired="2" | ||
Command="{Binding TapCommand, Source={RelativeSource AncestorType={x:Type issues:Issue21437}}}" | ||
CommandParameter="{Binding .}" /> | ||
</Label.GestureRecognizers> | ||
</Label> | ||
</DataTemplate> | ||
</BindableLayout.ItemTemplate> | ||
</VerticalStackLayout> | ||
</ContentPage> |
21 changes: 21 additions & 0 deletions
21
src/Controls/tests/TestCases.HostApp/Issues/Issue21437.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[Issue(IssueTracker.Github, 21437, "Removing TapGestureRecognizer with at least 2 taps causes Exception", PlatformAffected.Android)] | ||
|
||
public partial class Issue21437 : ContentPage | ||
{ | ||
public ObservableCollection<string> Items { get; } = new() { "Item1", "Item2", "Item3" }; | ||
|
||
public Command TapCommand => new Command<string>(obj => | ||
{ | ||
Items.Remove(obj); | ||
}); | ||
|
||
public Issue21437() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = this; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21437.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#if ANDROID | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.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] | ||
[Category(UITestCategories.Gestures)] | ||
public void ExceptionShouldNotBeThrown() | ||
{ | ||
_ = App.WaitForElement("Item2"); | ||
App.DoubleClick("Item2"); | ||
|
||
//The test passes if no exception is thrown | ||
} | ||
} | ||
#endif |