Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: content/renderer/input/input_handler_proxy_unittest.cc

Issue 230663004: Fix WebKeyboardEvent interruption of compositor scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/base/swap_promise_monitor.h" 9 #include "cc/base/swap_promise_monitor.h"
10 #include "content/common/input/did_overscroll_params.h" 10 #include "content/common/input/did_overscroll_params.h"
11 #include "content/renderer/input/input_handler_proxy_client.h" 11 #include "content/renderer/input/input_handler_proxy_client.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 14 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
15 #include "third_party/WebKit/public/platform/WebFloatSize.h" 15 #include "third_party/WebKit/public/platform/WebFloatSize.h"
16 #include "third_party/WebKit/public/platform/WebGestureCurve.h" 16 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
17 #include "third_party/WebKit/public/platform/WebPoint.h" 17 #include "third_party/WebKit/public/platform/WebPoint.h"
18 #include "third_party/WebKit/public/web/WebInputEvent.h" 18 #include "third_party/WebKit/public/web/WebInputEvent.h"
19 #include "ui/events/latency_info.h" 19 #include "ui/events/latency_info.h"
20 20
21 using blink::WebActiveWheelFlingParameters; 21 using blink::WebActiveWheelFlingParameters;
22 using blink::WebFloatPoint; 22 using blink::WebFloatPoint;
23 using blink::WebFloatSize; 23 using blink::WebFloatSize;
24 using blink::WebGestureEvent; 24 using blink::WebGestureEvent;
25 using blink::WebInputEvent; 25 using blink::WebInputEvent;
26 using blink::WebKeyboardEvent;
26 using blink::WebMouseWheelEvent; 27 using blink::WebMouseWheelEvent;
27 using blink::WebPoint; 28 using blink::WebPoint;
28 using blink::WebSize; 29 using blink::WebSize;
29 using blink::WebTouchEvent; 30 using blink::WebTouchEvent;
30 using blink::WebTouchPoint; 31 using blink::WebTouchPoint;
31 32
32 namespace content { 33 namespace content {
33 namespace { 34 namespace {
34 35
35 class MockInputHandler : public cc::InputHandler { 36 class MockInputHandler : public cc::InputHandler {
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 WebTouchEvent touch; 1251 WebTouchEvent touch;
1251 touch.type = WebInputEvent::TouchStart; 1252 touch.type = WebInputEvent::TouchStart;
1252 1253
1253 touch.touchesLength = 3; 1254 touch.touchesLength = 3;
1254 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 1255 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
1255 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 1256 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
1256 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 1257 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
1257 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 1258 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
1258 } 1259 }
1259 1260
1261 TEST_F(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) {
1262 // We shouldn't send any events to the widget for this gesture.
1263 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1264 VERIFY_AND_RESET_MOCKS();
1265
1266 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1267 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1268 gesture_.type = WebInputEvent::GestureScrollBegin;
1269 gesture_.sourceDevice = WebGestureEvent::Touchscreen;
1270 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1271 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1272 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1273
1274 // Keyboard events received during a scroll should have no effect.
1275 WebKeyboardEvent key_event;
1276 key_event.type = WebInputEvent::KeyDown;
1277 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
1278 input_handler_->HandleInputEvent(key_event));
1279 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1280 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1281
1282 // On the fling start, animation should be scheduled, but no scrolling occurs.
1283 gesture_.type = WebInputEvent::GestureFlingStart;
1284 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000);
1285 gesture_.data.flingStart.velocityX = fling_delta.x;
1286 gesture_.data.flingStart.velocityY = fling_delta.y;
1287 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1288 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1289 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1290 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1291 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1292 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1293
1294 // Keyboard events received during a fling should cancel the active fling.
1295 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1296 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
1297 input_handler_->HandleInputEvent(key_event));
1298 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1299 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1300
1301 // The call to animate should have no effect, as the fling was cancelled.
1302 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1303 input_handler_->Animate(time);
1304 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1305
1306 // A fling cancel should be dropped, as there is nothing to cancel.
1307 gesture_.type = WebInputEvent::GestureFlingCancel;
1308 EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
1309 input_handler_->HandleInputEvent(gesture_));
1310 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1311 }
1312
1260 } // namespace 1313 } // namespace
1261 } // namespace content 1314 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698