Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyIX committed Dec 13, 2023
1 parent b3bd738 commit ee002f2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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">
<BoxView x:Name="UpperBox" AutomationId="UpperBox" Color="CornflowerBlue" WidthRequest="20" HeightRequest="20"/>

<Button AutomationId="TapHere" Text="Tap Here">
<Button.GestureRecognizers>
<TapGestureRecognizer Tapped="OnTapped" />
</Button.GestureRecognizers>
</Button>
</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -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 });
}
}
}
26 changes: 26 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue19329.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}
}

0 comments on commit ee002f2

Please sign in to comment.