Skip to content

Commit

Permalink
Change UITest, add IsHorizontalCollectionView, and remove movedContai…
Browse files Browse the repository at this point in the history
…nerDistance
  • Loading branch information
tj-devel709 committed May 6, 2024
1 parent f1c0789 commit 6ee810c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
13 changes: 11 additions & 2 deletions src/Controls/tests/UITests/Tests/Issues/Issue19214.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Drawing;
using NUnit.Framework;
using OpenQA.Selenium.Appium.Interactions;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Interactions;
using UITest.Appium;
using UITest.Core;

Expand Down Expand Up @@ -87,8 +89,15 @@ void ConfirmVisible (AppiumApp app, Rectangle rect, string scrollView, string en

void ScrollScrollView (AppiumApp app, Rectangle rect, bool scrollsDown = true)
{
var actions = new TouchAction(app.Driver);
var newY = scrollsDown ? rect.Y - 1000 : rect.Y + 1000;
actions.LongPress(null, rect.Left - 5, rect.Y).MoveTo(null, rect.Left - 5, newY).Release().Perform();

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, rect.Left - 5, rect.Y, TimeSpan.Zero));
scrollSequence.AddAction(touchDevice.CreatePointerDown(PointerButton.TouchContact));
scrollSequence.AddAction(touchDevice.CreatePause(TimeSpan.FromMilliseconds(500)));
scrollSequence.AddAction(touchDevice.CreatePointerMove(CoordinateOrigin.Viewport, rect.Left - 5, newY, TimeSpan.FromMilliseconds(250)));
scrollSequence.AddAction(touchDevice.CreatePointerUp(PointerButton.TouchContact));
app.Driver.PerformActions([scrollSequence]);
}
}
12 changes: 4 additions & 8 deletions src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -663,13 +663,6 @@ static void ApplyContentInset(UIScrollView? scrolledView, UIScrollView? lastScro
return;

var keyboardIntersect = CGRect.Intersect(KeyboardFrame, scrolledView.Frame);
nfloat movedContainerDistance = 0;

// if we are moving or have moved the containerview frame, we need to account for that
if (TopViewBeginOrigin != InvalidPoint && ContainerView is not null)
{
movedContainerDistance = TopViewBeginOrigin.Y - ContainerView.Frame.Y;
}

var frameInWindow = ContainerView!.ConvertRectToView(scrolledView.Frame, null);
keyboardIntersect = CGRect.Intersect(KeyboardFrame, frameInWindow);
Expand Down Expand Up @@ -697,7 +690,7 @@ static void ApplyContentInset(UIScrollView? scrolledView, UIScrollView? lastScro
{
while (view is not null)
{
if (view.ScrollEnabled)
if (view.ScrollEnabled && !IsHorizontalCollectionView(view))
return view;

view = view.FindResponder<UIScrollView>();
Expand All @@ -706,6 +699,9 @@ static void ApplyContentInset(UIScrollView? scrolledView, UIScrollView? lastScro
return null;
}

static bool IsHorizontalCollectionView(UIView collectionView)
=> collectionView is UICollectionView { CollectionViewLayout: UICollectionViewFlowLayout { ScrollDirection: UICollectionViewScrollDirection.Horizontal }};

internal static nfloat FindKeyboardHeight()
{
if (ContainerView is null)
Expand Down

0 comments on commit 6ee810c

Please sign in to comment.