Commit d2728577 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Replace chrome.gpuBenchmarking.smoothScrollBy with smoothScroll

To simplify the use of the scroll function, we can use the smoothScroll
function in gesture-util.js instead of
chrome.gpuBenchmarking.smoothScrollBy in all the layout tests.

Bug: 1047176
Change-Id: I6764bd72e42d54a2623b453a808061f96d045687
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2115798Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752620}
parent 4b0f8fd9
<!DOCTYPE HTML>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
......@@ -26,7 +27,7 @@
<script>
var div = document.getElementById('div');
var rect = div.getBoundingClientRect();
const GESTURE_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h
const GESTURE_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
function changeStyleToScrollOnMain() {
if(div.scrollTop > 100)
......@@ -59,17 +60,10 @@ function waitForAnimationEnd() {
}
promise_test(() => {
return new Promise((resolve, reject) => {
chrome.gpuBenchmarking.smoothScrollBy(500,
resolve,
(rect.left + rect.right) / 2,
(rect.top + rect.bottom) / 2,
GESTURE_SOURCE_TYPE,
'down',
2000);
}).then(waitForAnimationEnd)
.then(() => {
assert_equals(div.scrollTop, div.scrollHeight - div.clientHeight,
return smoothScroll(500, (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, GESTURE_SOURCE_TYPE, 'down', 2000)
.then(waitForAnimationEnd)
.then(() => {
assert_equals(div.scrollTop, div.scrollHeight - div.clientHeight,
"div must be fully scrolled");
});
}, "Scroller should continue to scroll when MT takes over scroll handling.");
......
<!DOCTYPE html>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
......@@ -32,22 +33,10 @@
});
}
async function scroll(pixels_to_scroll, direction, start_x, start_y, speed_in_pixels_s) {
return new Promise((resolve, reject) => {
const WHEEL_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h
chrome.gpuBenchmarking.smoothScrollBy(pixels_to_scroll,
resolve,
start_x,
start_y,
WHEEL_SOURCE_TYPE,
direction,
speed_in_pixels_s);
});
}
async function runTest() {
if (!chrome.gpuBenchmarking)
return;
const WHEEL_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
// Wait a bit to ensure we don't start sending scroll gestures to the
// compositor before the page layers have fully propagated to the CC active
......@@ -57,7 +46,7 @@
// Scroll horizontally first. Ensure we scrolled the div since otherwise we
// may pass the test vacuously. See crbug.com/801381 for the case we're
// guarding against.
await scroll(10, 'right', 50, 50, 1000);
await smoothScroll(10, 50, 50, WHEEL_SOURCE_TYPE, 'right', 1000);
// Wait a bit since the scroll gesture resolves when the ScrollEnd is sent
// from the browser, not when it's processed by the renderer.
......@@ -72,7 +61,7 @@
// Now scroll vertically. The scroller shouldn't have any vertical scroll
// extent so the window should scroll.
await scroll(10, 'down', 50, 50, 1000);
await smoothScroll(10, 50, 50, WHEEL_SOURCE_TYPE, 'down', 1000);
await nFrames(2);
t.step(() => {
assert_approx_equals(window.scrollY, 10, 1);
......
<!DOCTYPE HTML>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
......@@ -45,19 +46,7 @@
var parentDiv = document.getElementById('parentDiv');
var childDiv = document.getElementById('childDiv');
const WHEEL_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h
function scrollDown(pixels_to_scroll, start_x, start_y, speed_in_pixels_s) {
return new Promise((resolve, reject) => {
chrome.gpuBenchmarking.smoothScrollBy(pixels_to_scroll,
resolve,
start_x,
start_y,
WHEEL_SOURCE_TYPE,
'down',
speed_in_pixels_s);
});
}
const WHEEL_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
const MAX_RAF = 1000;
var last_child_scroll_offset = childDiv.scrollTop;
var last_parent_scroll_offset = parentDiv.scrollTop;
......@@ -85,7 +74,7 @@ function waitForAnimationEnd() {
var rect = childDiv.getBoundingClientRect();
function testWheelScrollLatching() {
return scrollDown(400, (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 1000)
return smoothScroll(400, (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, WHEEL_SOURCE_TYPE, 'down', 1000)
.then(waitForAnimationEnd)
.then(() => {
assert_equals(childDiv.scrollTop, 10, "childDiv must be fully scrolled");
......
<!DOCTYPE HTML>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
......@@ -43,19 +44,7 @@
var childDiv = document.getElementById('childDiv');
var parentDiv = document.getElementById('parentDiv');
var rect = childDiv.getBoundingClientRect();
const GESTURE_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h
function scrollDown(pixels_to_scroll, start_x, start_y, speed_in_pixels_s) {
return new Promise((resolve, reject) => {
chrome.gpuBenchmarking.smoothScrollBy(pixels_to_scroll,
resolve,
start_x,
start_y,
GESTURE_SOURCE_TYPE,
'down',
speed_in_pixels_s);
});
}
const GESTURE_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
const MAX_RAF = 1000;
function waitForAnimationEnd() {
......@@ -83,7 +72,7 @@ function waitForAnimationEnd() {
}
promise_test(t => {
return scrollDown(1000, rect.right - 5, rect.bottom - 5, 4000)
return smoothScroll(1000, rect.right - 5, rect.bottom - 5, GESTURE_SOURCE_TYPE, 'down', 4000)
.then(waitForAnimationEnd)
.then(() => {
assert_equals(childDiv.scrollTop, childDiv.scrollHeight - childDiv.clientHeight,
......
......@@ -56,19 +56,6 @@
if (window.internals)
internals.settings.setScrollAnimatorEnabled(false);
function scrollDown(pixels_to_scroll, start_x, start_y,
gesture_source_type, speed_in_pixels_s) {
return new Promise((resolve, reject) => {
chrome.gpuBenchmarking.smoothScrollBy(pixels_to_scroll,
resolve,
start_x,
start_y,
gesture_source_type,
'down',
speed_in_pixels_s);
});
}
function waitForScroll() {
const MAX_FRAME = 500;
return new Promise((resolve, reject) => {
......@@ -99,8 +86,8 @@
rootscroller,
"#rootscroller must be the effective root scroller");
}
const GESTURE_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h
return scrollDown(500, 100, 100, GESTURE_SOURCE_TYPE, 1000)
const GESTURE_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
return smoothScroll(500, 100, 100, GESTURE_SOURCE_TYPE, 'down', 1000)
.then(waitForScroll)
.then(() => {
assert_greater_than(document.scrollingElement.scrollTop,
......
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