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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 void BindToClient(cc::InputHandlerClient* client) override {} | 126 void BindToClient(cc::InputHandlerClient* client) override {} |
127 | 127 |
128 void MouseMoveAt(const gfx::Point& mouse_position) override {} | 128 void MouseMoveAt(const gfx::Point& mouse_position) override {} |
129 | 129 |
130 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, | 130 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, |
131 bool(const gfx::Point& point, | 131 bool(const gfx::Point& point, |
132 cc::InputHandler::ScrollInputType type)); | 132 cc::InputHandler::ScrollInputType type)); |
133 | 133 |
134 MOCK_METHOD1(HaveWheelEventHandlersAt, bool(const gfx::Point& point)); | |
135 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); | 134 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); |
136 | 135 |
| 136 MOCK_METHOD1(EffectiveWheelEventListenerPropertiesAt, |
| 137 uint32_t(const gfx::Point& point)); |
| 138 MOCK_METHOD1(EffectiveTouchEventListenerPropertiesAt, |
| 139 uint32_t(const gfx::Point& point)); |
| 140 |
137 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void()); | 141 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void()); |
138 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset, | 142 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset, |
139 void(const gfx::ScrollOffset& root_offset)); | 143 void(const gfx::ScrollOffset& root_offset)); |
140 | 144 |
141 bool IsCurrentlyScrollingInnerViewport() const override { | 145 bool IsCurrentlyScrollingInnerViewport() const override { |
142 return is_scrolling_root_; | 146 return is_scrolling_root_; |
143 } | 147 } |
144 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } | 148 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } |
145 | 149 |
146 private: | 150 private: |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 622 |
619 VERIFY_AND_RESET_MOCKS(); | 623 VERIFY_AND_RESET_MOCKS(); |
620 } | 624 } |
621 | 625 |
622 TEST_P(InputHandlerProxyTest, GesturePinch) { | 626 TEST_P(InputHandlerProxyTest, GesturePinch) { |
623 // We shouldn't send any events to the widget for this gesture. | 627 // We shouldn't send any events to the widget for this gesture. |
624 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 628 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
625 VERIFY_AND_RESET_MOCKS(); | 629 VERIFY_AND_RESET_MOCKS(); |
626 | 630 |
627 gesture_.type = WebInputEvent::GesturePinchBegin; | 631 gesture_.type = WebInputEvent::GesturePinchBegin; |
628 EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlersAt(testing::_)) | 632 EXPECT_CALL(mock_input_handler_, |
629 .WillOnce(testing::Return(false)); | 633 EffectiveWheelEventListenerPropertiesAt(testing::_)) |
| 634 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
630 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); | 635 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); |
631 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 636 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
632 | 637 |
633 VERIFY_AND_RESET_MOCKS(); | 638 VERIFY_AND_RESET_MOCKS(); |
634 | 639 |
635 gesture_.type = WebInputEvent::GesturePinchUpdate; | 640 gesture_.type = WebInputEvent::GesturePinchUpdate; |
636 gesture_.data.pinchUpdate.scale = 1.5; | 641 gesture_.data.pinchUpdate.scale = 1.5; |
637 gesture_.x = 7; | 642 gesture_.x = 7; |
638 gesture_.y = 13; | 643 gesture_.y = 13; |
639 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); | 644 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); |
(...skipping 27 matching lines...) Expand all Loading... |
667 | 672 |
668 VERIFY_AND_RESET_MOCKS(); | 673 VERIFY_AND_RESET_MOCKS(); |
669 } | 674 } |
670 | 675 |
671 TEST_P(InputHandlerProxyTest, GesturePinchWithWheelHandler) { | 676 TEST_P(InputHandlerProxyTest, GesturePinchWithWheelHandler) { |
672 // We will send the synthetic wheel event to the widget. | 677 // We will send the synthetic wheel event to the widget. |
673 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 678 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
674 VERIFY_AND_RESET_MOCKS(); | 679 VERIFY_AND_RESET_MOCKS(); |
675 | 680 |
676 gesture_.type = WebInputEvent::GesturePinchBegin; | 681 gesture_.type = WebInputEvent::GesturePinchBegin; |
677 EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlersAt(testing::_)) | 682 EXPECT_CALL(mock_input_handler_, |
678 .WillOnce(testing::Return(true)); | 683 EffectiveWheelEventListenerPropertiesAt(testing::_)) |
| 684 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); |
679 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 685 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
680 | 686 |
681 VERIFY_AND_RESET_MOCKS(); | 687 VERIFY_AND_RESET_MOCKS(); |
682 | 688 |
683 gesture_.type = WebInputEvent::GesturePinchUpdate; | 689 gesture_.type = WebInputEvent::GesturePinchUpdate; |
684 gesture_.data.pinchUpdate.scale = 1.5; | 690 gesture_.data.pinchUpdate.scale = 1.5; |
685 gesture_.x = 7; | 691 gesture_.x = 7; |
686 gesture_.y = 13; | 692 gesture_.y = 13; |
687 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 693 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
688 | 694 |
(...skipping 27 matching lines...) Expand all Loading... |
716 gesture_.type = WebInputEvent::GestureScrollUpdate; | 722 gesture_.type = WebInputEvent::GestureScrollUpdate; |
717 gesture_.data.scrollUpdate.deltaY = 40; | 723 gesture_.data.scrollUpdate.deltaY = 40; |
718 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 724 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
719 | 725 |
720 // However, after the pinch gesture starts, they should go to the impl | 726 // However, after the pinch gesture starts, they should go to the impl |
721 // thread. | 727 // thread. |
722 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 728 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
723 VERIFY_AND_RESET_MOCKS(); | 729 VERIFY_AND_RESET_MOCKS(); |
724 | 730 |
725 gesture_.type = WebInputEvent::GesturePinchBegin; | 731 gesture_.type = WebInputEvent::GesturePinchBegin; |
726 EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlersAt(testing::_)) | 732 EXPECT_CALL(mock_input_handler_, |
727 .WillOnce(testing::Return(false)); | 733 EffectiveWheelEventListenerPropertiesAt(testing::_)) |
| 734 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
728 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); | 735 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); |
729 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 736 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
730 | 737 |
731 VERIFY_AND_RESET_MOCKS(); | 738 VERIFY_AND_RESET_MOCKS(); |
732 | 739 |
733 gesture_.type = WebInputEvent::GesturePinchUpdate; | 740 gesture_.type = WebInputEvent::GesturePinchUpdate; |
734 gesture_.data.pinchUpdate.scale = 1.5; | 741 gesture_.data.pinchUpdate.scale = 1.5; |
735 gesture_.x = 7; | 742 gesture_.x = 7; |
736 gesture_.y = 13; | 743 gesture_.y = 13; |
737 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); | 744 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1802 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1796 } | 1803 } |
1797 | 1804 |
1798 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { | 1805 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { |
1799 // None of the three touch points fall in the touch region. So the event | 1806 // None of the three touch points fall in the touch region. So the event |
1800 // should be dropped. | 1807 // should be dropped. |
1801 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 1808 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
1802 VERIFY_AND_RESET_MOCKS(); | 1809 VERIFY_AND_RESET_MOCKS(); |
1803 | 1810 |
1804 EXPECT_CALL(mock_input_handler_, | 1811 EXPECT_CALL(mock_input_handler_, |
1805 DoTouchEventsBlockScrollAt( | 1812 EffectiveTouchEventListenerPropertiesAt( |
1806 testing::Property(&gfx::Point::x, testing::Gt(0)))) | 1813 testing::Property(&gfx::Point::x, testing::Gt(0)))) |
1807 .WillOnce(testing::Return(false)); | 1814 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1808 EXPECT_CALL(mock_input_handler_, | 1815 EXPECT_CALL(mock_input_handler_, |
1809 DoTouchEventsBlockScrollAt( | 1816 EffectiveTouchEventListenerPropertiesAt( |
1810 testing::Property(&gfx::Point::x, testing::Lt(0)))) | 1817 testing::Property(&gfx::Point::x, testing::Lt(0)))) |
1811 .WillOnce(testing::Return(false)); | 1818 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1812 | 1819 |
1813 WebTouchEvent touch; | 1820 WebTouchEvent touch; |
1814 touch.type = WebInputEvent::TouchStart; | 1821 touch.type = WebInputEvent::TouchStart; |
1815 | 1822 |
1816 touch.touchesLength = 3; | 1823 touch.touchesLength = 3; |
1817 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); | 1824 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); |
1818 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 1825 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
1819 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 1826 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
1820 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 1827 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
1821 | 1828 |
1822 VERIFY_AND_RESET_MOCKS(); | 1829 VERIFY_AND_RESET_MOCKS(); |
1823 } | 1830 } |
1824 | 1831 |
1825 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { | 1832 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { |
1826 // One of the touch points is on a touch-region. So the event should be sent | 1833 // One of the touch points is on a touch-region. So the event should be sent |
1827 // to the main thread. | 1834 // to the main thread. |
1828 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 1835 expected_disposition_ = InputHandlerProxy::NON_BLOCKING; |
1829 VERIFY_AND_RESET_MOCKS(); | 1836 VERIFY_AND_RESET_MOCKS(); |
1830 | 1837 |
1831 EXPECT_CALL(mock_input_handler_, | 1838 EXPECT_CALL(mock_input_handler_, |
1832 DoTouchEventsBlockScrollAt( | 1839 EffectiveTouchEventListenerPropertiesAt( |
1833 testing::Property(&gfx::Point::x, testing::Eq(0)))) | 1840 testing::Property(&gfx::Point::x, testing::Le(0)))) |
1834 .WillOnce(testing::Return(false)); | 1841 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kNone)); |
1835 EXPECT_CALL(mock_input_handler_, | 1842 EXPECT_CALL(mock_input_handler_, |
1836 DoTouchEventsBlockScrollAt( | 1843 EffectiveTouchEventListenerPropertiesAt( |
1837 testing::Property(&gfx::Point::x, testing::Gt(0)))) | 1844 testing::Property(&gfx::Point::x, testing::Gt(0)))) |
1838 .WillOnce(testing::Return(true)); | 1845 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); |
1839 // Since the second touch point hits a touch-region, there should be no | 1846 // Since the second touch point hits a touch-region, there should be no |
1840 // hit-testing for the third touch point. | 1847 // hit-testing for the third touch point. |
1841 | 1848 |
1842 WebTouchEvent touch; | 1849 WebTouchEvent touch; |
1843 touch.type = WebInputEvent::TouchStart; | 1850 touch.type = WebInputEvent::TouchStart; |
1844 | 1851 |
1845 touch.touchesLength = 3; | 1852 touch.touchesLength = 3; |
1846 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 1853 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
1847 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 1854 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
1848 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 1855 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); | 2532 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); |
2526 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2533 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2527 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); | 2534 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); |
2528 } | 2535 } |
2529 | 2536 |
2530 INSTANTIATE_TEST_CASE_P(AnimateInput, | 2537 INSTANTIATE_TEST_CASE_P(AnimateInput, |
2531 InputHandlerProxyTest, | 2538 InputHandlerProxyTest, |
2532 testing::ValuesIn(test_types)); | 2539 testing::ValuesIn(test_types)); |
2533 } // namespace test | 2540 } // namespace test |
2534 } // namespace ui | 2541 } // namespace ui |
OLD | NEW |