forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21837.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,93 @@ | ||
<?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.Issue21837" | ||
Title="Issue21837"> | ||
|
||
<VerticalStackLayout HorizontalOptions="Start" Spacing="10"> | ||
<Label AutomationId="resultLabel" Text="{Binding TapCount, StringFormat='Number of recognized taps: {0}'}" FontSize="30" FontAttributes="Bold" /> | ||
|
||
<Label Text="Single line, progressively limited width:" FontSize="20" FontAttributes="Bold" /> | ||
|
||
<Label AutomationId="label1" HorizontalOptions="Start" MaxLines="1" BackgroundColor="LightCyan" WidthRequest="600"> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Only our WidthRequests differ. Otherwise we're the same. Please tap us!"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding TapCommand}" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
<Label AutomationId="label2" HorizontalOptions="Start" MaxLines="1" BackgroundColor="LightCyan" WidthRequest="500"> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Only our WidthRequests differ. Otherwise we're the same. Please tap us!"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding TapCommand}" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
<Label AutomationId="label3" HorizontalOptions="Start" MaxLines="1" LineBreakMode="TailTruncation" BackgroundColor="LightCyan" > | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Only our WidthRequests differ. Otherwise we're the same. Please tap us!"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding TapCommand}" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
<Label AutomationId="label4" HorizontalOptions="Start" MaxLines="1" BackgroundColor="LightCyan" WidthRequest="300"> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Only our WidthRequests differ. Otherwise we're the same. Please tap us!"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding TapCommand}" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
|
||
<Label Text="Limited width, progressively limited lines:" FontSize="20" FontAttributes="Bold" /> | ||
|
||
<Label AutomationId="label5" HorizontalOptions="Start" MaxLines="7" BackgroundColor="LightGoldenrodYellow" WidthRequest="100"> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Only our MaxLines differ. Otherwise we're the same. Please tap us!"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding TapCommand}" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
<Label AutomationId="label6" HorizontalOptions="Start" MaxLines="6" BackgroundColor="LightGoldenrodYellow" WidthRequest="100"> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Only our MaxLines differ. Otherwise we're the same. Please tap us!"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding TapCommand}" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
<Label AutomationId="label7" HorizontalOptions="Start" MaxLines="5" BackgroundColor="LightGoldenrodYellow" WidthRequest="100"> | ||
<Label.FormattedText> | ||
<FormattedString> | ||
<Span Text="Only our MaxLines differ. Otherwise we're the same. Please tap us!"> | ||
<Span.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding TapCommand}" /> | ||
</Span.GestureRecognizers> | ||
</Span> | ||
</FormattedString> | ||
</Label.FormattedText> | ||
</Label> | ||
</VerticalStackLayout> | ||
</ContentPage> |
29 changes: 29 additions & 0 deletions
29
src/Controls/samples/Controls.Sample.UITests/Issues/Issue21837.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,29 @@ | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 21837, "Span's TapGestureRecognizer not working if text is truncated", PlatformAffected.All)] | ||
|
||
public partial class Issue21837 : ContentPage | ||
{ | ||
private int _tapCount; | ||
public int TapCount | ||
{ | ||
get => _tapCount; | ||
set | ||
{ | ||
_tapCount = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public Command TapCommand { get; set; } | ||
|
||
public Issue21837() | ||
{ | ||
InitializeComponent(); | ||
TapCommand = new Command(() => ++TapCount); | ||
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,29 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue21837 : _IssuesUITest | ||
{ | ||
public Issue21837(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "Span's TapGestureRecognizer not working if text is truncated"; | ||
|
||
[Test] | ||
public void TapsShouldBeCorrectlyRecognized() | ||
{ | ||
int numberOfTappableLabels = 7; | ||
|
||
_ = App.WaitForElement("label1"); | ||
|
||
for (int i = 0; i < numberOfTappableLabels; i++) | ||
App.Click($"label{i + 1}"); | ||
|
||
var resultText = App.FindElement("resultLabel").GetText(); | ||
Assert.AreEqual(resultText, $"Number of recognized taps: {numberOfTappableLabels}"); | ||
} | ||
} | ||
} |