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 "ui/events/blink/input_handler_proxy.h" | 5 #include "ui/events/blink/input_handler_proxy.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "cc/input/main_thread_scrolling_reason.h" | 9 #include "cc/input/main_thread_scrolling_reason.h" |
10 #include "cc/trees/swap_promise_monitor.h" | 10 #include "cc/trees/swap_promise_monitor.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 EXPECT_EQ(expected_disposition_, | 362 EXPECT_EQ(expected_disposition_, |
363 input_handler_->HandleInputEvent(gesture_)); | 363 input_handler_->HandleInputEvent(gesture_)); |
364 | 364 |
365 VERIFY_AND_RESET_MOCKS(); | 365 VERIFY_AND_RESET_MOCKS(); |
366 } | 366 } |
367 | 367 |
368 void SetSmoothScrollEnabled(bool value) { | 368 void SetSmoothScrollEnabled(bool value) { |
369 input_handler_->smooth_scroll_enabled_ = value; | 369 input_handler_->smooth_scroll_enabled_ = value; |
370 } | 370 } |
371 | 371 |
| 372 void SetMouseWheelGesturesOn(bool value) { |
| 373 input_handler_->set_use_gesture_events_for_mouse_wheel(value); |
| 374 } |
| 375 |
372 protected: | 376 protected: |
373 const bool synchronous_root_scroll_; | 377 const bool synchronous_root_scroll_; |
374 const bool install_synchronous_handler_; | 378 const bool install_synchronous_handler_; |
375 testing::StrictMock<MockInputHandler> mock_input_handler_; | 379 testing::StrictMock<MockInputHandler> mock_input_handler_; |
376 testing::StrictMock<MockSynchronousInputHandler> | 380 testing::StrictMock<MockSynchronousInputHandler> |
377 mock_synchronous_input_handler_; | 381 mock_synchronous_input_handler_; |
378 scoped_ptr<ui::InputHandlerProxy> input_handler_; | 382 scoped_ptr<ui::InputHandlerProxy> input_handler_; |
379 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; | 383 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; |
380 WebGestureEvent gesture_; | 384 WebGestureEvent gesture_; |
381 InputHandlerProxy::EventDisposition expected_disposition_; | 385 InputHandlerProxy::EventDisposition expected_disposition_; |
382 cc::InputHandlerScrollResult scroll_result_did_scroll_; | 386 cc::InputHandlerScrollResult scroll_result_did_scroll_; |
383 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; | 387 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; |
384 }; | 388 }; |
385 | 389 |
386 TEST_P(InputHandlerProxyTest, MouseWheelByPageMainThread) { | 390 TEST_P(InputHandlerProxyTest, MouseWheelByPageMainThread) { |
387 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 391 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 392 SetMouseWheelGesturesOn(false); |
388 WebMouseWheelEvent wheel; | 393 WebMouseWheelEvent wheel; |
389 wheel.type = WebInputEvent::MouseWheel; | 394 wheel.type = WebInputEvent::MouseWheel; |
390 wheel.scrollByPage = true; | 395 wheel.scrollByPage = true; |
391 | 396 |
392 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); | 397 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
393 VERIFY_AND_RESET_MOCKS(); | 398 VERIFY_AND_RESET_MOCKS(); |
394 } | 399 } |
395 | 400 |
396 TEST_P(InputHandlerProxyTest, MouseWheelWithCtrlNotScroll) { | 401 TEST_P(InputHandlerProxyTest, MouseWheelWithCtrlNotScroll) { |
397 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 402 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 403 SetMouseWheelGesturesOn(false); |
398 WebMouseWheelEvent wheel; | 404 WebMouseWheelEvent wheel; |
399 wheel.type = WebInputEvent::MouseWheel; | 405 wheel.type = WebInputEvent::MouseWheel; |
400 wheel.modifiers = WebInputEvent::ControlKey; | 406 wheel.modifiers = WebInputEvent::ControlKey; |
401 wheel.canScroll = false; | 407 wheel.canScroll = false; |
402 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); | 408 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
403 VERIFY_AND_RESET_MOCKS(); | 409 VERIFY_AND_RESET_MOCKS(); |
404 } | 410 } |
405 | 411 |
| 412 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { |
| 413 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
| 414 EXPECT_CALL(mock_input_handler_, |
| 415 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 416 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
| 417 |
| 418 WebMouseWheelEvent wheel; |
| 419 wheel.type = WebInputEvent::MouseWheel; |
| 420 wheel.modifiers = WebInputEvent::ControlKey; |
| 421 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
| 422 VERIFY_AND_RESET_MOCKS(); |
| 423 } |
| 424 |
| 425 TEST_P(InputHandlerProxyTest, MouseWheelPassiveListener) { |
| 426 expected_disposition_ = InputHandlerProxy::NON_BLOCKING; |
| 427 EXPECT_CALL(mock_input_handler_, |
| 428 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 429 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); |
| 430 |
| 431 WebMouseWheelEvent wheel; |
| 432 wheel.type = WebInputEvent::MouseWheel; |
| 433 wheel.modifiers = WebInputEvent::ControlKey; |
| 434 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
| 435 VERIFY_AND_RESET_MOCKS(); |
| 436 } |
| 437 |
| 438 TEST_P(InputHandlerProxyTest, MouseWheelBlockingListener) { |
| 439 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 440 EXPECT_CALL(mock_input_handler_, |
| 441 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 442 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); |
| 443 |
| 444 WebMouseWheelEvent wheel; |
| 445 wheel.type = WebInputEvent::MouseWheel; |
| 446 wheel.modifiers = WebInputEvent::ControlKey; |
| 447 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
| 448 VERIFY_AND_RESET_MOCKS(); |
| 449 } |
| 450 |
406 // Mac does not smooth scroll wheel events (crbug.com/574283). | 451 // Mac does not smooth scroll wheel events (crbug.com/574283). |
407 #if !defined(OS_MACOSX) | 452 #if !defined(OS_MACOSX) |
408 TEST_P(InputHandlerProxyTest, MouseWheelWithPreciseScrollingDeltas) { | 453 TEST_P(InputHandlerProxyTest, MouseWheelWithPreciseScrollingDeltas) { |
409 #else | 454 #else |
410 TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelWithPreciseScrollingDeltas) { | 455 TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelWithPreciseScrollingDeltas) { |
411 #endif | 456 #endif |
412 SetSmoothScrollEnabled(true); | 457 SetSmoothScrollEnabled(true); |
| 458 SetMouseWheelGesturesOn(false); |
413 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 459 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
414 WebMouseWheelEvent wheel; | 460 WebMouseWheelEvent wheel; |
415 wheel.type = WebInputEvent::MouseWheel; | 461 wheel.type = WebInputEvent::MouseWheel; |
416 | 462 |
417 VERIFY_AND_RESET_MOCKS(); | 463 VERIFY_AND_RESET_MOCKS(); |
418 | 464 |
419 // Smooth scroll because hasPreciseScrollingDeltas is set to false. | 465 // Smooth scroll because hasPreciseScrollingDeltas is set to false. |
420 wheel.hasPreciseScrollingDeltas = false; | 466 wheel.hasPreciseScrollingDeltas = false; |
421 EXPECT_CALL(mock_input_handler_, ScrollAnimated(::testing::_, ::testing::_)) | 467 EXPECT_CALL(mock_input_handler_, ScrollAnimated(::testing::_, ::testing::_)) |
422 .WillOnce(testing::Return(kImplThreadScrollState)); | 468 .WillOnce(testing::Return(kImplThreadScrollState)); |
(...skipping 13 matching lines...) Expand all Loading... |
436 VERIFY_AND_RESET_MOCKS(); | 482 VERIFY_AND_RESET_MOCKS(); |
437 } | 483 } |
438 | 484 |
439 // Mac does not smooth scroll wheel events (crbug.com/574283). | 485 // Mac does not smooth scroll wheel events (crbug.com/574283). |
440 #if !defined(OS_MACOSX) | 486 #if !defined(OS_MACOSX) |
441 TEST_P(InputHandlerProxyTest, MouseWheelScrollIgnored) { | 487 TEST_P(InputHandlerProxyTest, MouseWheelScrollIgnored) { |
442 #else | 488 #else |
443 TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelScrollIgnored) { | 489 TEST_P(InputHandlerProxyTest, DISABLED_MouseWheelScrollIgnored) { |
444 #endif | 490 #endif |
445 SetSmoothScrollEnabled(true); | 491 SetSmoothScrollEnabled(true); |
| 492 SetMouseWheelGesturesOn(false); |
446 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 493 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
447 WebMouseWheelEvent wheel; | 494 WebMouseWheelEvent wheel; |
448 wheel.type = WebInputEvent::MouseWheel; | 495 wheel.type = WebInputEvent::MouseWheel; |
449 | 496 |
450 EXPECT_CALL(mock_input_handler_, ScrollAnimated(testing::_, testing::_)) | 497 EXPECT_CALL(mock_input_handler_, ScrollAnimated(testing::_, testing::_)) |
451 .WillOnce(testing::Return(kScrollIgnoredScrollState)); | 498 .WillOnce(testing::Return(kScrollIgnoredScrollState)); |
452 | 499 |
453 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); | 500 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
454 VERIFY_AND_RESET_MOCKS(); | 501 VERIFY_AND_RESET_MOCKS(); |
455 } | 502 } |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 fling_point, | 917 fling_point, |
871 fling_global_point, | 918 fling_global_point, |
872 modifiers); | 919 modifiers); |
873 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 920 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
874 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 921 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
875 .WillOnce(testing::Return(kImplThreadScrollState)); | 922 .WillOnce(testing::Return(kImplThreadScrollState)); |
876 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 923 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
877 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 924 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
878 | 925 |
879 VERIFY_AND_RESET_MOCKS(); | 926 VERIFY_AND_RESET_MOCKS(); |
| 927 |
880 // The first animate call should let us pick up an animation start time, but | 928 // The first animate call should let us pick up an animation start time, but |
881 // we shouldn't actually move anywhere just yet. The first frame after the | 929 // we shouldn't actually move anywhere just yet. The first frame after the |
882 // fling start will typically include the last scroll from the gesture that | 930 // fling start will typically include the last scroll from the gesture that |
883 // lead to the scroll (either wheel or gesture scroll), so there should be no | 931 // lead to the scroll (either wheel or gesture scroll), so there should be no |
884 // visible hitch. | 932 // visible hitch. |
885 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 933 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
886 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 934 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
887 .Times(0); | 935 .Times(0); |
888 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 936 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
889 Animate(time); | 937 Animate(time); |
890 | 938 |
891 VERIFY_AND_RESET_MOCKS(); | 939 VERIFY_AND_RESET_MOCKS(); |
892 | 940 |
893 // The second call should start scrolling in the -X direction. | 941 // The second call should start scrolling in the -X direction. |
894 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 942 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 943 EXPECT_CALL(mock_input_handler_, |
| 944 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 945 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
895 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 946 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
896 .WillOnce(testing::Return(kImplThreadScrollState)); | 947 .WillOnce(testing::Return(kImplThreadScrollState)); |
897 EXPECT_CALL( | 948 EXPECT_CALL( |
898 mock_input_handler_, | 949 mock_input_handler_, |
899 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) | 950 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) |
900 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 951 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
901 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 952 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
902 time += base::TimeDelta::FromMilliseconds(100); | 953 time += base::TimeDelta::FromMilliseconds(100); |
903 Animate(time); | 954 Animate(time); |
904 | 955 |
905 VERIFY_AND_RESET_MOCKS(); | 956 VERIFY_AND_RESET_MOCKS(); |
906 | 957 |
907 // Let's say on the third call we hit a non-scrollable region. We should abort | 958 // Let's say on the third call we hit a non-scrollable region. We should abort |
908 // the fling and not scroll. | 959 // the fling and not scroll. |
909 // We also should pass the current fling parameters out to the client so the | 960 // We also should pass the current fling parameters out to the client so the |
910 // rest of the fling can be | 961 // rest of the fling can be |
911 // transferred to the main thread. | 962 // transferred to the main thread. |
| 963 EXPECT_CALL(mock_input_handler_, |
| 964 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 965 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
912 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 966 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
913 .WillOnce(testing::Return(kMainThreadScrollState)); | 967 .WillOnce(testing::Return(kMainThreadScrollState)); |
914 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); | 968 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
915 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); | 969 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); |
916 // Expected wheel fling animation parameters: | 970 // Expected wheel fling animation parameters: |
917 // *) fling_delta and fling_point should match the original GestureFlingStart | 971 // *) fling_delta and fling_point should match the original GestureFlingStart |
918 // event | 972 // event |
919 // *) startTime should be 10 to match the time parameter of the first | 973 // *) startTime should be 10 to match the time parameter of the first |
920 // Animate() call after the GestureFlingStart | 974 // Animate() call after the GestureFlingStart |
921 // *) cumulativeScroll depends on the curve, but since we've animated in the | 975 // *) cumulativeScroll depends on the curve, but since we've animated in the |
(...skipping 30 matching lines...) Expand all Loading... |
952 // Since we've transferred the fling to the main thread, we need to pass the | 1006 // Since we've transferred the fling to the main thread, we need to pass the |
953 // next GestureFlingCancel to the main | 1007 // next GestureFlingCancel to the main |
954 // thread as well. | 1008 // thread as well. |
955 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 1009 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
956 gesture_.type = WebInputEvent::GestureFlingCancel; | 1010 gesture_.type = WebInputEvent::GestureFlingCancel; |
957 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1011 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
958 | 1012 |
959 VERIFY_AND_RESET_MOCKS(); | 1013 VERIFY_AND_RESET_MOCKS(); |
960 } | 1014 } |
961 | 1015 |
| 1016 TEST_P(InputHandlerProxyTest, GestureFlingPassiveListener) { |
| 1017 // We shouldn't send any events to the widget for this gesture. |
| 1018 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 1019 VERIFY_AND_RESET_MOCKS(); |
| 1020 |
| 1021 // On the fling start, we should schedule an animation but not actually start |
| 1022 // scrolling. |
| 1023 gesture_.type = WebInputEvent::GestureFlingStart; |
| 1024 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
| 1025 WebPoint fling_point = WebPoint(7, 13); |
| 1026 WebPoint fling_global_point = WebPoint(17, 23); |
| 1027 // Note that for trackpad, wheel events with the Control modifier are |
| 1028 // special (reserved for zoom), so don't set that here. |
| 1029 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
| 1030 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, fling_delta, |
| 1031 fling_point, fling_global_point, modifiers); |
| 1032 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1033 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1034 .WillOnce(testing::Return(kImplThreadScrollState)); |
| 1035 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
| 1036 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1037 |
| 1038 VERIFY_AND_RESET_MOCKS(); |
| 1039 |
| 1040 // The first animate call should let us pick up an animation start time, but |
| 1041 // we shouldn't actually move anywhere just yet. The first frame after the |
| 1042 // fling start will typically include the last scroll from the gesture that |
| 1043 // lead to the scroll (either wheel or gesture scroll), so there should be no |
| 1044 // visible hitch. |
| 1045 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1046 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1047 .Times(0); |
| 1048 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 1049 Animate(time); |
| 1050 |
| 1051 VERIFY_AND_RESET_MOCKS(); |
| 1052 |
| 1053 // The second call should punt the fling to the main thread |
| 1054 // because of a passive event listener. |
| 1055 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); |
| 1056 EXPECT_CALL(mock_input_handler_, |
| 1057 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1058 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); |
| 1059 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1060 .Times(0); |
| 1061 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
| 1062 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); |
| 1063 // Expected wheel fling animation parameters: |
| 1064 // *) fling_delta and fling_point should match the original GestureFlingStart |
| 1065 // event |
| 1066 // *) startTime should be 10 to match the time parameter of the first |
| 1067 // Animate() call after the GestureFlingStart |
| 1068 EXPECT_CALL( |
| 1069 mock_client_, |
| 1070 TransferActiveWheelFlingAnimation(testing::AllOf( |
| 1071 testing::Field(&WebActiveWheelFlingParameters::delta, |
| 1072 testing::Eq(fling_delta)), |
| 1073 testing::Field(&WebActiveWheelFlingParameters::point, |
| 1074 testing::Eq(fling_point)), |
| 1075 testing::Field(&WebActiveWheelFlingParameters::globalPoint, |
| 1076 testing::Eq(fling_global_point)), |
| 1077 testing::Field(&WebActiveWheelFlingParameters::modifiers, |
| 1078 testing::Eq(modifiers)), |
| 1079 testing::Field(&WebActiveWheelFlingParameters::startTime, |
| 1080 testing::Eq(10)), |
| 1081 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, |
| 1082 testing::_)))); |
| 1083 time += base::TimeDelta::FromMilliseconds(100); |
| 1084 Animate(time); |
| 1085 |
| 1086 VERIFY_AND_RESET_MOCKS(); |
| 1087 |
| 1088 // Since we've aborted the fling, the next animation should be a no-op and |
| 1089 // should not result in another |
| 1090 // frame being requested. |
| 1091 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); |
| 1092 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1093 .Times(0); |
| 1094 time += base::TimeDelta::FromMilliseconds(100); |
| 1095 Animate(time); |
| 1096 |
| 1097 // Since we've transferred the fling to the main thread, we need to pass the |
| 1098 // next GestureFlingCancel to the main |
| 1099 // thread as well. |
| 1100 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 1101 gesture_.type = WebInputEvent::GestureFlingCancel; |
| 1102 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1103 |
| 1104 VERIFY_AND_RESET_MOCKS(); |
| 1105 } |
| 1106 |
962 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { | 1107 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { |
963 // We shouldn't send any events to the widget for this gesture. | 1108 // We shouldn't send any events to the widget for this gesture. |
964 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1109 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
965 VERIFY_AND_RESET_MOCKS(); | 1110 VERIFY_AND_RESET_MOCKS(); |
966 | 1111 |
967 // Start a gesture fling in the -X direction with zero Y movement. | 1112 // Start a gesture fling in the -X direction with zero Y movement. |
968 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1113 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
969 WebPoint fling_point = WebPoint(7, 13); | 1114 WebPoint fling_point = WebPoint(7, 13); |
970 WebPoint fling_global_point = WebPoint(17, 23); | 1115 WebPoint fling_global_point = WebPoint(17, 23); |
971 // Note that for trackpad, wheel events with the Control modifier are | 1116 // Note that for trackpad, wheel events with the Control modifier are |
972 // special (reserved for zoom), so don't set that here. | 1117 // special (reserved for zoom), so don't set that here. |
973 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 1118 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
974 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, | 1119 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
975 fling_delta, | 1120 fling_delta, |
976 fling_point, | 1121 fling_point, |
977 fling_global_point, | 1122 fling_global_point, |
978 modifiers); | 1123 modifiers); |
979 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1124 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
980 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1125 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
981 .WillOnce(testing::Return(kImplThreadScrollState)); | 1126 .WillOnce(testing::Return(kImplThreadScrollState)); |
982 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1127 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
983 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1128 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
984 | |
985 VERIFY_AND_RESET_MOCKS(); | 1129 VERIFY_AND_RESET_MOCKS(); |
986 | 1130 |
987 // Start the fling animation at time 10. This shouldn't actually scroll, just | 1131 // Start the fling animation at time 10. This shouldn't actually scroll, just |
988 // establish a start time. | 1132 // establish a start time. |
989 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1133 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
990 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1134 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
991 .Times(0); | 1135 .Times(0); |
992 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1136 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
993 Animate(time); | 1137 Animate(time); |
994 | 1138 |
995 VERIFY_AND_RESET_MOCKS(); | 1139 VERIFY_AND_RESET_MOCKS(); |
996 | 1140 |
997 // The second call should start scrolling in the -X direction. | 1141 // The second call should start scrolling in the -X direction. |
998 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1142 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1143 EXPECT_CALL(mock_input_handler_, |
| 1144 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1145 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
999 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1146 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1000 .WillOnce(testing::Return(kImplThreadScrollState)); | 1147 .WillOnce(testing::Return(kImplThreadScrollState)); |
1001 EXPECT_CALL( | 1148 EXPECT_CALL( |
1002 mock_input_handler_, | 1149 mock_input_handler_, |
1003 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) | 1150 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) |
1004 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1151 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1005 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1152 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1006 time += base::TimeDelta::FromMilliseconds(100); | 1153 time += base::TimeDelta::FromMilliseconds(100); |
1007 Animate(time); | 1154 Animate(time); |
1008 | 1155 |
1009 VERIFY_AND_RESET_MOCKS(); | 1156 VERIFY_AND_RESET_MOCKS(); |
1010 | 1157 |
1011 // Let's say on the third call we hit a non-scrollable region. We should abort | 1158 // Let's say on the third call we hit a non-scrollable region. We should abort |
1012 // the fling and not scroll. | 1159 // the fling and not scroll. |
1013 // We also should pass the current fling parameters out to the client so the | 1160 // We also should pass the current fling parameters out to the client so the |
1014 // rest of the fling can be | 1161 // rest of the fling can be |
1015 // transferred to the main thread. | 1162 // transferred to the main thread. |
| 1163 EXPECT_CALL(mock_input_handler_, |
| 1164 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1165 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1016 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1166 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1017 .WillOnce(testing::Return(kMainThreadScrollState)); | 1167 .WillOnce(testing::Return(kMainThreadScrollState)); |
1018 | 1168 |
1019 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); | 1169 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
1020 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); | 1170 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); |
1021 | 1171 |
1022 // Expected wheel fling animation parameters: | 1172 // Expected wheel fling animation parameters: |
1023 // *) fling_delta and fling_point should match the original GestureFlingStart | 1173 // *) fling_delta and fling_point should match the original GestureFlingStart |
1024 // event | 1174 // event |
1025 // *) startTime should be 10 to match the time parameter of the first | 1175 // *) startTime should be 10 to match the time parameter of the first |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1240 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1091 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1241 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1092 .Times(0); | 1242 .Times(0); |
1093 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); | 1243 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); |
1094 Animate(time); | 1244 Animate(time); |
1095 | 1245 |
1096 VERIFY_AND_RESET_MOCKS(); | 1246 VERIFY_AND_RESET_MOCKS(); |
1097 | 1247 |
1098 // Tick the second fling once normally. | 1248 // Tick the second fling once normally. |
1099 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1249 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1250 EXPECT_CALL(mock_input_handler_, |
| 1251 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1252 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1100 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1253 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1101 .WillOnce(testing::Return(kImplThreadScrollState)); | 1254 .WillOnce(testing::Return(kImplThreadScrollState)); |
1102 EXPECT_CALL( | 1255 EXPECT_CALL( |
1103 mock_input_handler_, | 1256 mock_input_handler_, |
1104 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) | 1257 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) |
1105 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1258 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1106 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1259 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1107 time += base::TimeDelta::FromMilliseconds(100); | 1260 time += base::TimeDelta::FromMilliseconds(100); |
1108 Animate(time); | 1261 Animate(time); |
1109 | 1262 |
1110 VERIFY_AND_RESET_MOCKS(); | 1263 VERIFY_AND_RESET_MOCKS(); |
1111 | 1264 |
1112 // Then abort the second fling. | 1265 // Then abort the second fling. |
| 1266 EXPECT_CALL(mock_input_handler_, |
| 1267 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1268 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1113 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1269 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1114 .WillOnce(testing::Return(kMainThreadScrollState)); | 1270 .WillOnce(testing::Return(kMainThreadScrollState)); |
1115 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); | 1271 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
1116 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); | 1272 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); |
1117 | 1273 |
1118 // We should get parameters from the second fling, nothing from the first | 1274 // We should get parameters from the second fling, nothing from the first |
1119 // fling should "leak". | 1275 // fling should "leak". |
1120 EXPECT_CALL( | 1276 EXPECT_CALL( |
1121 mock_client_, | 1277 mock_client_, |
1122 TransferActiveWheelFlingAnimation(testing::AllOf( | 1278 TransferActiveWheelFlingAnimation(testing::AllOf( |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1718 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1563 VERIFY_AND_RESET_MOCKS(); | 1719 VERIFY_AND_RESET_MOCKS(); |
1564 | 1720 |
1565 // The first animate doesn't cause any scrolling. | 1721 // The first animate doesn't cause any scrolling. |
1566 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1722 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1567 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1723 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
1568 Animate(time); | 1724 Animate(time); |
1569 VERIFY_AND_RESET_MOCKS(); | 1725 VERIFY_AND_RESET_MOCKS(); |
1570 | 1726 |
1571 // The second animate starts scrolling in the positive X and Y directions. | 1727 // The second animate starts scrolling in the positive X and Y directions. |
| 1728 EXPECT_CALL(mock_input_handler_, |
| 1729 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1730 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1572 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1731 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1573 .WillOnce(testing::Return(kImplThreadScrollState)); | 1732 .WillOnce(testing::Return(kImplThreadScrollState)); |
1574 EXPECT_CALL( | 1733 EXPECT_CALL( |
1575 mock_input_handler_, | 1734 mock_input_handler_, |
1576 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) | 1735 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) |
1577 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1736 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1578 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1737 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1579 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1738 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1580 time += base::TimeDelta::FromMilliseconds(100); | 1739 time += base::TimeDelta::FromMilliseconds(100); |
1581 Animate(time); | 1740 Animate(time); |
1582 VERIFY_AND_RESET_MOCKS(); | 1741 VERIFY_AND_RESET_MOCKS(); |
1583 | 1742 |
1584 // The third animate overscrolls in the positive Y direction but scrolls | 1743 // The third animate overscrolls in the positive Y direction but scrolls |
1585 // somewhat. | 1744 // somewhat. |
1586 cc::InputHandlerScrollResult overscroll; | 1745 cc::InputHandlerScrollResult overscroll; |
1587 overscroll.did_scroll = true; | 1746 overscroll.did_scroll = true; |
1588 overscroll.did_overscroll_root = true; | 1747 overscroll.did_overscroll_root = true; |
1589 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); | 1748 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); |
1590 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); | 1749 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); |
| 1750 EXPECT_CALL(mock_input_handler_, |
| 1751 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1752 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1591 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1753 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1592 .WillOnce(testing::Return(kImplThreadScrollState)); | 1754 .WillOnce(testing::Return(kImplThreadScrollState)); |
1593 EXPECT_CALL( | 1755 EXPECT_CALL( |
1594 mock_input_handler_, | 1756 mock_input_handler_, |
1595 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) | 1757 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) |
1596 .WillOnce(testing::Return(overscroll)); | 1758 .WillOnce(testing::Return(overscroll)); |
1597 EXPECT_CALL( | 1759 EXPECT_CALL( |
1598 mock_client_, | 1760 mock_client_, |
1599 DidOverscroll( | 1761 DidOverscroll( |
1600 overscroll.accumulated_root_overscroll, | 1762 overscroll.accumulated_root_overscroll, |
1601 overscroll.unused_scroll_delta, | 1763 overscroll.unused_scroll_delta, |
1602 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), | 1764 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), |
1603 testing::_)); | 1765 testing::_)); |
1604 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1766 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1605 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1767 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1606 time += base::TimeDelta::FromMilliseconds(100); | 1768 time += base::TimeDelta::FromMilliseconds(100); |
1607 Animate(time); | 1769 Animate(time); |
1608 VERIFY_AND_RESET_MOCKS(); | 1770 VERIFY_AND_RESET_MOCKS(); |
1609 | 1771 |
1610 // The next call to animate will no longer scroll vertically. | 1772 // The next call to animate will no longer scroll vertically. |
1611 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1773 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1774 EXPECT_CALL(mock_input_handler_, |
| 1775 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1776 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1612 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1777 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1613 .WillOnce(testing::Return(kImplThreadScrollState)); | 1778 .WillOnce(testing::Return(kImplThreadScrollState)); |
1614 EXPECT_CALL( | 1779 EXPECT_CALL( |
1615 mock_input_handler_, | 1780 mock_input_handler_, |
1616 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) | 1781 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) |
1617 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1782 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1618 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1783 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1619 time += base::TimeDelta::FromMilliseconds(100); | 1784 time += base::TimeDelta::FromMilliseconds(100); |
1620 Animate(time); | 1785 Animate(time); |
1621 VERIFY_AND_RESET_MOCKS(); | 1786 VERIFY_AND_RESET_MOCKS(); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1965 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1801 } | 1966 } |
1802 | 1967 |
1803 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { | 1968 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { |
1804 // None of the three touch points fall in the touch region. So the event | 1969 // None of the three touch points fall in the touch region. So the event |
1805 // should be dropped. | 1970 // should be dropped. |
1806 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 1971 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
1807 VERIFY_AND_RESET_MOCKS(); | 1972 VERIFY_AND_RESET_MOCKS(); |
1808 | 1973 |
1809 EXPECT_CALL(mock_input_handler_, | 1974 EXPECT_CALL(mock_input_handler_, |
1810 DoTouchEventsBlockScrollAt( | 1975 GetEventListenerProperties(cc::EventListenerClass::kTouch)) |
1811 testing::Property(&gfx::Point::x, testing::Gt(0)))) | 1976 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
| 1977 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) |
1812 .WillOnce(testing::Return(false)); | 1978 .WillOnce(testing::Return(false)); |
1813 EXPECT_CALL(mock_input_handler_, | 1979 EXPECT_CALL(mock_input_handler_, |
1814 DoTouchEventsBlockScrollAt( | 1980 DoTouchEventsBlockScrollAt( |
1815 testing::Property(&gfx::Point::x, testing::Lt(0)))) | 1981 testing::Property(&gfx::Point::x, testing::Lt(0)))) |
1816 .WillOnce(testing::Return(false)); | 1982 .WillOnce(testing::Return(false)); |
1817 | 1983 |
1818 WebTouchEvent touch; | 1984 WebTouchEvent touch; |
1819 touch.type = WebInputEvent::TouchStart; | 1985 touch.type = WebInputEvent::TouchStart; |
1820 | 1986 |
1821 touch.touchesLength = 3; | 1987 touch.touchesLength = 3; |
(...skipping 27 matching lines...) Expand all Loading... |
1849 | 2015 |
1850 touch.touchesLength = 3; | 2016 touch.touchesLength = 3; |
1851 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 2017 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
1852 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 2018 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
1853 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 2019 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
1854 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 2020 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
1855 | 2021 |
1856 VERIFY_AND_RESET_MOCKS(); | 2022 VERIFY_AND_RESET_MOCKS(); |
1857 } | 2023 } |
1858 | 2024 |
| 2025 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { |
| 2026 // One of the touch points is on a touch-region. So the event should be sent |
| 2027 // to the main thread. |
| 2028 expected_disposition_ = InputHandlerProxy::NON_BLOCKING; |
| 2029 VERIFY_AND_RESET_MOCKS(); |
| 2030 |
| 2031 EXPECT_CALL(mock_input_handler_, |
| 2032 GetEventListenerProperties(cc::EventListenerClass::kTouch)) |
| 2033 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); |
| 2034 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) |
| 2035 .WillRepeatedly(testing::Return(false)); |
| 2036 |
| 2037 WebTouchEvent touch; |
| 2038 touch.type = WebInputEvent::TouchStart; |
| 2039 |
| 2040 touch.touchesLength = 3; |
| 2041 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
| 2042 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
| 2043 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
| 2044 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
| 2045 |
| 2046 VERIFY_AND_RESET_MOCKS(); |
| 2047 } |
| 2048 |
1859 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { | 2049 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { |
1860 // We shouldn't send any events to the widget for this gesture. | 2050 // We shouldn't send any events to the widget for this gesture. |
1861 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 2051 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1862 VERIFY_AND_RESET_MOCKS(); | 2052 VERIFY_AND_RESET_MOCKS(); |
1863 | 2053 |
1864 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 2054 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1865 .WillOnce(testing::Return(kImplThreadScrollState)); | 2055 .WillOnce(testing::Return(kImplThreadScrollState)); |
1866 gesture_.type = WebInputEvent::GestureScrollBegin; | 2056 gesture_.type = WebInputEvent::GestureScrollBegin; |
1867 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; | 2057 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; |
1868 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 2058 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2530 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); | 2720 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); |
2531 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2721 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2532 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); | 2722 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); |
2533 } | 2723 } |
2534 | 2724 |
2535 INSTANTIATE_TEST_CASE_P(AnimateInput, | 2725 INSTANTIATE_TEST_CASE_P(AnimateInput, |
2536 InputHandlerProxyTest, | 2726 InputHandlerProxyTest, |
2537 testing::ValuesIn(test_types)); | 2727 testing::ValuesIn(test_types)); |
2538 } // namespace test | 2728 } // namespace test |
2539 } // namespace ui | 2729 } // namespace ui |
OLD | NEW |