Commit 8fdb3047 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Add touchpad swipe action to GpuBenchmarking

For testing purpose, we want to add a new action to GpuBenchmarking to
simulate the touchpad swipe action, which is a mouse wheel scrolling
and a fling.

Now the GestureSourceType of MOUSE_INPUT and TOUCHPAD_INPUT are treated
the same, but I will have another CL to separate them.

Bug: 864001
Change-Id: I736831d50e1d0adf945ae22b6b045a12ee0ae95c
Reviewed-on: https://chromium-review.googlesource.com/1161184Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584272}
parent cdf2fc77
......@@ -260,6 +260,28 @@ class MockMoveTouchTarget : public MockMoveGestureTarget {
bool started_;
};
class MockFlingGestureTarget : public MockMoveGestureTarget {
public:
MockFlingGestureTarget() : fling_velocity_x_(0), fling_velocity_y_(0) {}
~MockFlingGestureTarget() override {}
void DispatchInputEventToPlatform(const WebInputEvent& event) override {
if (event.GetType() == WebInputEvent::kGestureFlingStart) {
const blink::WebGestureEvent& gesture_event =
static_cast<const blink::WebGestureEvent&>(event);
fling_velocity_x_ = gesture_event.data.fling_start.velocity_x;
fling_velocity_y_ = gesture_event.data.fling_start.velocity_y;
}
}
float fling_velocity_x() const { return fling_velocity_x_; }
float fling_velocity_y() const { return fling_velocity_y_; }
private:
float fling_velocity_x_;
float fling_velocity_y_;
};
class MockDragMouseTarget : public MockMoveGestureTarget {
public:
MockDragMouseTarget() : started_(false) {}
......@@ -1190,6 +1212,30 @@ TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) {
scroll_target->start_to_end_distance().x());
}
TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchpadSwipe) {
CreateControllerAndTarget<MockFlingGestureTarget>();
SyntheticSmoothMoveGestureParams params;
params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(39, 86);
params.distances.push_back(gfx::Vector2d(0, -132));
params.fling_velocity_x = 800;
params.fling_velocity_y = -1000;
params.prevent_fling = false;
std::unique_ptr<SyntheticSmoothMoveGesture> gesture(
new SyntheticSmoothMoveGesture(params));
QueueSyntheticGesture(std::move(gesture));
FlushInputUntilComplete();
MockFlingGestureTarget* swipe_target =
static_cast<MockFlingGestureTarget*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(params.fling_velocity_x, swipe_target->fling_velocity_x());
EXPECT_EQ(params.fling_velocity_y, swipe_target->fling_velocity_y());
}
TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMousePreciseScroll) {
CreateControllerAndTarget<MockScrollMouseTarget>();
......
......@@ -104,25 +104,44 @@ void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
void SyntheticGestureTargetAura::DispatchWebGestureEventToPlatform(
const blink::WebGestureEvent& web_gesture,
const ui::LatencyInfo& latency_info) {
DCHECK(blink::WebInputEvent::IsPinchGestureEventType(web_gesture.GetType()));
DCHECK(blink::WebInputEvent::IsPinchGestureEventType(web_gesture.GetType()) ||
blink::WebInputEvent::IsFlingGestureEventType(web_gesture.GetType()));
ui::EventType event_type = ui::WebEventTypeToEventType(web_gesture.GetType());
int flags = ui::WebEventModifiersToEventFlags(web_gesture.GetModifiers());
aura::Window* window = GetWindow();
aura::EventInjector injector;
ui::GestureEventDetails pinch_details(event_type);
pinch_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD);
if (event_type == ui::ET_GESTURE_PINCH_UPDATE)
pinch_details.set_scale(web_gesture.data.pinch_update.scale);
if (blink::WebInputEvent::IsPinchGestureEventType(web_gesture.GetType())) {
ui::GestureEventDetails pinch_details(event_type);
pinch_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD);
if (event_type == ui::ET_GESTURE_PINCH_UPDATE)
pinch_details.set_scale(web_gesture.data.pinch_update.scale);
ui::GestureEvent pinch_event(
web_gesture.PositionInWidget().x * device_scale_factor_,
web_gesture.PositionInWidget().y * device_scale_factor_, flags,
ui::EventTimeForNow(), pinch_details);
ui::GestureEvent pinch_event(
web_gesture.PositionInWidget().x * device_scale_factor_,
web_gesture.PositionInWidget().y * device_scale_factor_, flags,
ui::EventTimeForNow(), pinch_details);
aura::Window* window = GetWindow();
pinch_event.ConvertLocationToTarget(window, window->GetRootWindow());
pinch_event.ConvertLocationToTarget(window, window->GetRootWindow());
aura::EventInjector injector;
injector.Inject(window->GetHost(), &pinch_event);
injector.Inject(window->GetHost(), &pinch_event);
return;
}
ui::EventMomentumPhase momentum_phase =
web_gesture.GetType() == blink::WebInputEvent::kGestureFlingStart
? ui::EventMomentumPhase::BEGAN
: ui::EventMomentumPhase::END;
gfx::PointF location(web_gesture.PositionInWidget().x * device_scale_factor_,
web_gesture.PositionInWidget().y * device_scale_factor_);
ui::ScrollEvent scroll_event(event_type, gfx::Point(), ui::EventTimeForNow(),
flags, web_gesture.data.fling_start.velocity_x,
web_gesture.data.fling_start.velocity_y, 0, 0, 2,
momentum_phase, ui::ScrollEventPhase::kNone);
scroll_event.set_location_f(location);
scroll_event.set_root_location_f(location);
scroll_event.ConvertLocationToTarget(window, window->GetRootWindow());
injector.Inject(window->GetHost(), &scroll_event);
}
void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform(
......
......@@ -99,6 +99,19 @@ void SyntheticGestureTargetBase::DispatchInputEventToPlatform(
return;
}
DispatchWebGestureEventToPlatform(web_pinch, latency_info);
} else if (WebInputEvent::IsFlingGestureEventType(event.GetType())) {
const WebGestureEvent& web_fling =
static_cast<const WebGestureEvent&>(event);
// Touchscreen swipe should be injected as touch events.
DCHECK_EQ(blink::kWebGestureDeviceTouchpad, web_fling.SourceDevice());
if (event.GetType() == WebInputEvent::kGestureFlingStart &&
!PointIsWithinContents(web_fling.PositionInWidget().x,
web_fling.PositionInWidget().y)) {
LOG(WARNING)
<< "Fling coordinates are not within content bounds on FlingStart.";
return;
}
DispatchWebGestureEventToPlatform(web_fling, latency_info);
} else {
NOTREACHED();
}
......
......@@ -29,6 +29,8 @@ const int kDefaultSpeedInPixelsPerSec = 800;
SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams()
: speed_in_pixels_s(kDefaultSpeedInPixelsPerSec),
fling_velocity_x(0),
fling_velocity_y(0),
prevent_fling(true),
add_slop(true),
precise_scrolling_deltas(false) {}
......@@ -186,10 +188,18 @@ void SyntheticSmoothMoveGesture::ForwardMouseWheelInputEvents(
ComputeNextMoveSegment();
} else {
state_ = DONE;
// Forward a wheel event with phase ended and zero deltas.
ForwardMouseWheelEvent(target, gfx::Vector2d(),
blink::WebMouseWheelEvent::kPhaseEnded,
event_timestamp);
// Start flinging on the swipe action.
if (!params_.prevent_fling && (params_.fling_velocity_x != 0 ||
params_.fling_velocity_y != 0)) {
ForwardFlingGestureEvent(
target, blink::WebGestureEvent::kGestureFlingStart);
} else {
// Forward a wheel event with phase ended and zero deltas.
ForwardMouseWheelEvent(target, gfx::Vector2d(),
blink::WebMouseWheelEvent::kPhaseEnded,
event_timestamp);
}
needs_scroll_begin_ = true;
}
}
......@@ -272,6 +282,18 @@ void SyntheticSmoothMoveGesture::ForwardMouseWheelEvent(
target->DispatchInputEventToPlatform(mouse_wheel_event);
}
void SyntheticSmoothMoveGesture::ForwardFlingGestureEvent(
SyntheticGestureTarget* target,
const blink::WebInputEvent::Type type) const {
blink::WebGestureEvent fling_gesture_event =
SyntheticWebGestureEventBuilder::Build(type,
blink::kWebGestureDeviceTouchpad);
fling_gesture_event.data.fling_start.velocity_x = params_.fling_velocity_x;
fling_gesture_event.data.fling_start.velocity_y = params_.fling_velocity_y;
fling_gesture_event.SetPositionInWidget(current_move_segment_start_position_);
target->DispatchInputEventToPlatform(fling_gesture_event);
}
void SyntheticSmoothMoveGesture::PressPoint(SyntheticGestureTarget* target,
const base::TimeTicks& timestamp) {
DCHECK_EQ(current_move_segment_, 0);
......
......@@ -34,6 +34,8 @@ class CONTENT_EXPORT SyntheticSmoothMoveGestureParams {
gfx::PointF start_point;
std::vector<gfx::Vector2dF> distances;
int speed_in_pixels_s;
int fling_velocity_x;
int fling_velocity_y;
bool prevent_fling;
bool add_slop;
bool precise_scrolling_deltas;
......@@ -78,6 +80,9 @@ class CONTENT_EXPORT SyntheticSmoothMoveGesture : public SyntheticGesture {
const blink::WebMouseWheelEvent::Phase phase,
const base::TimeTicks& timestamp) const;
void ForwardFlingGestureEvent(SyntheticGestureTarget* target,
const blink::WebInputEvent::Type type) const;
void PressPoint(SyntheticGestureTarget* target,
const base::TimeTicks& timestamp);
void MovePoint(SyntheticGestureTarget* target,
......
......@@ -45,6 +45,8 @@ bool SyntheticSmoothScrollGesture::InitializeMoveGesture(
move_params.start_point = params_.anchor;
move_params.distances = params_.distances;
move_params.speed_in_pixels_s = params_.speed_in_pixels_s;
move_params.fling_velocity_x = params_.fling_velocity_x;
move_params.fling_velocity_y = params_.fling_velocity_y;
move_params.prevent_fling = params_.prevent_fling;
move_params.input_type = GetInputSourceType(gesture_type);
move_params.add_slop = true;
......
......@@ -29,6 +29,7 @@ struct CONTENT_EXPORT SyntheticGestureParams {
DEFAULT_INPUT,
TOUCH_INPUT,
MOUSE_INPUT,
TOUCHPAD_INPUT = MOUSE_INPUT,
PEN_INPUT,
GESTURE_SOURCE_TYPE_MAX = PEN_INPUT
};
......
......@@ -16,16 +16,12 @@ const float kDefaultSpeedInPixelsS = 800;
SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams()
: prevent_fling(true),
speed_in_pixels_s(kDefaultSpeedInPixelsS),
fling_velocity_x(0),
fling_velocity_y(0),
precise_scrolling_deltas(false) {}
SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams(
const SyntheticSmoothScrollGestureParams& other)
: SyntheticGestureParams(other),
anchor(other.anchor),
distances(other.distances),
prevent_fling(other.prevent_fling),
speed_in_pixels_s(other.speed_in_pixels_s),
precise_scrolling_deltas(other.precise_scrolling_deltas) {}
const SyntheticSmoothScrollGestureParams& other) = default;
SyntheticSmoothScrollGestureParams::~SyntheticSmoothScrollGestureParams() {}
......
......@@ -28,6 +28,8 @@ struct CONTENT_EXPORT SyntheticSmoothScrollGestureParams
std::vector<gfx::Vector2dF> distances; // Positive X/Y to scroll left/up.
bool prevent_fling; // Defaults to true.
float speed_in_pixels_s;
float fling_velocity_x;
float fling_velocity_y;
bool precise_scrolling_deltas;
static const SyntheticSmoothScrollGestureParams* Cast(
......
......@@ -120,6 +120,8 @@ IPC_STRUCT_TRAITS_BEGIN(content::SyntheticSmoothScrollGestureParams)
IPC_STRUCT_TRAITS_MEMBER(distances)
IPC_STRUCT_TRAITS_MEMBER(prevent_fling)
IPC_STRUCT_TRAITS_MEMBER(speed_in_pixels_s)
IPC_STRUCT_TRAITS_MEMBER(fling_velocity_x)
IPC_STRUCT_TRAITS_MEMBER(fling_velocity_y)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPinchGestureParams)
......
......@@ -288,6 +288,7 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context,
bool prevent_fling,
float start_x,
float start_y,
float fling_velocity,
bool precise_scrolling_deltas) {
gfx::Rect rect = context->render_view_impl()->GetWidget()->ViewRect();
rect -= rect.OffsetFromOrigin();
......@@ -329,28 +330,42 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context,
gesture_params.anchor.SetPoint(start_x, start_y);
DCHECK(gesture_source_type != SyntheticGestureParams::TOUCH_INPUT ||
fling_velocity == 0);
float distance_length = pixels_to_scroll;
gfx::Vector2dF distance;
if (direction == "down")
if (direction == "down") {
distance.set_y(-distance_length);
else if (direction == "up")
gesture_params.fling_velocity_y = fling_velocity;
} else if (direction == "up") {
distance.set_y(distance_length);
else if (direction == "right")
gesture_params.fling_velocity_y = -fling_velocity;
} else if (direction == "right") {
distance.set_x(-distance_length);
else if (direction == "left")
gesture_params.fling_velocity_x = fling_velocity;
} else if (direction == "left") {
distance.set_x(distance_length);
else if (direction == "upleft") {
gesture_params.fling_velocity_x = -fling_velocity;
} else if (direction == "upleft") {
distance.set_y(distance_length);
distance.set_x(distance_length);
gesture_params.fling_velocity_x = -fling_velocity;
gesture_params.fling_velocity_y = -fling_velocity;
} else if (direction == "upright") {
distance.set_y(distance_length);
distance.set_x(-distance_length);
gesture_params.fling_velocity_x = fling_velocity;
gesture_params.fling_velocity_y = -fling_velocity;
} else if (direction == "downleft") {
distance.set_y(-distance_length);
distance.set_x(distance_length);
gesture_params.fling_velocity_x = -fling_velocity;
gesture_params.fling_velocity_y = fling_velocity;
} else if (direction == "downright") {
distance.set_y(-distance_length);
distance.set_x(-distance_length);
gesture_params.fling_velocity_x = fling_velocity;
gesture_params.fling_velocity_y = fling_velocity;
} else {
return false;
}
......@@ -660,7 +675,7 @@ bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) {
EnsureRemoteInterface();
return BeginSmoothScroll(&context, args, input_injector_, pixels_to_scroll,
callback, gesture_source_type, direction,
speed_in_pixels_s, true, start_x, start_y,
speed_in_pixels_s, true, start_x, start_y, 0,
precise_scrolling_deltas);
}
......@@ -706,21 +721,31 @@ bool GpuBenchmarking::Swipe(gin::Arguments* args) {
float start_x = rect.width / 2;
float start_y = rect.height / 2;
float speed_in_pixels_s = 800;
float fling_velocity = 0;
int gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
if (!GetOptionalArg(args, &direction) ||
!GetOptionalArg(args, &pixels_to_scroll) ||
!GetOptionalArg(args, &callback) ||
!GetOptionalArg(args, &start_x) ||
!GetOptionalArg(args, &callback) || !GetOptionalArg(args, &start_x) ||
!GetOptionalArg(args, &start_y) ||
!GetOptionalArg(args, &speed_in_pixels_s)) {
!GetOptionalArg(args, &speed_in_pixels_s) ||
!GetOptionalArg(args, &fling_velocity) ||
!GetOptionalArg(args, &gesture_source_type)) {
return false;
}
// For touchpad swipe, we should be given a fling velocity, but it is not
// needed for touchscreen swipe, because we will calculate the velocity in
// our code.
if (gesture_source_type == SyntheticGestureParams::TOUCHPAD_INPUT &&
fling_velocity == 0)
fling_velocity = 1000;
EnsureRemoteInterface();
return BeginSmoothScroll(
&context, args, input_injector_, -pixels_to_scroll, callback,
1, // TOUCH_INPUT
direction, speed_in_pixels_s, false, start_x, start_y, true);
return BeginSmoothScroll(&context, args, input_injector_, -pixels_to_scroll,
callback, gesture_source_type, direction,
speed_in_pixels_s, false, start_x, start_y,
fling_velocity, true);
}
bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) {
......
......@@ -158,7 +158,8 @@ crbug.com/857490 virtual/user-activation-v2/fast/events/touch/gesture/pad-gestur
crbug.com/857490 virtual/user-activation-v2/fast/events/touch/gesture/touch-gesture-fling-with-page-scale.html [ Skip ]
crbug.com/857490 virtual/user-activation-v2/fast/events/wheel/mainthread-touchpad-fling-latching.html [ Skip ]
crbug.com/857490 virtual/user-activation-v2/fast/events/wheel/wheel-fling-cancel.html [ Skip ]
crbug.com/857490 virtual/paint-touchaction-rects/fast/events/touch/gesture/gesture-scrollbar-fling.html [ Skip ]
crbug.com/857490 virtual/paint-touchaction-rects/fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/857490 virtual/paint-touchaction-rects/fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/857490 virtual/paint-touchaction-rects/fast/events/touch/gesture/pad-gesture-cancel.html [ Skip ]
crbug.com/857490 virtual/paint-touchaction-rects/fast/events/touch/gesture/pad-gesture-fling.html [ Skip ]
crbug.com/857490 virtual/paint-touchaction-rects/fast/events/touch/gesture/touch-gesture-fling-with-page-scale.html [ Skip ]
......@@ -2245,7 +2246,8 @@ crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/pointerevents/po
# regularly on Windows. crbug.com/850964
crbug.com/613672 [ Mac Win ] virtual/threaded/external/wpt/feature-policy/experimental-features/vertical-scroll-touch-block-manual.tentative.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar-fling.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/gesture-scrollbar.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/touch-gesture-noscroll-body-xhidden.html [ Skip ]
......@@ -2262,7 +2264,8 @@ crbug.com/613672 [ Mac ] fast/events/touch/gesture/touch-gesture-scroll-page-pas
crbug.com/613672 [ Mac ] fast/events/touch/gesture/touch-gesture-scroll-page-zoomed.html [ Skip ]
crbug.com/613672 [ Mac ] fast/events/touch/gesture/touch-gesture-scroll-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-scrollbar.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/touch-gesture-noscroll-body-xhidden.html [ Skip ]
......@@ -2279,7 +2282,8 @@ crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/touch-gesture-scroll-page-zoomed.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/mouseevent_fractional/fast/events/touch/gesture/touch-gesture-scroll-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/gesture-scrollbar.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/touch-gesture-noscroll-body-xhidden.html [ Skip ]
......@@ -2296,7 +2300,8 @@ crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/touch-gesture-scroll-page-zoomed.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/scroll_customization/fast/events/touch/gesture/touch-gesture-scroll-page.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scroll.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar-touchpad-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar-touchscreen-fling.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar-mainframe.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/gesture-scrollbar.html [ Skip ]
crbug.com/613672 [ Mac ] virtual/user-activation-v2/fast/events/touch/gesture/touch-gesture-noscroll-body-xhidden.html [ Skip ]
......
<!DOCTYPE html>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/gesture-util.js"></script>
<!-- This tests that the scrollbar thumb is deselected on a fling start -->
<style type="text/css">
::-webkit-scrollbar {
background-color: #ccc;
height: 15px;
width: 15px;
}
::-webkit-scrollbar-button {
display: none;
}
::-webkit-scrollbar-thumb {
background-color: #777;
height: 15px;
width: 15px;
}
::-webkit-scrollbar-thumb:active {
background-color: #333;
}
#scrollable {
height: 300px;
width: 300px;
overflow: scroll;
}
.large {
height: 600px;
width: 600px;
}
</style>
<div id="scrollable">
<div class="large">
</div>
</div>
<script type="text/javascript">
internals.settings.setMockScrollbarsEnabled(true);
promise_test (async () => {
var movingDiv = document.getElementById('scrollable');
var scrollbarX = movingDiv.offsetLeft + movingDiv.offsetWidth - 5;
var scrollThumbSafeOffset = 80;
var scrollbarY = movingDiv.offsetTop + scrollThumbSafeOffset;
var fling_velocity = 1000;
await swipe(10, scrollbarX, scrollbarY, "up", SPEED_INSTANT, fling_velocity, GestureSourceType.TOUCHPAD_INPUT);
await waitFor(() => {return movingDiv.scrollTop > 90; })
});
</script>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<!DOCTYPE html>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/gesture-util.js"></script>
......
......@@ -77,6 +77,7 @@ const GestureSourceType = {
DEFAULT_INPUT: 0,
TOUCH_INPUT: 1,
MOUSE_INPUT: 2,
TOUCHPAD_INPUT:2,
PEN_INPUT: 3
};
......@@ -123,7 +124,7 @@ function pixelsPerTick() {
return 53;
}
function swipe(pixels_to_scroll, start_x, start_y, direction, speed_in_pixels_s) {
function swipe(pixels_to_scroll, start_x, start_y, direction, speed_in_pixels_s, fling_velocity, gesture_source_type) {
return new Promise((resolve, reject) => {
if (chrome && chrome.gpuBenchmarking) {
chrome.gpuBenchmarking.swipe(direction,
......@@ -131,7 +132,9 @@ function swipe(pixels_to_scroll, start_x, start_y, direction, speed_in_pixels_s)
resolve,
start_x,
start_y,
speed_in_pixels_s);
speed_in_pixels_s,
fling_velocity,
gesture_source_type);
} else {
reject('This test requires chrome.gpuBenchmarking');
}
......
......@@ -362,6 +362,11 @@ class WebInputEvent {
return kGesturePinchTypeFirst <= type && type <= kGesturePinchTypeLast;
}
// Returns true if the WebInputEvent |type| is a fling gesture event.
static bool IsFlingGestureEventType(WebInputEvent::Type type) {
return kGestureFlingStart <= type && type <= kGestureFlingCancel;
}
static const char* GetName(WebInputEvent::Type type) {
#define CASE_TYPE(t) \
case WebInputEvent::k##t: \
......
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