diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.xaml new file mode 100644 index 000000000000..37c81a1e1acc --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.xaml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.xaml.cs b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.xaml.cs new file mode 100644 index 000000000000..dc899d4f89ea --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue19329.xaml.cs @@ -0,0 +1,44 @@ +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; + + if (position is null) + { + result = "Error: position is null"; + } + else if (position.Value.X < 75 && position.Value.X < 75) + { + result = "Success"; + } + else + { + result = $"Error: relative position is: X={position.Value.X},Y={position.Value.Y}"; + } + + // Report the result of the test. + layout.Children.Add(new Label { Text = result, AutomationId = result }); + } + } +} diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19329.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19329.cs new file mode 100644 index 000000000000..17f401d920f5 --- /dev/null +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19329.cs @@ -0,0 +1,26 @@ +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() + { + IUIElement button = App.FindElement("TapHere"); + Rectangle rect = button.GetRect(); + + App.TapCoordinates(rect.CenterX(), rect.CenterY()); + //App.Click(rect.CenterX(), rect.CenterY()); + App.WaitForElement("TapAccepted"); + App.WaitForElement("Success"); + } + } +} \ No newline at end of file