From 6ee810c1d851f96e71d989bb05e8f1c335636000 Mon Sep 17 00:00:00 2001 From: tj-devel709 Date: Mon, 6 May 2024 15:35:56 -0500 Subject: [PATCH] Change UITest, add IsHorizontalCollectionView, and remove movedContainerDistance --- .../tests/UITests/Tests/Issues/Issue19214.cs | 13 +++++++++++-- .../src/Platform/iOS/KeyboardAutoManagerScroll.cs | 12 ++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue19214.cs b/src/Controls/tests/UITests/Tests/Issues/Issue19214.cs index 817b46003d94..327dcbd67ee9 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue19214.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue19214.cs @@ -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; @@ -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]); } } diff --git a/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs b/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs index 5af590e73792..22c71b51b0cd 100644 --- a/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs +++ b/src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs @@ -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); @@ -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(); @@ -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)