Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<MauiImage Include="Resources\AppIcons\appicon.svg" ForegroundFile="Resources\AppIcons\appicon_foreground.svg" IsAppIcon="true" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#FFFFFF" BaseSize="168,208" />
<MauiFont Include="Resources\Fonts\OpenSans-Regular.ttf" />
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<Import Project="$(MauiSrcDirectory)Maui.InTree.props" Condition=" '$(UseMaui)' != 'true' " />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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.Issue18716">
<Grid>
<WebView
x:Name="WaitForStubControl"
AutomationId="WaitForStubControl">
</WebView>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 18716, "Touch events are not working on WebView when a PDF is displayed", PlatformAffected.iOS)]
public partial class Issue18716 : ContentPage
{
public Issue18716()
{
InitializeComponent();
var urlWebViewSource = new UrlWebViewSource
{
Url = $"dotnetmaui.pdf"
};

WaitForStubControl.Source = urlWebViewSource;
}
}
}
Binary file not shown.
31 changes: 31 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue18716.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues
{
public class Issue18716 : _IssuesUITest
{
public Issue18716(TestDevice device)
: base(device)
{ }

public override string Issue => "Touch events are not working on WebView when a PDF is displayed";

/*
There's an issue getting the mouse interactions to work with Appium.
[Test]
[Category(UITestCategories.WebView)]
public async Task CanScrollWebView()
{
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Windows, TestDevice.iOS });

await Task.Delay(1000); // Wait WebView to load.

App.WaitForElement("WaitForStubControl");
App.ScrollDown("WaitForStubControl", ScrollStrategy.Gesture, 0.75);
App.Screenshot("Scrolling has been done correctly.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a VerifyScreenshot maybe?

}*/

}
}
12 changes: 3 additions & 9 deletions src/Core/src/Platform/iOS/LayoutView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public override void WillRemoveSubview(UIView uiview)
var result = base.HitTest(point, uievent);

if (result is null)
{
return null;
}

if (!_userInteractionEnabled && this.Equals(result))
if (!_userInteractionEnabled && Equals(result))
{
// If user interaction is disabled (IOW, if the corresponding Layout is InputTransparent),
// then we exclude the LayoutView itself from hit testing. But it's children are valid
Expand All @@ -37,14 +39,6 @@ public override void WillRemoveSubview(UIView uiview)
return null;
}

if (!result.UserInteractionEnabled)
{
// If the child also has user interaction disabled (IOW the child is InputTransparent),
// then we also want to exclude it from the hit testing.

return null;
}
Comment thread
PureWeen marked this conversation as resolved.

if (result is LayoutView layoutView && !layoutView.UserInteractionEnabledOverride)
{
// If the child is a layout then we need to check the UserInteractionEnabledOverride
Expand Down
60 changes: 29 additions & 31 deletions src/TestUtils/src/UITest.Appium/Actions/AppiumScrollActions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Interactions;
using OpenQA.Selenium.Appium.Mac;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Interactions;
using UITest.Core;
Expand Down Expand Up @@ -151,15 +152,7 @@ static void ScrollToLeft(AppiumDriver driver, AppiumElement element, ScrollStrat

int endX = (int)(position.X + (size.Width * swipePercentage));
int endY = startY;

OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
var scrollSequence = new ActionSequence(touchDevice, 0);
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
driver.PerformActions([scrollSequence]);
PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
}

static void ScrollToDown(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
Expand All @@ -172,15 +165,7 @@ static void ScrollToDown(AppiumDriver driver, AppiumElement element, ScrollStrat

int endX = startX;
int endY = (int)(position.Y + (size.Height * 0.05));

OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
var scrollSequence = new ActionSequence(touchDevice, 0);
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
driver.PerformActions([scrollSequence]);
PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
}

static void ScrollToRight(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
Expand All @@ -193,15 +178,7 @@ static void ScrollToRight(AppiumDriver driver, AppiumElement element, ScrollStra

int endX = (int)(position.X + (size.Width * 0.05));
int endY = startY;

OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
var scrollSequence = new ActionSequence(touchDevice, 0);
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
driver.PerformActions([scrollSequence]);
PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
}

static void ScrollToUp(AppiumDriver driver, AppiumElement element, ScrollStrategy strategy, double swipePercentage, int swipeSpeed, bool withInertia = true)
Expand All @@ -214,13 +191,34 @@ static void ScrollToUp(AppiumDriver driver, AppiumElement element, ScrollStrateg

int endX = startX;
int endY = (int)(position.Y + (size.Height * swipePercentage));
PerformActions(driver, startX, startY, endX, endY, strategy, swipeSpeed);
}

static void PerformActions(
AppiumDriver driver,
int startX,
int startY,
int endX,
int endY,
ScrollStrategy strategy,
int swipeSpeed)
{

OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(PointerKind.Touch);
var pointerKind = PointerKind.Touch;
if (driver is MacDriver)
{
pointerKind = PointerKind.Mouse;
}

OpenQA.Selenium.Appium.Interactions.PointerInputDevice touchDevice = new OpenQA.Selenium.Appium.Interactions.PointerInputDevice(pointerKind);
var scrollSequence = new ActionSequence(touchDevice, 0);
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.Zero));
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, startX, startY, TimeSpan.FromMilliseconds(2)));
scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(ScrollTouchDownTime)));
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, TimeSpan.FromMilliseconds(strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime)));
scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(Math.Max(ScrollTouchDownTime, 2))));

var moveDuration = TimeSpan.FromMilliseconds(Math.Max(2, strategy != ScrollStrategy.Programmatically ? swipeSpeed : ProgrammaticallyScrollTime));
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, endX, endY, moveDuration));

scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
driver.PerformActions([scrollSequence]);
}
Expand Down