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/common/input/did_overscroll_params.h" | 10 #include "content/common/input/did_overscroll_params.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 using blink::WebTouchPoint; | 31 using blink::WebTouchPoint; |
32 | 32 |
33 namespace content { | 33 namespace content { |
34 namespace { | 34 namespace { |
35 | 35 |
36 double InSecondsF(const base::TimeTicks& time) { | 36 double InSecondsF(const base::TimeTicks& time) { |
37 return (time - base::TimeTicks()).InSecondsF(); | 37 return (time - base::TimeTicks()).InSecondsF(); |
38 } | 38 } |
39 | 39 |
40 WebGestureEvent CreateFling(base::TimeTicks timestamp, | 40 WebGestureEvent CreateFling(base::TimeTicks timestamp, |
41 WebGestureEvent::SourceDevice source_device, | 41 WebGestureDevice source_device, |
42 WebFloatPoint velocity, | 42 WebFloatPoint velocity, |
43 WebPoint point, | 43 WebPoint point, |
44 WebPoint global_point, | 44 WebPoint global_point, |
45 int modifiers) { | 45 int modifiers) { |
46 WebGestureEvent fling; | 46 WebGestureEvent fling; |
47 fling.type = WebInputEvent::GestureFlingStart; | 47 fling.type = WebInputEvent::GestureFlingStart; |
48 fling.sourceDevice = source_device; | 48 fling.sourceDevice = source_device; |
49 fling.timeStampSeconds = (timestamp - base::TimeTicks()).InSecondsF(); | 49 fling.timeStampSeconds = (timestamp - base::TimeTicks()).InSecondsF(); |
50 fling.data.flingStart.velocityX = velocity.x; | 50 fling.data.flingStart.velocityX = velocity.x; |
51 fling.data.flingStart.velocityY = velocity.y; | 51 fling.data.flingStart.velocityY = velocity.y; |
52 fling.x = point.x; | 52 fling.x = point.x; |
53 fling.y = point.y; | 53 fling.y = point.y; |
54 fling.globalX = global_point.x; | 54 fling.globalX = global_point.x; |
55 fling.globalY = global_point.y; | 55 fling.globalY = global_point.y; |
56 fling.modifiers = modifiers; | 56 fling.modifiers = modifiers; |
57 return fling; | 57 return fling; |
58 } | 58 } |
59 | 59 |
60 WebGestureEvent CreateFling(WebGestureEvent::SourceDevice source_device, | 60 WebGestureEvent CreateFling(WebGestureDevice source_device, |
61 WebFloatPoint velocity, | 61 WebFloatPoint velocity, |
62 WebPoint point, | 62 WebPoint point, |
63 WebPoint global_point, | 63 WebPoint global_point, |
64 int modifiers) { | 64 int modifiers) { |
65 return CreateFling(base::TimeTicks(), | 65 return CreateFling(base::TimeTicks(), |
66 source_device, | 66 source_device, |
67 velocity, | 67 velocity, |
68 point, | 68 point, |
69 global_point, | 69 global_point, |
70 modifiers); | 70 modifiers); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // This is defined as a macro because when an expectation is not satisfied the | 204 // This is defined as a macro because when an expectation is not satisfied the |
205 // only output you get | 205 // only output you get |
206 // out of gmock is the line number that set the expectation. | 206 // out of gmock is the line number that set the expectation. |
207 #define VERIFY_AND_RESET_MOCKS() \ | 207 #define VERIFY_AND_RESET_MOCKS() \ |
208 do { \ | 208 do { \ |
209 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \ | 209 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \ |
210 testing::Mock::VerifyAndClearExpectations(&mock_client_); \ | 210 testing::Mock::VerifyAndClearExpectations(&mock_client_); \ |
211 } while (false) | 211 } while (false) |
212 | 212 |
213 void StartFling(base::TimeTicks timestamp, | 213 void StartFling(base::TimeTicks timestamp, |
214 WebGestureEvent::SourceDevice source_device, | 214 WebGestureDevice source_device, |
215 WebFloatPoint velocity, | 215 WebFloatPoint velocity, |
216 WebPoint position) { | 216 WebPoint position) { |
217 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 217 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
218 VERIFY_AND_RESET_MOCKS(); | 218 VERIFY_AND_RESET_MOCKS(); |
219 | 219 |
220 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 220 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
221 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 221 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
222 gesture_.type = WebInputEvent::GestureScrollBegin; | 222 gesture_.type = WebInputEvent::GestureScrollBegin; |
223 gesture_.sourceDevice = source_device; | 223 gesture_.sourceDevice = source_device; |
224 EXPECT_EQ(expected_disposition_, | 224 EXPECT_EQ(expected_disposition_, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 479 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
480 VERIFY_AND_RESET_MOCKS(); | 480 VERIFY_AND_RESET_MOCKS(); |
481 | 481 |
482 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 482 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
483 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 483 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
484 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 484 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
485 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 485 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
486 | 486 |
487 gesture_.type = WebInputEvent::GestureFlingStart; | 487 gesture_.type = WebInputEvent::GestureFlingStart; |
488 gesture_.data.flingStart.velocityX = 10; | 488 gesture_.data.flingStart.velocityX = 10; |
489 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 489 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
490 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 490 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
491 | 491 |
492 VERIFY_AND_RESET_MOCKS(); | 492 VERIFY_AND_RESET_MOCKS(); |
493 | 493 |
494 // Verify that a GestureFlingCancel during an animation cancels it. | 494 // Verify that a GestureFlingCancel during an animation cancels it. |
495 gesture_.type = WebInputEvent::GestureFlingCancel; | 495 gesture_.type = WebInputEvent::GestureFlingCancel; |
496 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 496 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
497 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 497 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
498 } | 498 } |
499 | 499 |
500 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) { | 500 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) { |
501 // We should send all events to the widget for this gesture. | 501 // We should send all events to the widget for this gesture. |
502 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 502 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
503 VERIFY_AND_RESET_MOCKS(); | 503 VERIFY_AND_RESET_MOCKS(); |
504 | 504 |
505 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 505 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
506 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); | 506 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); |
507 | 507 |
508 gesture_.type = WebInputEvent::GestureFlingStart; | 508 gesture_.type = WebInputEvent::GestureFlingStart; |
509 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 509 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
510 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 510 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
511 | 511 |
512 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the | 512 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the |
513 // input handler knows it's scrolling off the impl thread | 513 // input handler knows it's scrolling off the impl thread |
514 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 514 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
515 | 515 |
516 VERIFY_AND_RESET_MOCKS(); | 516 VERIFY_AND_RESET_MOCKS(); |
517 | 517 |
518 // Even if we didn't start a fling ourselves, we still need to send the cancel | 518 // Even if we didn't start a fling ourselves, we still need to send the cancel |
519 // event to the widget. | 519 // event to the widget. |
520 gesture_.type = WebInputEvent::GestureFlingCancel; | 520 gesture_.type = WebInputEvent::GestureFlingCancel; |
521 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 521 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
522 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 522 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
523 } | 523 } |
524 | 524 |
525 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { | 525 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { |
526 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 526 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
527 VERIFY_AND_RESET_MOCKS(); | 527 VERIFY_AND_RESET_MOCKS(); |
528 | 528 |
529 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 529 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
530 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); | 530 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); |
531 | 531 |
532 gesture_.type = WebInputEvent::GestureFlingStart; | 532 gesture_.type = WebInputEvent::GestureFlingStart; |
533 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 533 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
534 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 534 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
535 | 535 |
536 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 536 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
537 VERIFY_AND_RESET_MOCKS(); | 537 VERIFY_AND_RESET_MOCKS(); |
538 | 538 |
539 // Since the previous fling was ignored, we should also be dropping the next | 539 // Since the previous fling was ignored, we should also be dropping the next |
540 // fling_cancel. | 540 // fling_cancel. |
541 gesture_.type = WebInputEvent::GestureFlingCancel; | 541 gesture_.type = WebInputEvent::GestureFlingCancel; |
542 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 542 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
543 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 543 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
544 } | 544 } |
545 | 545 |
546 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { | 546 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { |
547 // We shouldn't send any events to the widget for this gesture. | 547 // We shouldn't send any events to the widget for this gesture. |
548 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 548 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
549 VERIFY_AND_RESET_MOCKS(); | 549 VERIFY_AND_RESET_MOCKS(); |
550 | 550 |
551 // On the fling start, we should schedule an animation but not actually start | 551 // On the fling start, we should schedule an animation but not actually start |
552 // scrolling. | 552 // scrolling. |
553 gesture_.type = WebInputEvent::GestureFlingStart; | 553 gesture_.type = WebInputEvent::GestureFlingStart; |
554 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 554 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
555 WebPoint fling_point = WebPoint(7, 13); | 555 WebPoint fling_point = WebPoint(7, 13); |
556 WebPoint fling_global_point = WebPoint(17, 23); | 556 WebPoint fling_global_point = WebPoint(17, 23); |
557 // Note that for trackpad, wheel events with the Control modifier are | 557 // Note that for trackpad, wheel events with the Control modifier are |
558 // special (reserved for zoom), so don't set that here. | 558 // special (reserved for zoom), so don't set that here. |
559 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 559 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
560 gesture_ = CreateFling(WebGestureEvent::Touchpad, | 560 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
561 fling_delta, | 561 fling_delta, |
562 fling_point, | 562 fling_point, |
563 fling_global_point, | 563 fling_global_point, |
564 modifiers); | 564 modifiers); |
565 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 565 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
566 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 566 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
567 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 567 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
568 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 568 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
569 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 569 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
570 | 570 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 655 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
656 VERIFY_AND_RESET_MOCKS(); | 656 VERIFY_AND_RESET_MOCKS(); |
657 | 657 |
658 // Start a gesture fling in the -X direction with zero Y movement. | 658 // Start a gesture fling in the -X direction with zero Y movement. |
659 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 659 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
660 WebPoint fling_point = WebPoint(7, 13); | 660 WebPoint fling_point = WebPoint(7, 13); |
661 WebPoint fling_global_point = WebPoint(17, 23); | 661 WebPoint fling_global_point = WebPoint(17, 23); |
662 // Note that for trackpad, wheel events with the Control modifier are | 662 // Note that for trackpad, wheel events with the Control modifier are |
663 // special (reserved for zoom), so don't set that here. | 663 // special (reserved for zoom), so don't set that here. |
664 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 664 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
665 gesture_ = CreateFling(WebGestureEvent::Touchpad, | 665 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
666 fling_delta, | 666 fling_delta, |
667 fling_point, | 667 fling_point, |
668 fling_global_point, | 668 fling_global_point, |
669 modifiers); | 669 modifiers); |
670 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 670 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
671 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 671 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
672 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 672 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
673 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 673 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
674 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 674 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
675 | 675 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 756 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
757 | 757 |
758 VERIFY_AND_RESET_MOCKS(); | 758 VERIFY_AND_RESET_MOCKS(); |
759 input_handler_->MainThreadHasStoppedFlinging(); | 759 input_handler_->MainThreadHasStoppedFlinging(); |
760 | 760 |
761 // Start a second gesture fling, this time in the +Y direction with no X. | 761 // Start a second gesture fling, this time in the +Y direction with no X. |
762 fling_delta = WebFloatPoint(0, -1000); | 762 fling_delta = WebFloatPoint(0, -1000); |
763 fling_point = WebPoint(95, 87); | 763 fling_point = WebPoint(95, 87); |
764 fling_global_point = WebPoint(32, 71); | 764 fling_global_point = WebPoint(32, 71); |
765 modifiers = WebInputEvent::AltKey; | 765 modifiers = WebInputEvent::AltKey; |
766 gesture_ = CreateFling(WebGestureEvent::Touchpad, | 766 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
767 fling_delta, | 767 fling_delta, |
768 fling_point, | 768 fling_point, |
769 fling_global_point, | 769 fling_global_point, |
770 modifiers); | 770 modifiers); |
771 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 771 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
772 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 772 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
773 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 773 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
774 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 774 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
775 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 775 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
776 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 776 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 828 } |
829 | 829 |
830 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { | 830 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { |
831 // We shouldn't send any events to the widget for this gesture. | 831 // We shouldn't send any events to the widget for this gesture. |
832 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 832 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
833 VERIFY_AND_RESET_MOCKS(); | 833 VERIFY_AND_RESET_MOCKS(); |
834 | 834 |
835 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 835 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
836 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 836 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
837 gesture_.type = WebInputEvent::GestureScrollBegin; | 837 gesture_.type = WebInputEvent::GestureScrollBegin; |
838 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 838 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
839 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 839 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
840 | 840 |
841 VERIFY_AND_RESET_MOCKS(); | 841 VERIFY_AND_RESET_MOCKS(); |
842 | 842 |
843 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 843 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
844 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 844 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
845 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 845 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
846 | 846 |
847 gesture_.type = WebInputEvent::GestureFlingStart; | 847 gesture_.type = WebInputEvent::GestureFlingStart; |
848 gesture_.data.flingStart.velocityX = 10; | 848 gesture_.data.flingStart.velocityX = 10; |
849 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 849 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
850 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 850 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
851 | 851 |
852 VERIFY_AND_RESET_MOCKS(); | 852 VERIFY_AND_RESET_MOCKS(); |
853 | 853 |
854 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 854 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
855 | 855 |
856 // Verify that a GestureFlingCancel during an animation cancels it. | 856 // Verify that a GestureFlingCancel during an animation cancels it. |
857 gesture_.type = WebInputEvent::GestureFlingCancel; | 857 gesture_.type = WebInputEvent::GestureFlingCancel; |
858 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 858 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
859 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 859 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
860 } | 860 } |
861 | 861 |
862 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) { | 862 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) { |
863 // We should send all events to the widget for this gesture. | 863 // We should send all events to the widget for this gesture. |
864 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 864 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
865 VERIFY_AND_RESET_MOCKS(); | 865 VERIFY_AND_RESET_MOCKS(); |
866 | 866 |
867 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 867 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
868 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); | 868 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); |
869 | 869 |
870 gesture_.type = WebInputEvent::GestureScrollBegin; | 870 gesture_.type = WebInputEvent::GestureScrollBegin; |
871 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 871 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
872 | 872 |
873 VERIFY_AND_RESET_MOCKS(); | 873 VERIFY_AND_RESET_MOCKS(); |
874 | 874 |
875 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0); | 875 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0); |
876 | 876 |
877 gesture_.type = WebInputEvent::GestureFlingStart; | 877 gesture_.type = WebInputEvent::GestureFlingStart; |
878 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 878 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
879 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 879 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
880 | 880 |
881 VERIFY_AND_RESET_MOCKS(); | 881 VERIFY_AND_RESET_MOCKS(); |
882 | 882 |
883 // Even if we didn't start a fling ourselves, we still need to send the cancel | 883 // Even if we didn't start a fling ourselves, we still need to send the cancel |
884 // event to the widget. | 884 // event to the widget. |
885 gesture_.type = WebInputEvent::GestureFlingCancel; | 885 gesture_.type = WebInputEvent::GestureFlingCancel; |
886 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 886 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
887 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 887 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
888 } | 888 } |
889 | 889 |
890 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) { | 890 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) { |
891 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 891 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
892 VERIFY_AND_RESET_MOCKS(); | 892 VERIFY_AND_RESET_MOCKS(); |
893 | 893 |
894 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 894 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
895 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 895 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
896 | 896 |
897 gesture_.type = WebInputEvent::GestureScrollBegin; | 897 gesture_.type = WebInputEvent::GestureScrollBegin; |
898 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 898 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
899 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 899 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
900 | 900 |
901 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 901 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
902 VERIFY_AND_RESET_MOCKS(); | 902 VERIFY_AND_RESET_MOCKS(); |
903 | 903 |
904 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 904 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
905 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); | 905 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); |
906 | 906 |
907 gesture_.type = WebInputEvent::GestureFlingStart; | 907 gesture_.type = WebInputEvent::GestureFlingStart; |
908 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 908 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
909 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 909 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
910 | 910 |
911 VERIFY_AND_RESET_MOCKS(); | 911 VERIFY_AND_RESET_MOCKS(); |
912 | 912 |
913 // Even if we didn't start a fling ourselves, we still need to send the cancel | 913 // Even if we didn't start a fling ourselves, we still need to send the cancel |
914 // event to the widget. | 914 // event to the widget. |
915 gesture_.type = WebInputEvent::GestureFlingCancel; | 915 gesture_.type = WebInputEvent::GestureFlingCancel; |
916 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 916 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
917 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 917 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
918 } | 918 } |
919 | 919 |
920 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) { | 920 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) { |
921 // We shouldn't send any events to the widget for this gesture. | 921 // We shouldn't send any events to the widget for this gesture. |
922 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 922 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
923 VERIFY_AND_RESET_MOCKS(); | 923 VERIFY_AND_RESET_MOCKS(); |
924 | 924 |
925 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 925 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
926 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 926 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
927 | 927 |
928 gesture_.type = WebInputEvent::GestureScrollBegin; | 928 gesture_.type = WebInputEvent::GestureScrollBegin; |
929 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 929 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
930 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 930 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
931 | 931 |
932 VERIFY_AND_RESET_MOCKS(); | 932 VERIFY_AND_RESET_MOCKS(); |
933 | 933 |
934 // On the fling start, we should schedule an animation but not actually start | 934 // On the fling start, we should schedule an animation but not actually start |
935 // scrolling. | 935 // scrolling. |
936 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 936 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
937 WebPoint fling_point = WebPoint(7, 13); | 937 WebPoint fling_point = WebPoint(7, 13); |
938 WebPoint fling_global_point = WebPoint(17, 23); | 938 WebPoint fling_global_point = WebPoint(17, 23); |
939 // Note that for touchscreen the control modifier is not special. | 939 // Note that for touchscreen the control modifier is not special. |
940 int modifiers = WebInputEvent::ControlKey; | 940 int modifiers = WebInputEvent::ControlKey; |
941 gesture_ = CreateFling(WebGestureEvent::Touchscreen, | 941 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
942 fling_delta, | 942 fling_delta, |
943 fling_point, | 943 fling_point, |
944 fling_global_point, | 944 fling_global_point, |
945 modifiers); | 945 modifiers); |
946 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 946 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
947 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 947 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
948 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 948 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
949 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 949 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
950 | 950 |
951 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 951 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
(...skipping 26 matching lines...) Expand all Loading... |
978 | 978 |
979 TEST_F(InputHandlerProxyTest, GestureFlingWithValidTimestamp) { | 979 TEST_F(InputHandlerProxyTest, GestureFlingWithValidTimestamp) { |
980 // We shouldn't send any events to the widget for this gesture. | 980 // We shouldn't send any events to the widget for this gesture. |
981 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 981 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
982 VERIFY_AND_RESET_MOCKS(); | 982 VERIFY_AND_RESET_MOCKS(); |
983 | 983 |
984 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 984 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
985 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 985 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
986 | 986 |
987 gesture_.type = WebInputEvent::GestureScrollBegin; | 987 gesture_.type = WebInputEvent::GestureScrollBegin; |
988 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 988 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
989 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 989 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
990 | 990 |
991 VERIFY_AND_RESET_MOCKS(); | 991 VERIFY_AND_RESET_MOCKS(); |
992 | 992 |
993 // On the fling start, we should schedule an animation but not actually start | 993 // On the fling start, we should schedule an animation but not actually start |
994 // scrolling. | 994 // scrolling. |
995 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 995 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
996 base::TimeTicks time = base::TimeTicks() + dt; | 996 base::TimeTicks time = base::TimeTicks() + dt; |
997 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 997 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
998 WebPoint fling_point = WebPoint(7, 13); | 998 WebPoint fling_point = WebPoint(7, 13); |
999 WebPoint fling_global_point = WebPoint(17, 23); | 999 WebPoint fling_global_point = WebPoint(17, 23); |
1000 int modifiers = WebInputEvent::ControlKey; | 1000 int modifiers = WebInputEvent::ControlKey; |
1001 gesture_ = CreateFling(time, | 1001 gesture_ = CreateFling(time, |
1002 WebGestureEvent::Touchscreen, | 1002 blink::WebGestureDeviceTouchpad, |
1003 fling_delta, | 1003 fling_delta, |
1004 fling_point, | 1004 fling_point, |
1005 fling_global_point, | 1005 fling_global_point, |
1006 modifiers); | 1006 modifiers); |
1007 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1007 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
1008 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1008 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1009 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1009 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1010 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1010 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1011 | 1011 |
1012 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1012 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
(...skipping 19 matching lines...) Expand all Loading... |
1032 | 1032 |
1033 TEST_F(InputHandlerProxyTest, GestureFlingWithInvalidTimestamp) { | 1033 TEST_F(InputHandlerProxyTest, GestureFlingWithInvalidTimestamp) { |
1034 // We shouldn't send any events to the widget for this gesture. | 1034 // We shouldn't send any events to the widget for this gesture. |
1035 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1035 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1036 VERIFY_AND_RESET_MOCKS(); | 1036 VERIFY_AND_RESET_MOCKS(); |
1037 | 1037 |
1038 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1038 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1039 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1039 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1040 | 1040 |
1041 gesture_.type = WebInputEvent::GestureScrollBegin; | 1041 gesture_.type = WebInputEvent::GestureScrollBegin; |
1042 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1042 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
1043 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1043 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1044 | 1044 |
1045 VERIFY_AND_RESET_MOCKS(); | 1045 VERIFY_AND_RESET_MOCKS(); |
1046 | 1046 |
1047 // On the fling start, we should schedule an animation but not actually start | 1047 // On the fling start, we should schedule an animation but not actually start |
1048 // scrolling. | 1048 // scrolling. |
1049 base::TimeDelta start_time_offset = base::TimeDelta::FromMilliseconds(10); | 1049 base::TimeDelta start_time_offset = base::TimeDelta::FromMilliseconds(10); |
1050 gesture_.type = WebInputEvent::GestureFlingStart; | 1050 gesture_.type = WebInputEvent::GestureFlingStart; |
1051 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1051 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1052 WebPoint fling_point = WebPoint(7, 13); | 1052 WebPoint fling_point = WebPoint(7, 13); |
1053 WebPoint fling_global_point = WebPoint(17, 23); | 1053 WebPoint fling_global_point = WebPoint(17, 23); |
1054 int modifiers = WebInputEvent::ControlKey; | 1054 int modifiers = WebInputEvent::ControlKey; |
1055 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); | 1055 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); |
1056 gesture_.data.flingStart.velocityX = fling_delta.x; | 1056 gesture_.data.flingStart.velocityX = fling_delta.x; |
1057 gesture_.data.flingStart.velocityY = fling_delta.y; | 1057 gesture_.data.flingStart.velocityY = fling_delta.y; |
1058 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1058 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
1059 gesture_.x = fling_point.x; | 1059 gesture_.x = fling_point.x; |
1060 gesture_.y = fling_point.y; | 1060 gesture_.y = fling_point.y; |
1061 gesture_.globalX = fling_global_point.x; | 1061 gesture_.globalX = fling_global_point.x; |
1062 gesture_.globalY = fling_global_point.y; | 1062 gesture_.globalY = fling_global_point.y; |
1063 gesture_.modifiers = modifiers; | 1063 gesture_.modifiers = modifiers; |
1064 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1064 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
1065 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1065 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1066 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1066 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1067 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1067 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1068 | 1068 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 | 1111 |
1112 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1112 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1113 VERIFY_AND_RESET_MOCKS(); | 1113 VERIFY_AND_RESET_MOCKS(); |
1114 | 1114 |
1115 // On the fling start, we should schedule an animation but not actually start | 1115 // On the fling start, we should schedule an animation but not actually start |
1116 // scrolling. | 1116 // scrolling. |
1117 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1117 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1118 WebPoint fling_point = WebPoint(7, 13); | 1118 WebPoint fling_point = WebPoint(7, 13); |
1119 WebPoint fling_global_point = WebPoint(17, 23); | 1119 WebPoint fling_global_point = WebPoint(17, 23); |
1120 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; | 1120 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; |
1121 gesture_ = CreateFling(WebGestureEvent::Touchscreen, | 1121 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad, |
1122 fling_delta, | 1122 fling_delta, |
1123 fling_point, | 1123 fling_point, |
1124 fling_global_point, | 1124 fling_global_point, |
1125 modifiers); | 1125 modifiers); |
1126 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1126 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
1127 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1127 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1128 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1128 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1129 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1129 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1130 | 1130 |
1131 // |gesture_scroll_on_impl_thread_| should still be true after | 1131 // |gesture_scroll_on_impl_thread_| should still be true after |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 | 1232 |
1233 TEST_F(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { | 1233 TEST_F(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { |
1234 // We shouldn't send any events to the widget for this gesture. | 1234 // We shouldn't send any events to the widget for this gesture. |
1235 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1235 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1236 VERIFY_AND_RESET_MOCKS(); | 1236 VERIFY_AND_RESET_MOCKS(); |
1237 | 1237 |
1238 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1238 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1239 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1239 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1240 | 1240 |
1241 gesture_.type = WebInputEvent::GestureScrollBegin; | 1241 gesture_.type = WebInputEvent::GestureScrollBegin; |
1242 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1242 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
1243 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1243 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1244 | 1244 |
1245 VERIFY_AND_RESET_MOCKS(); | 1245 VERIFY_AND_RESET_MOCKS(); |
1246 | 1246 |
1247 // On the fling start, we should schedule an animation but not actually start | 1247 // On the fling start, we should schedule an animation but not actually start |
1248 // scrolling. | 1248 // scrolling. |
1249 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 1249 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
1250 base::TimeTicks time = base::TimeTicks() + dt; | 1250 base::TimeTicks time = base::TimeTicks() + dt; |
1251 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1251 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1252 WebPoint fling_point = WebPoint(7, 13); | 1252 WebPoint fling_point = WebPoint(7, 13); |
1253 WebPoint fling_global_point = WebPoint(17, 23); | 1253 WebPoint fling_global_point = WebPoint(17, 23); |
1254 int modifiers = WebInputEvent::ControlKey; | 1254 int modifiers = WebInputEvent::ControlKey; |
1255 gesture_ = CreateFling(time, | 1255 gesture_ = CreateFling(time, |
1256 WebGestureEvent::Touchscreen, | 1256 blink::WebGestureDeviceTouchpad, |
1257 fling_delta, | 1257 fling_delta, |
1258 fling_point, | 1258 fling_point, |
1259 fling_global_point, | 1259 fling_global_point, |
1260 modifiers); | 1260 modifiers); |
1261 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1261 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
1262 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1262 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1263 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1263 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1264 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1264 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1265 | 1265 |
1266 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1266 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 } | 1308 } |
1309 | 1309 |
1310 TEST_F(InputHandlerProxyTest, GestureFlingCancelledAfterBothAxesStopScrolling) { | 1310 TEST_F(InputHandlerProxyTest, GestureFlingCancelledAfterBothAxesStopScrolling) { |
1311 // We shouldn't send any events to the widget for this gesture. | 1311 // We shouldn't send any events to the widget for this gesture. |
1312 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1312 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1313 VERIFY_AND_RESET_MOCKS(); | 1313 VERIFY_AND_RESET_MOCKS(); |
1314 | 1314 |
1315 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1315 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1316 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1316 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1317 gesture_.type = WebInputEvent::GestureScrollBegin; | 1317 gesture_.type = WebInputEvent::GestureScrollBegin; |
1318 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1318 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
1319 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1319 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1320 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1320 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1321 | 1321 |
1322 // On the fling start, we should schedule an animation but not actually start | 1322 // On the fling start, we should schedule an animation but not actually start |
1323 // scrolling. | 1323 // scrolling. |
1324 gesture_.type = WebInputEvent::GestureFlingStart; | 1324 gesture_.type = WebInputEvent::GestureFlingStart; |
1325 WebFloatPoint fling_delta = WebFloatPoint(100, 100); | 1325 WebFloatPoint fling_delta = WebFloatPoint(100, 100); |
1326 gesture_.data.flingStart.velocityX = fling_delta.x; | 1326 gesture_.data.flingStart.velocityX = fling_delta.x; |
1327 gesture_.data.flingStart.velocityY = fling_delta.y; | 1327 gesture_.data.flingStart.velocityY = fling_delta.y; |
1328 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1328 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 } | 1450 } |
1451 | 1451 |
1452 TEST_F(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { | 1452 TEST_F(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { |
1453 // We shouldn't send any events to the widget for this gesture. | 1453 // We shouldn't send any events to the widget for this gesture. |
1454 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1454 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1455 VERIFY_AND_RESET_MOCKS(); | 1455 VERIFY_AND_RESET_MOCKS(); |
1456 | 1456 |
1457 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1457 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1458 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1458 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1459 gesture_.type = WebInputEvent::GestureScrollBegin; | 1459 gesture_.type = WebInputEvent::GestureScrollBegin; |
1460 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1460 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
1461 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1461 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1462 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1462 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1463 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1463 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
1464 | 1464 |
1465 // Keyboard events received during a scroll should have no effect. | 1465 // Keyboard events received during a scroll should have no effect. |
1466 WebKeyboardEvent key_event; | 1466 WebKeyboardEvent key_event; |
1467 key_event.type = WebInputEvent::KeyDown; | 1467 key_event.type = WebInputEvent::KeyDown; |
1468 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, | 1468 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, |
1469 input_handler_->HandleInputEvent(key_event)); | 1469 input_handler_->HandleInputEvent(key_event)); |
1470 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1470 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 | 1503 |
1504 TEST_F(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) { | 1504 TEST_F(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) { |
1505 // We shouldn't send any events to the widget for this gesture. | 1505 // We shouldn't send any events to the widget for this gesture. |
1506 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 1506 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
1507 VERIFY_AND_RESET_MOCKS(); | 1507 VERIFY_AND_RESET_MOCKS(); |
1508 | 1508 |
1509 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1509 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1510 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1510 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1511 | 1511 |
1512 gesture_.type = WebInputEvent::GestureScrollBegin; | 1512 gesture_.type = WebInputEvent::GestureScrollBegin; |
1513 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 1513 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad; |
1514 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1514 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1515 | 1515 |
1516 VERIFY_AND_RESET_MOCKS(); | 1516 VERIFY_AND_RESET_MOCKS(); |
1517 | 1517 |
1518 // On the fling start, we should schedule an animation but not actually start | 1518 // On the fling start, we should schedule an animation but not actually start |
1519 // scrolling. | 1519 // scrolling. |
1520 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 1520 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
1521 base::TimeTicks time = base::TimeTicks() + dt; | 1521 base::TimeTicks time = base::TimeTicks() + dt; |
1522 WebFloatPoint fling_delta = WebFloatPoint(100, 0); | 1522 WebFloatPoint fling_delta = WebFloatPoint(100, 0); |
1523 WebPoint fling_point = WebPoint(7, 13); | 1523 WebPoint fling_point = WebPoint(7, 13); |
1524 WebPoint fling_global_point = WebPoint(17, 23); | 1524 WebPoint fling_global_point = WebPoint(17, 23); |
1525 int modifiers = WebInputEvent::ControlKey; | 1525 int modifiers = WebInputEvent::ControlKey; |
1526 gesture_ = CreateFling(time, | 1526 gesture_ = CreateFling(time, |
1527 WebGestureEvent::Touchscreen, | 1527 blink::WebGestureDeviceTouchpad, |
1528 fling_delta, | 1528 fling_delta, |
1529 fling_point, | 1529 fling_point, |
1530 fling_global_point, | 1530 fling_global_point, |
1531 modifiers); | 1531 modifiers); |
1532 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1532 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
1533 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 1533 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
1534 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1534 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1535 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1535 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1536 | 1536 |
1537 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 1537 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
(...skipping 26 matching lines...) Expand all Loading... |
1564 gesture_.type = WebInputEvent::GestureFlingCancel; | 1564 gesture_.type = WebInputEvent::GestureFlingCancel; |
1565 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1565 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1566 } | 1566 } |
1567 | 1567 |
1568 TEST_F(InputHandlerProxyTest, FlingBoost) { | 1568 TEST_F(InputHandlerProxyTest, FlingBoost) { |
1569 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 1569 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
1570 base::TimeTicks time = base::TimeTicks() + dt; | 1570 base::TimeTicks time = base::TimeTicks() + dt; |
1571 base::TimeTicks last_animate_time = time; | 1571 base::TimeTicks last_animate_time = time; |
1572 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1572 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
1573 WebPoint fling_point = WebPoint(7, 13); | 1573 WebPoint fling_point = WebPoint(7, 13); |
1574 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); | 1574 StartFling(time, blink::WebGestureDeviceTouchpad, fling_delta, fling_point); |
1575 | 1575 |
1576 // Now cancel the fling. The fling cancellation should be deferred to allow | 1576 // Now cancel the fling. The fling cancellation should be deferred to allow |
1577 // fling boosting events to arrive. | 1577 // fling boosting events to arrive. |
1578 time += dt; | 1578 time += dt; |
1579 CancelFling(time); | 1579 CancelFling(time); |
1580 | 1580 |
1581 // The GestureScrollBegin should be swallowed by the fling if it hits the same | 1581 // The GestureScrollBegin should be swallowed by the fling if it hits the same |
1582 // scrolling layer. | 1582 // scrolling layer. |
1583 EXPECT_CALL(mock_input_handler_, | 1583 EXPECT_CALL(mock_input_handler_, |
1584 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) | 1584 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 .WillOnce(testing::Return(true)); | 1627 .WillOnce(testing::Return(true)); |
1628 input_handler_->Animate(time); | 1628 input_handler_->Animate(time); |
1629 last_animate_time = time; | 1629 last_animate_time = time; |
1630 | 1630 |
1631 VERIFY_AND_RESET_MOCKS(); | 1631 VERIFY_AND_RESET_MOCKS(); |
1632 | 1632 |
1633 // GestureFlingStart in the same direction and at sufficient speed should | 1633 // GestureFlingStart in the same direction and at sufficient speed should |
1634 // boost the active fling. | 1634 // boost the active fling. |
1635 | 1635 |
1636 gesture_ = CreateFling(time, | 1636 gesture_ = CreateFling(time, |
1637 WebGestureEvent::Touchscreen, | 1637 blink::WebGestureDeviceTouchpad, |
1638 fling_delta, | 1638 fling_delta, |
1639 fling_point, | 1639 fling_point, |
1640 fling_point, | 1640 fling_point, |
1641 0); | 1641 0); |
1642 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1642 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1643 VERIFY_AND_RESET_MOCKS(); | 1643 VERIFY_AND_RESET_MOCKS(); |
1644 | 1644 |
1645 time += dt; | 1645 time += dt; |
1646 // Note we get *2x* as much delta because 2 flings have combined. | 1646 // Note we get *2x* as much delta because 2 flings have combined. |
1647 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; | 1647 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; |
1648 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1648 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
1649 EXPECT_CALL(mock_input_handler_, | 1649 EXPECT_CALL(mock_input_handler_, |
1650 ScrollBy(testing::_, | 1650 ScrollBy(testing::_, |
1651 testing::Property(&gfx::Vector2dF::x, | 1651 testing::Property(&gfx::Vector2dF::x, |
1652 testing::Eq(expected_delta)))) | 1652 testing::Eq(expected_delta)))) |
1653 .WillOnce(testing::Return(true)); | 1653 .WillOnce(testing::Return(true)); |
1654 input_handler_->Animate(time); | 1654 input_handler_->Animate(time); |
1655 last_animate_time = time; | 1655 last_animate_time = time; |
1656 | 1656 |
1657 VERIFY_AND_RESET_MOCKS(); | 1657 VERIFY_AND_RESET_MOCKS(); |
1658 | 1658 |
1659 // Repeated GestureFlingStarts should accumulate. | 1659 // Repeated GestureFlingStarts should accumulate. |
1660 | 1660 |
1661 CancelFling(time); | 1661 CancelFling(time); |
1662 gesture_ = CreateFling(time, | 1662 gesture_ = CreateFling(time, |
1663 WebGestureEvent::Touchscreen, | 1663 blink::WebGestureDeviceTouchpad, |
1664 fling_delta, | 1664 fling_delta, |
1665 fling_point, | 1665 fling_point, |
1666 fling_point, | 1666 fling_point, |
1667 0); | 1667 0); |
1668 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1668 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1669 VERIFY_AND_RESET_MOCKS(); | 1669 VERIFY_AND_RESET_MOCKS(); |
1670 | 1670 |
1671 time += dt; | 1671 time += dt; |
1672 // Note we get *3x* as much delta because 3 flings have combined. | 1672 // Note we get *3x* as much delta because 3 flings have combined. |
1673 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; | 1673 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; |
(...skipping 23 matching lines...) Expand all Loading... |
1697 input_handler_->Animate(time); | 1697 input_handler_->Animate(time); |
1698 | 1698 |
1699 VERIFY_AND_RESET_MOCKS(); | 1699 VERIFY_AND_RESET_MOCKS(); |
1700 } | 1700 } |
1701 | 1701 |
1702 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollTargetsDifferentLayer) { | 1702 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollTargetsDifferentLayer) { |
1703 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 1703 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
1704 base::TimeTicks time = base::TimeTicks() + dt; | 1704 base::TimeTicks time = base::TimeTicks() + dt; |
1705 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1705 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
1706 WebPoint fling_point = WebPoint(7, 13); | 1706 WebPoint fling_point = WebPoint(7, 13); |
1707 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); | 1707 StartFling(time, blink::WebGestureDeviceTouchpad, fling_delta, fling_point); |
1708 | 1708 |
1709 // Cancel the fling. The fling cancellation should be deferred to allow | 1709 // Cancel the fling. The fling cancellation should be deferred to allow |
1710 // fling boosting events to arrive. | 1710 // fling boosting events to arrive. |
1711 time += dt; | 1711 time += dt; |
1712 CancelFling(time); | 1712 CancelFling(time); |
1713 | 1713 |
1714 // If the GestureScrollBegin targets a different layer, the fling should be | 1714 // If the GestureScrollBegin targets a different layer, the fling should be |
1715 // cancelled and the scroll should be handled as usual. | 1715 // cancelled and the scroll should be handled as usual. |
1716 EXPECT_CALL(mock_input_handler_, | 1716 EXPECT_CALL(mock_input_handler_, |
1717 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) | 1717 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) |
1718 .WillOnce(testing::Return(false)); | 1718 .WillOnce(testing::Return(false)); |
1719 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1719 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1720 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1720 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1721 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 1721 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
1722 | 1722 |
1723 time += dt; | 1723 time += dt; |
1724 gesture_.timeStampSeconds = InSecondsF(time); | 1724 gesture_.timeStampSeconds = InSecondsF(time); |
1725 gesture_.type = WebInputEvent::GestureScrollBegin; | 1725 gesture_.type = WebInputEvent::GestureScrollBegin; |
1726 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1726 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1727 | 1727 |
1728 VERIFY_AND_RESET_MOCKS(); | 1728 VERIFY_AND_RESET_MOCKS(); |
1729 } | 1729 } |
1730 | 1730 |
1731 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollDelayed) { | 1731 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollDelayed) { |
1732 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 1732 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
1733 base::TimeTicks time = base::TimeTicks() + dt; | 1733 base::TimeTicks time = base::TimeTicks() + dt; |
1734 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1734 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
1735 WebPoint fling_point = WebPoint(7, 13); | 1735 WebPoint fling_point = WebPoint(7, 13); |
1736 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); | 1736 StartFling(time, blink::WebGestureDeviceTouchpad, fling_delta, fling_point); |
1737 | 1737 |
1738 // Cancel the fling. The fling cancellation should be deferred to allow | 1738 // Cancel the fling. The fling cancellation should be deferred to allow |
1739 // fling boosting events to arrive. | 1739 // fling boosting events to arrive. |
1740 time += dt; | 1740 time += dt; |
1741 CancelFling(time); | 1741 CancelFling(time); |
1742 | 1742 |
1743 // The GestureScrollBegin should be swallowed by the fling if it hits the same | 1743 // The GestureScrollBegin should be swallowed by the fling if it hits the same |
1744 // scrolling layer. | 1744 // scrolling layer. |
1745 EXPECT_CALL(mock_input_handler_, | 1745 EXPECT_CALL(mock_input_handler_, |
1746 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) | 1746 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) |
(...skipping 15 matching lines...) Expand all Loading... |
1762 input_handler_->Animate(time); | 1762 input_handler_->Animate(time); |
1763 | 1763 |
1764 VERIFY_AND_RESET_MOCKS(); | 1764 VERIFY_AND_RESET_MOCKS(); |
1765 } | 1765 } |
1766 | 1766 |
1767 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) { | 1767 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) { |
1768 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 1768 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
1769 base::TimeTicks time = base::TimeTicks() + dt; | 1769 base::TimeTicks time = base::TimeTicks() + dt; |
1770 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1770 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
1771 WebPoint fling_point = WebPoint(7, 13); | 1771 WebPoint fling_point = WebPoint(7, 13); |
1772 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); | 1772 StartFling(time, blink::WebGestureDeviceTouchpad, fling_delta, fling_point); |
1773 | 1773 |
1774 // Cancel the fling. The fling cancellation should be deferred to allow | 1774 // Cancel the fling. The fling cancellation should be deferred to allow |
1775 // fling boosting events to arrive. | 1775 // fling boosting events to arrive. |
1776 time += dt; | 1776 time += dt; |
1777 CancelFling(time); | 1777 CancelFling(time); |
1778 | 1778 |
1779 // The GestureScrollBegin should be swallowed by the fling if it hits the same | 1779 // The GestureScrollBegin should be swallowed by the fling if it hits the same |
1780 // scrolling layer. | 1780 // scrolling layer. |
1781 EXPECT_CALL(mock_input_handler_, | 1781 EXPECT_CALL(mock_input_handler_, |
1782 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) | 1782 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) |
(...skipping 23 matching lines...) Expand all Loading... |
1806 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1806 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1807 | 1807 |
1808 VERIFY_AND_RESET_MOCKS(); | 1808 VERIFY_AND_RESET_MOCKS(); |
1809 } | 1809 } |
1810 | 1810 |
1811 TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) { | 1811 TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) { |
1812 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); | 1812 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
1813 base::TimeTicks time = base::TimeTicks() + dt; | 1813 base::TimeTicks time = base::TimeTicks() + dt; |
1814 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 1814 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
1815 WebPoint fling_point = WebPoint(7, 13); | 1815 WebPoint fling_point = WebPoint(7, 13); |
1816 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); | 1816 StartFling(time, blink::WebGestureDeviceTouchpad, fling_delta, fling_point); |
1817 | 1817 |
1818 // Cancel the fling. The fling cancellation should be deferred to allow | 1818 // Cancel the fling. The fling cancellation should be deferred to allow |
1819 // fling boosting events to arrive. | 1819 // fling boosting events to arrive. |
1820 time += dt; | 1820 time += dt; |
1821 CancelFling(time); | 1821 CancelFling(time); |
1822 | 1822 |
1823 // If the new fling is too slow, no boosting should take place, with the new | 1823 // If the new fling is too slow, no boosting should take place, with the new |
1824 // fling replacing the old. | 1824 // fling replacing the old. |
1825 WebFloatPoint small_fling_delta = WebFloatPoint(100, 0); | 1825 WebFloatPoint small_fling_delta = WebFloatPoint(100, 0); |
1826 gesture_ = CreateFling(time, | 1826 gesture_ = CreateFling(time, |
1827 WebGestureEvent::Touchscreen, | 1827 blink::WebGestureDeviceTouchpad, |
1828 small_fling_delta, | 1828 small_fling_delta, |
1829 fling_point, | 1829 fling_point, |
1830 fling_point, | 1830 fling_point, |
1831 0); | 1831 0); |
1832 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 1832 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
1833 | 1833 |
1834 VERIFY_AND_RESET_MOCKS(); | 1834 VERIFY_AND_RESET_MOCKS(); |
1835 | 1835 |
1836 // Note that the new fling delta uses the *slow*, unboosted fling velocity. | 1836 // Note that the new fling delta uses the *slow*, unboosted fling velocity. |
1837 time += dt; | 1837 time += dt; |
1838 float expected_delta = dt.InSecondsF() * -small_fling_delta.x; | 1838 float expected_delta = dt.InSecondsF() * -small_fling_delta.x; |
1839 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 1839 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
1840 EXPECT_CALL(mock_input_handler_, | 1840 EXPECT_CALL(mock_input_handler_, |
1841 ScrollBy(testing::_, | 1841 ScrollBy(testing::_, |
1842 testing::Property(&gfx::Vector2dF::x, | 1842 testing::Property(&gfx::Vector2dF::x, |
1843 testing::Eq(expected_delta)))) | 1843 testing::Eq(expected_delta)))) |
1844 .WillOnce(testing::Return(true)); | 1844 .WillOnce(testing::Return(true)); |
1845 input_handler_->Animate(time); | 1845 input_handler_->Animate(time); |
1846 | 1846 |
1847 VERIFY_AND_RESET_MOCKS(); | 1847 VERIFY_AND_RESET_MOCKS(); |
1848 } | 1848 } |
1849 | 1849 |
1850 } // namespace | 1850 } // namespace |
1851 } // namespace content | 1851 } // namespace content |
OLD | NEW |