-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Added null checks (#21437)
- Loading branch information
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/Controls/samples/Controls.Sample.UITests/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> |
24 changes: 24 additions & 0 deletions
24
src/Controls/samples/Controls.Sample.UITests/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,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<string> Items { get; } = new() { "Item1", "Item2", "Item3" }; | ||
|
||
public Command TapCommand => new Command<string>(obj => | ||
{ | ||
Items.Remove(obj); | ||
}); | ||
|
||
public Issue21437() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = this; | ||
} | ||
} |
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
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,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 | ||
} | ||
} |