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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 void MouseMoveAt(const gfx::Point& mouse_position) override {} | 190 void MouseMoveAt(const gfx::Point& mouse_position) override {} |
191 | 191 |
192 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, | 192 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, |
193 bool(const gfx::Point& point, | 193 bool(const gfx::Point& point, |
194 cc::InputHandler::ScrollInputType type)); | 194 cc::InputHandler::ScrollInputType type)); |
195 | 195 |
196 MOCK_CONST_METHOD1( | 196 MOCK_CONST_METHOD1( |
197 GetEventListenerProperties, | 197 GetEventListenerProperties, |
198 cc::EventListenerProperties(cc::EventListenerClass event_class)); | 198 cc::EventListenerProperties(cc::EventListenerClass event_class)); |
199 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); | 199 MOCK_METHOD1( |
| 200 EventListenerTypeForTouchStartAt, |
| 201 cc::InputHandler::TouchStartEventListenerType(const gfx::Point& point)); |
200 | 202 |
201 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void()); | 203 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void()); |
202 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset, | 204 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset, |
203 void(const gfx::ScrollOffset& root_offset)); | 205 void(const gfx::ScrollOffset& root_offset)); |
204 | 206 |
205 bool IsCurrentlyScrollingViewport() const override { | 207 bool IsCurrentlyScrollingViewport() const override { |
206 return is_scrolling_root_; | 208 return is_scrolling_root_; |
207 } | 209 } |
208 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } | 210 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } |
209 | 211 |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2024 VERIFY_AND_RESET_MOCKS(); | 2026 VERIFY_AND_RESET_MOCKS(); |
2025 | 2027 |
2026 EXPECT_CALL( | 2028 EXPECT_CALL( |
2027 mock_input_handler_, | 2029 mock_input_handler_, |
2028 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) | 2030 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) |
2029 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); | 2031 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
2030 EXPECT_CALL( | 2032 EXPECT_CALL( |
2031 mock_input_handler_, | 2033 mock_input_handler_, |
2032 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) | 2034 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) |
2033 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); | 2035 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
2034 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) | 2036 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_)) |
2035 .WillOnce(testing::Return(false)); | 2037 .Times(2) |
2036 EXPECT_CALL(mock_input_handler_, | 2038 .WillRepeatedly(testing::Return( |
2037 DoTouchEventsBlockScrollAt( | 2039 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); |
2038 testing::Property(&gfx::Point::x, testing::Lt(0)))) | |
2039 .WillOnce(testing::Return(false)); | |
2040 | 2040 |
2041 WebTouchEvent touch; | 2041 WebTouchEvent touch; |
2042 touch.type = WebInputEvent::TouchStart; | 2042 touch.type = WebInputEvent::TouchStart; |
2043 | 2043 |
2044 touch.touchesLength = 3; | 2044 touch.touchesLength = 3; |
2045 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); | 2045 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); |
2046 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 2046 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
2047 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 2047 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
2048 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 2048 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
2049 | 2049 |
2050 VERIFY_AND_RESET_MOCKS(); | 2050 VERIFY_AND_RESET_MOCKS(); |
2051 } | 2051 } |
2052 | 2052 |
2053 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { | 2053 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { |
2054 // One of the touch points is on a touch-region. So the event should be sent | 2054 // One of the touch points is on a touch-region. So the event should be sent |
2055 // to the main thread. | 2055 // to the main thread. |
2056 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 2056 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
2057 VERIFY_AND_RESET_MOCKS(); | 2057 VERIFY_AND_RESET_MOCKS(); |
2058 | 2058 |
2059 EXPECT_CALL(mock_input_handler_, | 2059 EXPECT_CALL(mock_input_handler_, |
2060 DoTouchEventsBlockScrollAt( | 2060 EventListenerTypeForTouchStartAt( |
2061 testing::Property(&gfx::Point::x, testing::Eq(0)))) | 2061 testing::Property(&gfx::Point::x, testing::Eq(0)))) |
2062 .WillOnce(testing::Return(false)); | 2062 .WillOnce(testing::Return( |
| 2063 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); |
2063 EXPECT_CALL(mock_input_handler_, | 2064 EXPECT_CALL(mock_input_handler_, |
2064 DoTouchEventsBlockScrollAt( | 2065 EventListenerTypeForTouchStartAt( |
2065 testing::Property(&gfx::Point::x, testing::Gt(0)))) | 2066 testing::Property(&gfx::Point::x, testing::Gt(0)))) |
2066 .WillOnce(testing::Return(true)); | 2067 .WillOnce(testing::Return(cc::InputHandler::TouchStartEventListenerType:: |
| 2068 HANDLER_ON_FLINGING_LAYER)); |
2067 // Since the second touch point hits a touch-region, there should be no | 2069 // Since the second touch point hits a touch-region, there should be no |
2068 // hit-testing for the third touch point. | 2070 // hit-testing for the third touch point. |
2069 | 2071 |
2070 WebTouchEvent touch; | 2072 WebTouchEvent touch; |
2071 touch.type = WebInputEvent::TouchStart; | 2073 touch.type = WebInputEvent::TouchStart; |
2072 | 2074 |
2073 touch.touchesLength = 3; | 2075 touch.touchesLength = 3; |
2074 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 2076 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
2075 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 2077 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
2076 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 2078 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
2077 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 2079 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
2078 | 2080 |
2079 VERIFY_AND_RESET_MOCKS(); | 2081 VERIFY_AND_RESET_MOCKS(); |
2080 } | 2082 } |
2081 | 2083 |
2082 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { | 2084 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { |
2083 // One of the touch points is on a touch-region. So the event should be sent | 2085 // One of the touch points is not on a touch-region. So the event should be |
2084 // to the main thread. | 2086 // sent to the impl thread. |
2085 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; | 2087 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; |
2086 VERIFY_AND_RESET_MOCKS(); | 2088 VERIFY_AND_RESET_MOCKS(); |
2087 | 2089 |
2088 EXPECT_CALL( | 2090 EXPECT_CALL( |
2089 mock_input_handler_, | 2091 mock_input_handler_, |
2090 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) | 2092 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) |
2091 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); | 2093 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); |
2092 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) | 2094 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_)) |
2093 .WillRepeatedly(testing::Return(false)); | 2095 .WillRepeatedly(testing::Return( |
| 2096 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); |
2094 | 2097 |
2095 WebTouchEvent touch; | 2098 WebTouchEvent touch; |
2096 touch.type = WebInputEvent::TouchStart; | 2099 touch.type = WebInputEvent::TouchStart; |
2097 | 2100 |
2098 touch.touchesLength = 3; | 2101 touch.touchesLength = 3; |
2099 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 2102 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
2100 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 2103 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
2101 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 2104 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
2102 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 2105 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
2103 | 2106 |
2104 VERIFY_AND_RESET_MOCKS(); | 2107 VERIFY_AND_RESET_MOCKS(); |
2105 } | 2108 } |
2106 | 2109 |
2107 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) { | 2110 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) { |
2108 // The touch start is not in a touch-region but there is a touch end handler | 2111 // The touch start is not in a touch-region but there is a touch end handler |
2109 // so to maintain targeting we need to dispatch the touch start as | 2112 // so to maintain targeting we need to dispatch the touch start as |
2110 // non-blocking but drop all touch moves. | 2113 // non-blocking but drop all touch moves. |
2111 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; | 2114 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; |
2112 VERIFY_AND_RESET_MOCKS(); | 2115 VERIFY_AND_RESET_MOCKS(); |
2113 | 2116 |
2114 EXPECT_CALL( | 2117 EXPECT_CALL( |
2115 mock_input_handler_, | 2118 mock_input_handler_, |
2116 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) | 2119 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) |
2117 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); | 2120 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
2118 EXPECT_CALL( | 2121 EXPECT_CALL( |
2119 mock_input_handler_, | 2122 mock_input_handler_, |
2120 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) | 2123 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) |
2121 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); | 2124 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); |
2122 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) | 2125 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_)) |
2123 .WillOnce(testing::Return(false)); | 2126 .WillOnce(testing::Return( |
| 2127 cc::InputHandler::TouchStartEventListenerType::NO_HANDLER)); |
2124 | 2128 |
2125 WebTouchEvent touch; | 2129 WebTouchEvent touch; |
2126 touch.type = WebInputEvent::TouchStart; | 2130 touch.type = WebInputEvent::TouchStart; |
2127 touch.touchesLength = 1; | 2131 touch.touchesLength = 1; |
2128 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 2132 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
2129 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 2133 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
2130 | 2134 |
2131 touch.type = WebInputEvent::TouchMove; | 2135 touch.type = WebInputEvent::TouchMove; |
2132 touch.touchesLength = 1; | 2136 touch.touchesLength = 1; |
2133 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 2137 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3082 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70, | 3086 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70, |
3083 1); | 3087 1); |
3084 } | 3088 } |
3085 | 3089 |
3086 INSTANTIATE_TEST_CASE_P(AnimateInput, | 3090 INSTANTIATE_TEST_CASE_P(AnimateInput, |
3087 InputHandlerProxyTest, | 3091 InputHandlerProxyTest, |
3088 testing::ValuesIn(test_types)); | 3092 testing::ValuesIn(test_types)); |
3089 | 3093 |
3090 } // namespace test | 3094 } // namespace test |
3091 } // namespace ui | 3095 } // namespace ui |
OLD | NEW |