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_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, |
| 1031 fling_delta, |
| 1032 fling_point, |
| 1033 fling_global_point, |
| 1034 modifiers); |
| 1035 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1036 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1037 .WillOnce(testing::Return(kImplThreadScrollState)); |
| 1038 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
| 1039 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1040 |
| 1041 VERIFY_AND_RESET_MOCKS(); |
| 1042 |
| 1043 // The first animate call should let us pick up an animation start time, but |
| 1044 // we shouldn't actually move anywhere just yet. The first frame after the |
| 1045 // fling start will typically include the last scroll from the gesture that |
| 1046 // lead to the scroll (either wheel or gesture scroll), so there should be no |
| 1047 // visible hitch. |
| 1048 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1049 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1050 .Times(0); |
| 1051 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 1052 Animate(time); |
| 1053 |
| 1054 VERIFY_AND_RESET_MOCKS(); |
| 1055 |
| 1056 // The second call should punt the fling to the main thread |
| 1057 // because of a passive event listener. |
| 1058 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); |
| 1059 EXPECT_CALL(mock_input_handler_, |
| 1060 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1061 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); |
| 1062 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1063 .Times(0); |
| 1064 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
| 1065 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); |
| 1066 // Expected wheel fling animation parameters: |
| 1067 // *) fling_delta and fling_point should match the original GestureFlingStart |
| 1068 // event |
| 1069 // *) startTime should be 10 to match the time parameter of the first |
| 1070 // Animate() call after the GestureFlingStart |
| 1071 EXPECT_CALL( |
| 1072 mock_client_, |
| 1073 TransferActiveWheelFlingAnimation(testing::AllOf( |
| 1074 testing::Field(&WebActiveWheelFlingParameters::delta, |
| 1075 testing::Eq(fling_delta)), |
| 1076 testing::Field(&WebActiveWheelFlingParameters::point, |
| 1077 testing::Eq(fling_point)), |
| 1078 testing::Field(&WebActiveWheelFlingParameters::globalPoint, |
| 1079 testing::Eq(fling_global_point)), |
| 1080 testing::Field(&WebActiveWheelFlingParameters::modifiers, |
| 1081 testing::Eq(modifiers)), |
| 1082 testing::Field(&WebActiveWheelFlingParameters::startTime, |
| 1083 testing::Eq(10)), |
| 1084 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, |
| 1085 testing::_)))); |
| 1086 time += base::TimeDelta::FromMilliseconds(100); |
| 1087 Animate(time); |
| 1088 |
| 1089 VERIFY_AND_RESET_MOCKS(); |
| 1090 |
| 1091 // Since we've aborted the fling, the next animation should be a no-op and |
| 1092 // should not result in another |
| 1093 // frame being requested. |
| 1094 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); |
| 1095 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1096 .Times(0); |
| 1097 time += base::TimeDelta::FromMilliseconds(100); |
| 1098 Animate(time); |
| 1099 |
| 1100 // Since we've transferred the fling to the main thread, we need to pass the |
| 1101 // next GestureFlingCancel to the main |
| 1102 // thread as well. |
| 1103 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
| 1104 gesture_.type = WebInputEvent::GestureFlingCancel; |
| 1105 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1106 |
| 1107 VERIFY_AND_RESET_MOCKS(); |
| 1108 } |
| 1109 |
962 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { | 1110 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { |
963 // We shouldn't send any events to the widget for this gesture. | 1111 // We shouldn't send any events to the widget for this gesture. |
964 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1112 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
965 VERIFY_AND_RESET_MOCKS(); | 1113 VERIFY_AND_RESET_MOCKS(); |
966 | 1114 |
967 // Start a gesture fling in the -X direction with zero Y movement. | 1115 // Start a gesture fling in the -X direction with zero Y movement. |
968 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1116 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
969 WebPoint fling_point = WebPoint(7, 13); | 1117 WebPoint fling_point = WebPoint(7, 13); |
970 WebPoint fling_global_point = WebPoint(17, 23); | 1118 WebPoint fling_global_point = WebPoint(17, 23); |
971 // Note that for trackpad, wheel events with the Control modifier are | 1119 // Note that for trackpad, wheel events with the Control modifier are |
972 // special (reserved for zoom), so don't set that here. | 1120 // special (reserved for zoom), so don't set that here. |
973 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 1121 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
974 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, | 1122 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
975 fling_delta, | 1123 fling_delta, |
976 fling_point, | 1124 fling_point, |
977 fling_global_point, | 1125 fling_global_point, |
978 modifiers); | 1126 modifiers); |
979 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1127 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
980 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1128 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
981 .WillOnce(testing::Return(kImplThreadScrollState)); | 1129 .WillOnce(testing::Return(kImplThreadScrollState)); |
982 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1130 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
983 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1131 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
984 | |
985 VERIFY_AND_RESET_MOCKS(); | 1132 VERIFY_AND_RESET_MOCKS(); |
986 | 1133 |
987 // Start the fling animation at time 10. This shouldn't actually scroll, just | 1134 // Start the fling animation at time 10. This shouldn't actually scroll, just |
988 // establish a start time. | 1135 // establish a start time. |
989 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1136 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
990 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1137 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
991 .Times(0); | 1138 .Times(0); |
992 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1139 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
993 Animate(time); | 1140 Animate(time); |
994 | 1141 |
995 VERIFY_AND_RESET_MOCKS(); | 1142 VERIFY_AND_RESET_MOCKS(); |
996 | 1143 |
997 // The second call should start scrolling in the -X direction. | 1144 // The second call should start scrolling in the -X direction. |
998 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1145 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1146 EXPECT_CALL(mock_input_handler_, |
| 1147 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1148 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
999 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1149 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1000 .WillOnce(testing::Return(kImplThreadScrollState)); | 1150 .WillOnce(testing::Return(kImplThreadScrollState)); |
1001 EXPECT_CALL( | 1151 EXPECT_CALL( |
1002 mock_input_handler_, | 1152 mock_input_handler_, |
1003 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) | 1153 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) |
1004 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1154 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1005 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1155 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1006 time += base::TimeDelta::FromMilliseconds(100); | 1156 time += base::TimeDelta::FromMilliseconds(100); |
1007 Animate(time); | 1157 Animate(time); |
1008 | 1158 |
1009 VERIFY_AND_RESET_MOCKS(); | 1159 VERIFY_AND_RESET_MOCKS(); |
1010 | 1160 |
1011 // Let's say on the third call we hit a non-scrollable region. We should abort | 1161 // Let's say on the third call we hit a non-scrollable region. We should abort |
1012 // the fling and not scroll. | 1162 // the fling and not scroll. |
1013 // We also should pass the current fling parameters out to the client so the | 1163 // We also should pass the current fling parameters out to the client so the |
1014 // rest of the fling can be | 1164 // rest of the fling can be |
1015 // transferred to the main thread. | 1165 // transferred to the main thread. |
| 1166 EXPECT_CALL(mock_input_handler_, |
| 1167 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1168 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1016 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1169 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1017 .WillOnce(testing::Return(kMainThreadScrollState)); | 1170 .WillOnce(testing::Return(kMainThreadScrollState)); |
1018 | 1171 |
1019 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); | 1172 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
1020 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); | 1173 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); |
1021 | 1174 |
1022 // Expected wheel fling animation parameters: | 1175 // Expected wheel fling animation parameters: |
1023 // *) fling_delta and fling_point should match the original GestureFlingStart | 1176 // *) fling_delta and fling_point should match the original GestureFlingStart |
1024 // event | 1177 // event |
1025 // *) startTime should be 10 to match the time parameter of the first | 1178 // *) 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); | 1243 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1091 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1244 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1092 .Times(0); | 1245 .Times(0); |
1093 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); | 1246 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); |
1094 Animate(time); | 1247 Animate(time); |
1095 | 1248 |
1096 VERIFY_AND_RESET_MOCKS(); | 1249 VERIFY_AND_RESET_MOCKS(); |
1097 | 1250 |
1098 // Tick the second fling once normally. | 1251 // Tick the second fling once normally. |
1099 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1252 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1253 EXPECT_CALL(mock_input_handler_, |
| 1254 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1255 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1100 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1256 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1101 .WillOnce(testing::Return(kImplThreadScrollState)); | 1257 .WillOnce(testing::Return(kImplThreadScrollState)); |
1102 EXPECT_CALL( | 1258 EXPECT_CALL( |
1103 mock_input_handler_, | 1259 mock_input_handler_, |
1104 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) | 1260 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) |
1105 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1261 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1106 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1262 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1107 time += base::TimeDelta::FromMilliseconds(100); | 1263 time += base::TimeDelta::FromMilliseconds(100); |
1108 Animate(time); | 1264 Animate(time); |
1109 | 1265 |
1110 VERIFY_AND_RESET_MOCKS(); | 1266 VERIFY_AND_RESET_MOCKS(); |
1111 | 1267 |
1112 // Then abort the second fling. | 1268 // Then abort the second fling. |
| 1269 EXPECT_CALL(mock_input_handler_, |
| 1270 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1271 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1113 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1272 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1114 .WillOnce(testing::Return(kMainThreadScrollState)); | 1273 .WillOnce(testing::Return(kMainThreadScrollState)); |
1115 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); | 1274 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
1116 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); | 1275 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0); |
1117 | 1276 |
1118 // We should get parameters from the second fling, nothing from the first | 1277 // We should get parameters from the second fling, nothing from the first |
1119 // fling should "leak". | 1278 // fling should "leak". |
1120 EXPECT_CALL( | 1279 EXPECT_CALL( |
1121 mock_client_, | 1280 mock_client_, |
1122 TransferActiveWheelFlingAnimation(testing::AllOf( | 1281 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_)); | 1721 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1563 VERIFY_AND_RESET_MOCKS(); | 1722 VERIFY_AND_RESET_MOCKS(); |
1564 | 1723 |
1565 // The first animate doesn't cause any scrolling. | 1724 // The first animate doesn't cause any scrolling. |
1566 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1725 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1567 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 1726 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
1568 Animate(time); | 1727 Animate(time); |
1569 VERIFY_AND_RESET_MOCKS(); | 1728 VERIFY_AND_RESET_MOCKS(); |
1570 | 1729 |
1571 // The second animate starts scrolling in the positive X and Y directions. | 1730 // The second animate starts scrolling in the positive X and Y directions. |
| 1731 EXPECT_CALL(mock_input_handler_, |
| 1732 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1733 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1572 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1734 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1573 .WillOnce(testing::Return(kImplThreadScrollState)); | 1735 .WillOnce(testing::Return(kImplThreadScrollState)); |
1574 EXPECT_CALL( | 1736 EXPECT_CALL( |
1575 mock_input_handler_, | 1737 mock_input_handler_, |
1576 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) | 1738 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) |
1577 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1739 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1578 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1740 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1579 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1741 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1580 time += base::TimeDelta::FromMilliseconds(100); | 1742 time += base::TimeDelta::FromMilliseconds(100); |
1581 Animate(time); | 1743 Animate(time); |
1582 VERIFY_AND_RESET_MOCKS(); | 1744 VERIFY_AND_RESET_MOCKS(); |
1583 | 1745 |
1584 // The third animate overscrolls in the positive Y direction but scrolls | 1746 // The third animate overscrolls in the positive Y direction but scrolls |
1585 // somewhat. | 1747 // somewhat. |
1586 cc::InputHandlerScrollResult overscroll; | 1748 cc::InputHandlerScrollResult overscroll; |
1587 overscroll.did_scroll = true; | 1749 overscroll.did_scroll = true; |
1588 overscroll.did_overscroll_root = true; | 1750 overscroll.did_overscroll_root = true; |
1589 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); | 1751 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); |
1590 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); | 1752 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); |
| 1753 EXPECT_CALL(mock_input_handler_, |
| 1754 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1755 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1591 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1756 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1592 .WillOnce(testing::Return(kImplThreadScrollState)); | 1757 .WillOnce(testing::Return(kImplThreadScrollState)); |
1593 EXPECT_CALL( | 1758 EXPECT_CALL( |
1594 mock_input_handler_, | 1759 mock_input_handler_, |
1595 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) | 1760 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) |
1596 .WillOnce(testing::Return(overscroll)); | 1761 .WillOnce(testing::Return(overscroll)); |
1597 EXPECT_CALL( | 1762 EXPECT_CALL( |
1598 mock_client_, | 1763 mock_client_, |
1599 DidOverscroll( | 1764 DidOverscroll( |
1600 overscroll.accumulated_root_overscroll, | 1765 overscroll.accumulated_root_overscroll, |
1601 overscroll.unused_scroll_delta, | 1766 overscroll.unused_scroll_delta, |
1602 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), | 1767 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), |
1603 testing::_)); | 1768 testing::_)); |
1604 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1769 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1605 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1770 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1606 time += base::TimeDelta::FromMilliseconds(100); | 1771 time += base::TimeDelta::FromMilliseconds(100); |
1607 Animate(time); | 1772 Animate(time); |
1608 VERIFY_AND_RESET_MOCKS(); | 1773 VERIFY_AND_RESET_MOCKS(); |
1609 | 1774 |
1610 // The next call to animate will no longer scroll vertically. | 1775 // The next call to animate will no longer scroll vertically. |
1611 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1776 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 1777 EXPECT_CALL(mock_input_handler_, |
| 1778 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 1779 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1612 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1780 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1613 .WillOnce(testing::Return(kImplThreadScrollState)); | 1781 .WillOnce(testing::Return(kImplThreadScrollState)); |
1614 EXPECT_CALL( | 1782 EXPECT_CALL( |
1615 mock_input_handler_, | 1783 mock_input_handler_, |
1616 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) | 1784 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) |
1617 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1785 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1618 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 1786 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
1619 time += base::TimeDelta::FromMilliseconds(100); | 1787 time += base::TimeDelta::FromMilliseconds(100); |
1620 Animate(time); | 1788 Animate(time); |
1621 VERIFY_AND_RESET_MOCKS(); | 1789 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()); | 1968 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1801 } | 1969 } |
1802 | 1970 |
1803 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { | 1971 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { |
1804 // None of the three touch points fall in the touch region. So the event | 1972 // None of the three touch points fall in the touch region. So the event |
1805 // should be dropped. | 1973 // should be dropped. |
1806 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 1974 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
1807 VERIFY_AND_RESET_MOCKS(); | 1975 VERIFY_AND_RESET_MOCKS(); |
1808 | 1976 |
1809 EXPECT_CALL(mock_input_handler_, | 1977 EXPECT_CALL(mock_input_handler_, |
1810 DoTouchEventsBlockScrollAt( | 1978 GetEventListenerProperties(cc::EventListenerClass::kTouch)) |
1811 testing::Property(&gfx::Point::x, testing::Gt(0)))) | 1979 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
| 1980 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) |
1812 .WillOnce(testing::Return(false)); | 1981 .WillOnce(testing::Return(false)); |
1813 EXPECT_CALL(mock_input_handler_, | 1982 EXPECT_CALL(mock_input_handler_, |
1814 DoTouchEventsBlockScrollAt( | 1983 DoTouchEventsBlockScrollAt( |
1815 testing::Property(&gfx::Point::x, testing::Lt(0)))) | 1984 testing::Property(&gfx::Point::x, testing::Lt(0)))) |
1816 .WillOnce(testing::Return(false)); | 1985 .WillOnce(testing::Return(false)); |
1817 | 1986 |
1818 WebTouchEvent touch; | 1987 WebTouchEvent touch; |
1819 touch.type = WebInputEvent::TouchStart; | 1988 touch.type = WebInputEvent::TouchStart; |
1820 | 1989 |
1821 touch.touchesLength = 3; | 1990 touch.touchesLength = 3; |
(...skipping 27 matching lines...) Expand all Loading... |
1849 | 2018 |
1850 touch.touchesLength = 3; | 2019 touch.touchesLength = 3; |
1851 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 2020 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
1852 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 2021 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
1853 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 2022 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
1854 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 2023 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
1855 | 2024 |
1856 VERIFY_AND_RESET_MOCKS(); | 2025 VERIFY_AND_RESET_MOCKS(); |
1857 } | 2026 } |
1858 | 2027 |
| 2028 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { |
| 2029 // One of the touch points is on a touch-region. So the event should be sent |
| 2030 // to the main thread. |
| 2031 expected_disposition_ = InputHandlerProxy::NON_BLOCKING; |
| 2032 VERIFY_AND_RESET_MOCKS(); |
| 2033 |
| 2034 EXPECT_CALL(mock_input_handler_, |
| 2035 GetEventListenerProperties(cc::EventListenerClass::kTouch)) |
| 2036 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); |
| 2037 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) |
| 2038 .WillRepeatedly(testing::Return(false)); |
| 2039 |
| 2040 WebTouchEvent touch; |
| 2041 touch.type = WebInputEvent::TouchStart; |
| 2042 |
| 2043 touch.touchesLength = 3; |
| 2044 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
| 2045 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
| 2046 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
| 2047 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
| 2048 |
| 2049 VERIFY_AND_RESET_MOCKS(); |
| 2050 } |
| 2051 |
1859 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { | 2052 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { |
1860 // We shouldn't send any events to the widget for this gesture. | 2053 // We shouldn't send any events to the widget for this gesture. |
1861 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 2054 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1862 VERIFY_AND_RESET_MOCKS(); | 2055 VERIFY_AND_RESET_MOCKS(); |
1863 | 2056 |
1864 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 2057 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1865 .WillOnce(testing::Return(kImplThreadScrollState)); | 2058 .WillOnce(testing::Return(kImplThreadScrollState)); |
1866 gesture_.type = WebInputEvent::GestureScrollBegin; | 2059 gesture_.type = WebInputEvent::GestureScrollBegin; |
1867 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; | 2060 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; |
1868 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 2061 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); | 2723 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); |
2531 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2724 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2532 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); | 2725 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); |
2533 } | 2726 } |
2534 | 2727 |
2535 INSTANTIATE_TEST_CASE_P(AnimateInput, | 2728 INSTANTIATE_TEST_CASE_P(AnimateInput, |
2536 InputHandlerProxyTest, | 2729 InputHandlerProxyTest, |
2537 testing::ValuesIn(test_types)); | 2730 testing::ValuesIn(test_types)); |
2538 } // namespace test | 2731 } // namespace test |
2539 } // namespace ui | 2732 } // namespace ui |
OLD | NEW |