Commit e6d84b1a authored by Rahul Arakeri's avatar Rahul Arakeri Committed by Commit Bot

Added test to verify animated scrolling.

This CL adds some test coverage for animated scrolling. The test
verifies that mouse clicks on the scrollbar and mousewheel ticks
are animated by default. Verifying the curve type is not in scope.
This test was added because scroll animations were regressed by
crrev.com/c/2485659.

Change-Id: If44578745582fa7e69795886a4a3e1c80ecbd7ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521449
Commit-Queue: Rahul Arakeri <arakeri@microsoft.com>
Reviewed-by: default avatarOlga Gerchikov <gerchiko@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#825180}
parent 6c857673
<!DOCTYPE html>
<title>Tests mouse clicks and mousewheel ticks are animated.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/gesture-util.js"></script>
<script src="../../resources/scrollbar-util.js"></script>
<body style="height: 1000px; width: 1000px">
<script>
window.onload = () => {
const TRACK_WIDTH = calculateScrollbarThickness();
const BUTTON_WIDTH = TRACK_WIDTH;
const SCROLL_CORNER = TRACK_WIDTH;
var start_offset = 0;
var end_offset = 0;
var animated_scroll = false;
// Watches for scroll offset values between the bounds (start_offset, end_offset).
window.onscroll = function() {
if(!animated_scroll)
animated_scroll = window.scrollY > start_offset && window.scrollY < end_offset;
}
function initBounds(start, end) {
start_offset = start;
end_offset = end;
animated_scroll = false;
}
promise_test (async () => {
await waitForCompositorCommit();
resetScrollOffset(document.scrollingElement);
// Click on the track part just above the down arrow.
const x = window.innerWidth - BUTTON_WIDTH / 2;
const y = window.innerHeight - SCROLL_CORNER - BUTTON_WIDTH - 2;
// Start at 0, perform a click and check that scrollY animates at least once.
// Also, note that this test is relevant only when running in threaded mode
// (--enable-threaded-compositing).
assert_equals(window.scrollY, 0, "Scroller is expected to be at 0 offset.");
initBounds(0, 431);
await mouseClickOn(x, y);
await waitForAnimationEndTimeBased(() => {return window.scrollY;});
assert_equals(window.scrollY, 431, "Unexpected scroll offset for scrollbar track.");
assert_true(animated_scroll, "Scrollbar scroll did not animate.");
}, "Test mouse click on scrollbar is animated.");
promise_test (async () => {
// Mac doesn't support mousewheel animations yet crbug.com/574283.
if(navigator.userAgent.includes("Mac OS X"))
return;
await waitForCompositorCommit();
resetScrollOffset(document.scrollingElement);
// Start at 0, perform a mousewheel tick and check that scrollY animates at
// least once. This test is relevant only when running in threaded mode
// (--enable-threaded-compositing).
assert_equals(window.scrollY, 0, "Scroller is expected to be at 0 offset.");
initBounds(0, 72);
await smoothScrollWithXY(0, 72, window.innerWidth / 2, window.innerHeight / 2,
GestureSourceType.MOUSE_INPUT,
SPEED_INSTANT, false /* precise_scrolling_deltas */,
false /* scroll_by_page */, true /* cursor_visible */,
false /* scroll_by_percentage */);
await waitForAnimationEndTimeBased(() => {return window.scrollY;});
assert_equals(window.scrollY, 72, "Unexpected scroll offset for mousewheel tick.");
assert_true(animated_scroll, "Mousewheel tick did not animate.");
}, "Test mouse wheel tick is animated.");
}
</script>
</body>
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