| OLD | NEW |
| 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/renderer/input/input_handler_proxy_client.h" | 10 #include "content/renderer/input/input_handler_proxy_client.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 TEST_F(InputHandlerProxyTest, MouseWheelByPageMainThread) { | 183 TEST_F(InputHandlerProxyTest, MouseWheelByPageMainThread) { |
| 184 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 184 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 185 WebMouseWheelEvent wheel; | 185 WebMouseWheelEvent wheel; |
| 186 wheel.type = WebInputEvent::MouseWheel; | 186 wheel.type = WebInputEvent::MouseWheel; |
| 187 wheel.scrollByPage = true; | 187 wheel.scrollByPage = true; |
| 188 | 188 |
| 189 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); | 189 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
| 190 testing::Mock::VerifyAndClearExpectations(&mock_client_); | 190 testing::Mock::VerifyAndClearExpectations(&mock_client_); |
| 191 } | 191 } |
| 192 | 192 |
| 193 TEST_F(InputHandlerProxyTest, MouseWheelWithCtrl) { |
| 194 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 195 WebMouseWheelEvent wheel; |
| 196 wheel.type = WebInputEvent::MouseWheel; |
| 197 wheel.modifiers = WebInputEvent::ControlKey; |
| 198 |
| 199 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
| 200 testing::Mock::VerifyAndClearExpectations(&mock_client_); |
| 201 } |
| 202 |
| 193 TEST_F(InputHandlerProxyTest, GestureScrollStarted) { | 203 TEST_F(InputHandlerProxyTest, GestureScrollStarted) { |
| 194 // We shouldn't send any events to the widget for this gesture. | 204 // We shouldn't send any events to the widget for this gesture. |
| 195 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 205 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 196 VERIFY_AND_RESET_MOCKS(); | 206 VERIFY_AND_RESET_MOCKS(); |
| 197 | 207 |
| 198 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 208 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 199 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 209 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 200 | 210 |
| 201 gesture_.type = WebInputEvent::GestureScrollBegin; | 211 gesture_.type = WebInputEvent::GestureScrollBegin; |
| 202 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_)); | 212 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_)); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 // We shouldn't send any events to the widget for this gesture. | 471 // We shouldn't send any events to the widget for this gesture. |
| 462 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 472 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 463 VERIFY_AND_RESET_MOCKS(); | 473 VERIFY_AND_RESET_MOCKS(); |
| 464 | 474 |
| 465 // On the fling start, we should schedule an animation but not actually start | 475 // On the fling start, we should schedule an animation but not actually start |
| 466 // scrolling. | 476 // scrolling. |
| 467 gesture_.type = WebInputEvent::GestureFlingStart; | 477 gesture_.type = WebInputEvent::GestureFlingStart; |
| 468 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 478 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
| 469 WebPoint fling_point = WebPoint(7, 13); | 479 WebPoint fling_point = WebPoint(7, 13); |
| 470 WebPoint fling_global_point = WebPoint(17, 23); | 480 WebPoint fling_global_point = WebPoint(17, 23); |
| 471 int modifiers = 7; | 481 // Note that for trackpad, wheel events with the Control modifier are |
| 482 // special (reserved for zoom), so don't set that here. |
| 483 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
| 472 gesture_.data.flingStart.velocityX = fling_delta.x; | 484 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 473 gesture_.data.flingStart.velocityY = fling_delta.y; | 485 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 474 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 486 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
| 475 gesture_.x = fling_point.x; | 487 gesture_.x = fling_point.x; |
| 476 gesture_.y = fling_point.y; | 488 gesture_.y = fling_point.y; |
| 477 gesture_.globalX = fling_global_point.x; | 489 gesture_.globalX = fling_global_point.x; |
| 478 gesture_.globalY = fling_global_point.y; | 490 gesture_.globalY = fling_global_point.y; |
| 479 gesture_.modifiers = modifiers; | 491 gesture_.modifiers = modifiers; |
| 480 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 492 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 481 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 493 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 TEST_F(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { | 581 TEST_F(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { |
| 570 // We shouldn't send any events to the widget for this gesture. | 582 // We shouldn't send any events to the widget for this gesture. |
| 571 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 583 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 572 VERIFY_AND_RESET_MOCKS(); | 584 VERIFY_AND_RESET_MOCKS(); |
| 573 | 585 |
| 574 // Start a gesture fling in the -X direction with zero Y movement. | 586 // Start a gesture fling in the -X direction with zero Y movement. |
| 575 gesture_.type = WebInputEvent::GestureFlingStart; | 587 gesture_.type = WebInputEvent::GestureFlingStart; |
| 576 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 588 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
| 577 WebPoint fling_point = WebPoint(7, 13); | 589 WebPoint fling_point = WebPoint(7, 13); |
| 578 WebPoint fling_global_point = WebPoint(17, 23); | 590 WebPoint fling_global_point = WebPoint(17, 23); |
| 579 int modifiers = 1; | 591 // Note that for trackpad, wheel events with the Control modifier are |
| 592 // special (reserved for zoom), so don't set that here. |
| 593 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
| 580 gesture_.data.flingStart.velocityX = fling_delta.x; | 594 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 581 gesture_.data.flingStart.velocityY = fling_delta.y; | 595 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 582 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 596 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
| 583 gesture_.x = fling_point.x; | 597 gesture_.x = fling_point.x; |
| 584 gesture_.y = fling_point.y; | 598 gesture_.y = fling_point.y; |
| 585 gesture_.globalX = fling_global_point.x; | 599 gesture_.globalX = fling_global_point.x; |
| 586 gesture_.globalY = fling_global_point.y; | 600 gesture_.globalY = fling_global_point.y; |
| 587 gesture_.modifiers = modifiers; | 601 gesture_.modifiers = modifiers; |
| 588 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 602 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 589 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 603 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 689 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 676 | 690 |
| 677 VERIFY_AND_RESET_MOCKS(); | 691 VERIFY_AND_RESET_MOCKS(); |
| 678 input_handler_->MainThreadHasStoppedFlinging(); | 692 input_handler_->MainThreadHasStoppedFlinging(); |
| 679 | 693 |
| 680 // Start a second gesture fling, this time in the +Y direction with no X. | 694 // Start a second gesture fling, this time in the +Y direction with no X. |
| 681 gesture_.type = WebInputEvent::GestureFlingStart; | 695 gesture_.type = WebInputEvent::GestureFlingStart; |
| 682 fling_delta = WebFloatPoint(0, -1000); | 696 fling_delta = WebFloatPoint(0, -1000); |
| 683 fling_point = WebPoint(95, 87); | 697 fling_point = WebPoint(95, 87); |
| 684 fling_global_point = WebPoint(32, 71); | 698 fling_global_point = WebPoint(32, 71); |
| 685 modifiers = 2; | 699 modifiers = WebInputEvent::AltKey; |
| 686 gesture_.data.flingStart.velocityX = fling_delta.x; | 700 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 687 gesture_.data.flingStart.velocityY = fling_delta.y; | 701 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 688 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 702 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
| 689 gesture_.x = fling_point.x; | 703 gesture_.x = fling_point.x; |
| 690 gesture_.y = fling_point.y; | 704 gesture_.y = fling_point.y; |
| 691 gesture_.globalX = fling_global_point.x; | 705 gesture_.globalX = fling_global_point.x; |
| 692 gesture_.globalY = fling_global_point.y; | 706 gesture_.globalY = fling_global_point.y; |
| 693 gesture_.modifiers = modifiers; | 707 gesture_.modifiers = modifiers; |
| 694 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 708 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 695 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 709 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 868 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 855 | 869 |
| 856 VERIFY_AND_RESET_MOCKS(); | 870 VERIFY_AND_RESET_MOCKS(); |
| 857 | 871 |
| 858 // On the fling start, we should schedule an animation but not actually start | 872 // On the fling start, we should schedule an animation but not actually start |
| 859 // scrolling. | 873 // scrolling. |
| 860 gesture_.type = WebInputEvent::GestureFlingStart; | 874 gesture_.type = WebInputEvent::GestureFlingStart; |
| 861 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 875 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
| 862 WebPoint fling_point = WebPoint(7, 13); | 876 WebPoint fling_point = WebPoint(7, 13); |
| 863 WebPoint fling_global_point = WebPoint(17, 23); | 877 WebPoint fling_global_point = WebPoint(17, 23); |
| 864 int modifiers = 7; | 878 // Note that for touchscreen the control modifier is not special. |
| 879 int modifiers = WebInputEvent::ControlKey; |
| 865 gesture_.data.flingStart.velocityX = fling_delta.x; | 880 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 866 gesture_.data.flingStart.velocityY = fling_delta.y; | 881 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 867 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 882 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 868 gesture_.x = fling_point.x; | 883 gesture_.x = fling_point.x; |
| 869 gesture_.y = fling_point.y; | 884 gesture_.y = fling_point.y; |
| 870 gesture_.globalX = fling_global_point.x; | 885 gesture_.globalX = fling_global_point.x; |
| 871 gesture_.globalY = fling_global_point.y; | 886 gesture_.globalY = fling_global_point.y; |
| 872 gesture_.modifiers = modifiers; | 887 gesture_.modifiers = modifiers; |
| 873 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 888 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 874 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 889 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 932 |
| 918 VERIFY_AND_RESET_MOCKS(); | 933 VERIFY_AND_RESET_MOCKS(); |
| 919 | 934 |
| 920 // On the fling start, we should schedule an animation but not actually start | 935 // On the fling start, we should schedule an animation but not actually start |
| 921 // scrolling. | 936 // scrolling. |
| 922 base::TimeDelta startTimeOffset = base::TimeDelta::FromMilliseconds(10); | 937 base::TimeDelta startTimeOffset = base::TimeDelta::FromMilliseconds(10); |
| 923 gesture_.type = WebInputEvent::GestureFlingStart; | 938 gesture_.type = WebInputEvent::GestureFlingStart; |
| 924 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 939 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
| 925 WebPoint fling_point = WebPoint(7, 13); | 940 WebPoint fling_point = WebPoint(7, 13); |
| 926 WebPoint fling_global_point = WebPoint(17, 23); | 941 WebPoint fling_global_point = WebPoint(17, 23); |
| 927 int modifiers = 7; | 942 int modifiers = WebInputEvent::ControlKey; |
| 928 gesture_.timeStampSeconds = startTimeOffset.InSecondsF(); | 943 gesture_.timeStampSeconds = startTimeOffset.InSecondsF(); |
| 929 gesture_.data.flingStart.velocityX = fling_delta.x; | 944 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 930 gesture_.data.flingStart.velocityY = fling_delta.y; | 945 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 931 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 946 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 932 gesture_.x = fling_point.x; | 947 gesture_.x = fling_point.x; |
| 933 gesture_.y = fling_point.y; | 948 gesture_.y = fling_point.y; |
| 934 gesture_.globalX = fling_global_point.x; | 949 gesture_.globalX = fling_global_point.x; |
| 935 gesture_.globalY = fling_global_point.y; | 950 gesture_.globalY = fling_global_point.y; |
| 936 gesture_.modifiers = modifiers; | 951 gesture_.modifiers = modifiers; |
| 937 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 952 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 | 993 |
| 979 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 994 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 980 VERIFY_AND_RESET_MOCKS(); | 995 VERIFY_AND_RESET_MOCKS(); |
| 981 | 996 |
| 982 // On the fling start, we should schedule an animation but not actually start | 997 // On the fling start, we should schedule an animation but not actually start |
| 983 // scrolling. | 998 // scrolling. |
| 984 gesture_.type = WebInputEvent::GestureFlingStart; | 999 gesture_.type = WebInputEvent::GestureFlingStart; |
| 985 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1000 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
| 986 WebPoint fling_point = WebPoint(7, 13); | 1001 WebPoint fling_point = WebPoint(7, 13); |
| 987 WebPoint fling_global_point = WebPoint(17, 23); | 1002 WebPoint fling_global_point = WebPoint(17, 23); |
| 988 int modifiers = 7; | 1003 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; |
| 989 gesture_.data.flingStart.velocityX = fling_delta.x; | 1004 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 990 gesture_.data.flingStart.velocityY = fling_delta.y; | 1005 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 991 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1006 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
| 992 gesture_.x = fling_point.x; | 1007 gesture_.x = fling_point.x; |
| 993 gesture_.y = fling_point.y; | 1008 gesture_.y = fling_point.y; |
| 994 gesture_.globalX = fling_global_point.x; | 1009 gesture_.globalX = fling_global_point.x; |
| 995 gesture_.globalY = fling_global_point.y; | 1010 gesture_.globalY = fling_global_point.y; |
| 996 gesture_.modifiers = modifiers; | 1011 gesture_.modifiers = modifiers; |
| 997 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 1012 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 998 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1013 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 | 1224 |
| 1210 touch.touchesLength = 3; | 1225 touch.touchesLength = 3; |
| 1211 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 1226 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
| 1212 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 1227 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
| 1213 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 1228 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
| 1214 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 1229 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
| 1215 } | 1230 } |
| 1216 | 1231 |
| 1217 } // namespace | 1232 } // namespace |
| 1218 } // namespace content | 1233 } // namespace content |
| OLD | NEW |