Commit 3c4369d0 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Portals: Fix touch input transfer tests

Couple of issues dealt with by this CL:

1) We should be starting the gesture from near the bottom of the page
   instead from the top (as it moves upwards)
2) In TouchInputTransferAcrossReactivation, we might get some scrolling
   in the main page before the first activation. We should be checking
   to see if it has scrolled more than that amount after reactivation

Bug: 1010675
Change-Id: I6289549f1326a80896c8b78e6a66a724ac6dbeff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880077Reviewed-by: default avatarKevin McNee <mcnee@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709989}
parent 4026486b
......@@ -976,7 +976,8 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, TouchInputTransferAcrossActivation) {
// Create and dispatch a synthetic scroll to trigger activation.
SyntheticSmoothScrollGestureParams params;
params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
params.anchor = gfx::PointF(50, 150);
params.anchor =
gfx::PointF(50, main_frame->GetView()->GetViewBounds().height() - 100);
params.distances.push_back(-gfx::Vector2d(0, 100));
std::unique_ptr<SyntheticSmoothScrollGesture> gesture =
......@@ -999,7 +1000,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, TouchInputTransferAcrossActivation) {
// Touch input transfer is only implemented in the content layer for Aura.
#if defined(USE_AURA)
IN_PROC_BROWSER_TEST_F(PortalBrowserTest,
DISABLED_TouchInputTransferAcrossReactivation) {
TouchInputTransferAcrossReactivation) {
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL(
"portal.test",
......@@ -1026,6 +1027,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest,
portal = portal_created_observer.WaitUntilPortalCreated();
}
navigation_observer.Wait();
WaitForHitTestData(main_frame);
PortalInterceptorForTesting* portal_interceptor =
PortalInterceptorForTesting::From(portal);
......@@ -1033,8 +1035,10 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest,
// Create and dispatch a synthetic scroll to trigger activation.
SyntheticSmoothScrollGestureParams params;
params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
params.anchor = gfx::PointF(50, 150);
params.distances.push_back(-gfx::Vector2d(0, 1000));
params.anchor =
gfx::PointF(50, main_frame->GetView()->GetViewBounds().height() - 100);
params.distances.push_back(-gfx::Vector2d(0, 250));
params.speed_in_pixels_s = 200;
std::unique_ptr<SyntheticSmoothScrollGesture> gesture =
std::make_unique<SyntheticSmoothScrollGesture>(params);
......@@ -1055,7 +1059,10 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest,
// The starting page should have scrolled.
// NOTE: This assumes that the scroll gesture is long enough that touch events
// are still sent after the predecessor is reactivated.
EXPECT_NE(0, EvalJs(main_frame, "window.scrollY"));
int scroll_y_after_portal_activate =
EvalJs(main_frame, "scrollYAfterPortalActivate").ExtractInt();
EXPECT_LT(scroll_y_after_portal_activate,
EvalJs(main_frame, "window.scrollY"));
}
#endif
......
......@@ -12,10 +12,12 @@
<body>
<div id="scroller"></div>
<script>
let scrollYAfterPortalActivate = 0;
document.body.addEventListener('touchstart', e => {
var portal = document.querySelector('portal');
portal.activate().then(() => {
document.body.removeChild(portal);
scrollYAfterPortalActivate = window.scrollY;
});
}, {passive: false, once: true});
</script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment