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> <!DOCTYPE HTML>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<style> <style>
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
<script> <script>
var div = document.getElementById('div'); var div = document.getElementById('div');
var rect = div.getBoundingClientRect(); 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() { function changeStyleToScrollOnMain() {
if(div.scrollTop > 100) if(div.scrollTop > 100)
...@@ -59,15 +60,8 @@ function waitForAnimationEnd() { ...@@ -59,15 +60,8 @@ function waitForAnimationEnd() {
} }
promise_test(() => { promise_test(() => {
return new Promise((resolve, reject) => { return smoothScroll(500, (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, GESTURE_SOURCE_TYPE, 'down', 2000)
chrome.gpuBenchmarking.smoothScrollBy(500, .then(waitForAnimationEnd)
resolve,
(rect.left + rect.right) / 2,
(rect.top + rect.bottom) / 2,
GESTURE_SOURCE_TYPE,
'down',
2000);
}).then(waitForAnimationEnd)
.then(() => { .then(() => {
assert_equals(div.scrollTop, div.scrollHeight - div.clientHeight, assert_equals(div.scrollTop, div.scrollHeight - div.clientHeight,
"div must be fully scrolled"); "div must be fully scrolled");
......
<!DOCTYPE html> <!DOCTYPE html>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<script> <script>
...@@ -32,22 +33,10 @@ ...@@ -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() { async function runTest() {
if (!chrome.gpuBenchmarking) if (!chrome.gpuBenchmarking)
return; return;
const WHEEL_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
// Wait a bit to ensure we don't start sending scroll gestures to the // 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 // compositor before the page layers have fully propagated to the CC active
...@@ -57,7 +46,7 @@ ...@@ -57,7 +46,7 @@
// Scroll horizontally first. Ensure we scrolled the div since otherwise we // 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 // may pass the test vacuously. See crbug.com/801381 for the case we're
// guarding against. // 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 // Wait a bit since the scroll gesture resolves when the ScrollEnd is sent
// from the browser, not when it's processed by the renderer. // from the browser, not when it's processed by the renderer.
...@@ -72,7 +61,7 @@ ...@@ -72,7 +61,7 @@
// Now scroll vertically. The scroller shouldn't have any vertical scroll // Now scroll vertically. The scroller shouldn't have any vertical scroll
// extent so the window should 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); await nFrames(2);
t.step(() => { t.step(() => {
assert_approx_equals(window.scrollY, 10, 1); assert_approx_equals(window.scrollY, 10, 1);
......
<!DOCTYPE HTML> <!DOCTYPE HTML>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<style> <style>
...@@ -45,19 +46,7 @@ ...@@ -45,19 +46,7 @@
var parentDiv = document.getElementById('parentDiv'); var parentDiv = document.getElementById('parentDiv');
var childDiv = document.getElementById('childDiv'); var childDiv = document.getElementById('childDiv');
const WHEEL_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h const WHEEL_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
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 MAX_RAF = 1000; const MAX_RAF = 1000;
var last_child_scroll_offset = childDiv.scrollTop; var last_child_scroll_offset = childDiv.scrollTop;
var last_parent_scroll_offset = parentDiv.scrollTop; var last_parent_scroll_offset = parentDiv.scrollTop;
...@@ -85,7 +74,7 @@ function waitForAnimationEnd() { ...@@ -85,7 +74,7 @@ function waitForAnimationEnd() {
var rect = childDiv.getBoundingClientRect(); var rect = childDiv.getBoundingClientRect();
function testWheelScrollLatching() { 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(waitForAnimationEnd)
.then(() => { .then(() => {
assert_equals(childDiv.scrollTop, 10, "childDiv must be fully scrolled"); assert_equals(childDiv.scrollTop, 10, "childDiv must be fully scrolled");
......
<!DOCTYPE HTML> <!DOCTYPE HTML>
<script src='../../../resources/gesture-util.js'></script>
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<style> <style>
...@@ -43,19 +44,7 @@ ...@@ -43,19 +44,7 @@
var childDiv = document.getElementById('childDiv'); var childDiv = document.getElementById('childDiv');
var parentDiv = document.getElementById('parentDiv'); var parentDiv = document.getElementById('parentDiv');
var rect = childDiv.getBoundingClientRect(); var rect = childDiv.getBoundingClientRect();
const GESTURE_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h const GESTURE_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
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 MAX_RAF = 1000; const MAX_RAF = 1000;
function waitForAnimationEnd() { function waitForAnimationEnd() {
...@@ -83,7 +72,7 @@ function waitForAnimationEnd() { ...@@ -83,7 +72,7 @@ function waitForAnimationEnd() {
} }
promise_test(t => { 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(waitForAnimationEnd)
.then(() => { .then(() => {
assert_equals(childDiv.scrollTop, childDiv.scrollHeight - childDiv.clientHeight, assert_equals(childDiv.scrollTop, childDiv.scrollHeight - childDiv.clientHeight,
......
...@@ -56,19 +56,6 @@ ...@@ -56,19 +56,6 @@
if (window.internals) if (window.internals)
internals.settings.setScrollAnimatorEnabled(false); 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() { function waitForScroll() {
const MAX_FRAME = 500; const MAX_FRAME = 500;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -99,8 +86,8 @@ ...@@ -99,8 +86,8 @@
rootscroller, rootscroller,
"#rootscroller must be the effective root scroller"); "#rootscroller must be the effective root scroller");
} }
const GESTURE_SOURCE_TYPE = 2; // MOUSE_INPUT from synthetic_gesture_params.h const GESTURE_SOURCE_TYPE = GestureSourceType.MOUSE_INPUT;
return scrollDown(500, 100, 100, GESTURE_SOURCE_TYPE, 1000) return smoothScroll(500, 100, 100, GESTURE_SOURCE_TYPE, 'down', 1000)
.then(waitForScroll) .then(waitForScroll)
.then(() => { .then(() => {
assert_greater_than(document.scrollingElement.scrollTop, 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