Commit 92439e8f authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Use gpuBenchmarking for wheel scroll in wheel event tests

After we finish the scroll unification, the scrolls happens mainly on
the compositor thread, and the scroll code in the main thread will be
removed. eventSender sends the scroll events to main thread, so it
would not work after the scroll unification. We should replace
eventSender.continuousMouseScrollBy with gpuBenchmarking.smoothScrollBy
in the wheel event tests. In the wheel event tests, there is a check for
wheelDeltaX or wheelDeltaY, which has a multiplier factor of 3, which I
think should change to kTickMultiplier/MouseWheelEvent::kWheelDelta,
120/53.

Bug: 1047176
Change-Id: I534cbd25f2a9c84f6f5d891742438facdcda91ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2084091
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751210}
parent 5a4da390
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
#include "content/browser/renderer_host/input/synthetic_gesture_target_mac.h" #include "content/browser/renderer_host/input/synthetic_gesture_target_mac.h"
#import "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_input_event_router.h" #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
#import "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h" #include "ui/events/cocoa/cocoa_event_utils.h"
#include "ui/events/gesture_detection/gesture_configuration.h" #include "ui/events/gesture_detection/gesture_configuration.h"
// Unlike some event APIs, Apple does not provide a way to programmatically // Unlike some event APIs, Apple does not provide a way to programmatically
...@@ -135,7 +136,12 @@ void SyntheticGestureTargetMac::DispatchWebTouchEventToPlatform( ...@@ -135,7 +136,12 @@ void SyntheticGestureTargetMac::DispatchWebTouchEventToPlatform(
void SyntheticGestureTargetMac::DispatchWebMouseWheelEventToPlatform( void SyntheticGestureTargetMac::DispatchWebMouseWheelEventToPlatform(
const blink::WebMouseWheelEvent& web_wheel, const blink::WebMouseWheelEvent& web_wheel,
const ui::LatencyInfo& latency_info) { const ui::LatencyInfo& latency_info) {
GetView()->RouteOrProcessWheelEvent(web_wheel); blink::WebMouseWheelEvent wheel_event = web_wheel;
wheel_event.wheel_ticks_x =
web_wheel.delta_x / ui::kScrollbarPixelsPerCocoaTick;
wheel_event.wheel_ticks_y =
web_wheel.delta_y / ui::kScrollbarPixelsPerCocoaTick;
GetView()->RouteOrProcessWheelEvent(wheel_event);
if (web_wheel.phase == blink::WebMouseWheelEvent::kPhaseEnded) { if (web_wheel.phase == blink::WebMouseWheelEvent::kPhaseEnded) {
// Send the pending wheel end event immediately. Otherwise, the // Send the pending wheel end event immediately. Otherwise, the
// MouseWheelPhaseHandler will defer the end event in case of momentum // MouseWheelPhaseHandler will defer the end event in case of momentum
......
PASS event.wheelDeltaY is window.expectedScrollTop*-3
PASS event.wheelDeltaX is window.expectedScrollLeft*-3
PASS event.wheelDelta is window.expectedScrollTop*-3
PASS div.scrollTop == window.expectedScrollTop && div.scrollLeft == window.expectedScrollLeft became true
PASS successfullyParsed is true
TEST COMPLETE
<html> <!DOCTYPE html>
<head> <script src='../../resources/gesture-util.js'></script>
<script src="../../resources/js-test.js"></script> <script src="../../resources/testharness.js"></script>
<script> <script src="../../resources/testharnessreport.js"></script>
window.jsTestIsAsync = true; <div id="overflow" style="border:2px solid black;overflow:auto;height:200px;width:200px;">
var expectedScrollTop = 200; <div style="background-color:red;height:200px;width:400px;"></div>
var expectedScrollLeft = 100; <div style="background-color:green;height:200px;width:400px;"></div>
var event; <div style="background-color:red;height:200px;width:400px;"></div>
var div; </div>
function runTest() <script>
{
var overflowElement = document.getElementById("overflow");
if (overflowElement)
overflowElement.addEventListener("mousewheel", mousewheelHandler, false);
if (window.eventSender) { var expectedScrollTop = 200;
eventSender.mouseMoveTo(100, 110); var expectedScrollLeft = 100;
eventSender.continuousMouseScrollBy(-window.expectedScrollLeft, -window.expectedScrollTop); var last_event = null;
} var source = GestureSourceType.MOUSE_INPUT;
const numTicksX = expectedScrollLeft / pixelsPerTick();
const numTicksY = expectedScrollTop / pixelsPerTick();
const expectedWheelDeltaX = numTicksX * LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER;
const expectedWheelDeltaY = numTicksY * LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER;
div = document.getElementById("overflow"); function mousewheelHandler(e)
shouldBecomeEqual("div.scrollTop == window.expectedScrollTop && " + {
"div.scrollLeft == window.expectedScrollLeft", "true", finishJSTest); last_event = e;
} }
function mousewheelHandler(e) promise_test(async () => {
{ var overflowElement = document.getElementById("overflow");
event = e; overflowElement.addEventListener("mousewheel", mousewheelHandler, false);
shouldBe("event.wheelDeltaY", "window.expectedScrollTop*-3");
shouldBe("event.wheelDeltaX", "window.expectedScrollLeft*-3");
if (e.wheelDeltaY) await smoothScroll(window.expectedScrollLeft, 100, 110, source, 'right', SPEED_INSTANT);
shouldBe("event.wheelDelta", "window.expectedScrollTop*-3"); await waitFor( () => {
else return overflowElement.scrollLeft == window.expectedScrollLeft;
shouldBe("event.wheelDelta", "window.expectedScrollLeft*-3"); });
} assert_equals(last_event.wheelDeltaX, -Math.floor(expectedWheelDeltaX));
</script> assert_equals(last_event.wheelDelta, -Math.floor(expectedWheelDeltaX));
</head> last_event = null;
<body style="margin:0" onload="runTest()"> await smoothScroll(window.expectedScrollTop, 100, 110, source, 'down', SPEED_INSTANT);
<div id="overflow" style="border:2px solid black;overflow:auto;height:200px;width:200px;"> await waitFor( () => {
<div style="background-color:red;height:200px;width:400px;"></div> return overflowElement.scrollTop == window.expectedScrollTop;
<div style="background-color:green;height:200px;width:400px;"></div> });
<div style="background-color:red;height:200px;width:400px;"></div> assert_equals(last_event.wheelDeltaY, -Math.floor(expectedWheelDeltaY));
</div> assert_equals(last_event.wheelDelta, -Math.floor(expectedWheelDeltaY));
<div id="console"></div> }, 'This test checks the wheel delta value of wheel events, which should be the number of ticks multiplies the legacy mouse wheel tick multiplier.');
</body>
</html> </script>
\ No newline at end of file
...@@ -186,6 +186,8 @@ function smoothScroll(pixels_to_scroll, start_x, start_y, gesture_source_type, d ...@@ -186,6 +186,8 @@ function smoothScroll(pixels_to_scroll, start_x, start_y, gesture_source_type, d
}); });
} }
const LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER = 120;
// Returns the number of pixels per wheel tick which is a platform specific value. // Returns the number of pixels per wheel tick which is a platform specific value.
function pixelsPerTick() { function pixelsPerTick() {
// Comes from ui/events/event.cc // Comes from ui/events/event.cc
......
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