-
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.
[macOS] Fix
GesturePlatformManager.CalculatePosition
when asked for…
… a relative position (#19371) * Fix * Test * Apply feedback * Switch Button to BoxView * - fix tests * - add upper limit constraints * - switch to wait for element * Update src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.xaml Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com> * - switch to click for catalyst * Update src/Controls/tests/UITests/Tests/Issues/Issue19329.cs Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com> * - add comments --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com> Co-authored-by: Shane Neuville <shane94@hotmail.com>
- Loading branch information
1 parent
aa28d78
commit c1dfd70
Showing
5 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.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,16 @@ | ||
<?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.Issue19329"> | ||
<VerticalStackLayout x:Name="layout" Margin="75,75,75,75" BackgroundColor="LightGray"> | ||
<Label Text="Tap the bottom red label. The position of the tap should be calculated relative to the upper blue box." /> | ||
<VerticalStackLayout HeightRequest="80" WidthRequest="80"> | ||
<BoxView HorizontalOptions="Start" x:Name="UpperBox" AutomationId="UpperBox" Color="CornflowerBlue" WidthRequest="20" HeightRequest="20"/> | ||
<Label HorizontalOptions="End" x:Name="TapHere" Text="Tap Here" AutomationId="TapHere" Background="Red" WidthRequest="20" HeightRequest="20"> | ||
<Label.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="OnTapped" /> | ||
</Label.GestureRecognizers> | ||
</Label> | ||
</VerticalStackLayout> | ||
</VerticalStackLayout> | ||
</ContentPage> |
48 changes: 48 additions & 0 deletions
48
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.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,48 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 19329, "Pointer gestures should work with relative positions correctly", PlatformAffected.iOS)] | ||
public partial class Issue19329 : ContentPage | ||
{ | ||
public Issue19329() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnTapped(object sender, TappedEventArgs e) | ||
{ | ||
// Report that the callback was called. | ||
layout.Children.Add(new Label { Text = "TapAccepted", AutomationId = "TapAccepted" }); | ||
|
||
Point? position = e.GetPosition(relativeTo: UpperBox); | ||
|
||
string result; | ||
string automationId; | ||
|
||
if (position is null) | ||
{ | ||
result = "Error: position is null"; | ||
automationId = "Failure"; | ||
} | ||
else if (position.Value.X >= 60 && position.Value.X <= 80 && position.Value.Y >= 20 && position.Value.Y <= 40) | ||
{ | ||
result = $"Success: relative position is: X={position.Value.X}, Y={position.Value.Y}"; | ||
automationId = "Success"; | ||
} | ||
else | ||
{ | ||
result = $"Error: relative position is: X={position.Value.X}, Y={position.Value.Y}"; | ||
automationId = "Failure"; | ||
} | ||
|
||
// Report the result of the test. | ||
layout.Children.Add(new Label { Text = result, AutomationId = automationId }); | ||
} | ||
} | ||
} |
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,25 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
using System.Drawing; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue19329 : _IssuesUITest | ||
{ | ||
public Issue19329(TestDevice device) : base(device) { } | ||
|
||
public override string Issue => "Pointer gestures should work with relative positions correctly"; | ||
|
||
[Test] | ||
public void RelativePointerPositionIsComputedCorrectly() | ||
{ | ||
_ = App.WaitForElement("TapHere"); | ||
|
||
App.Click("TapHere"); | ||
|
||
App.WaitForElement("TapAccepted"); | ||
App.WaitForElement("Success"); | ||
} | ||
} | ||
} |
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