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/macros.h" | 9 #include "base/macros.h" |
10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 VERIFY_AND_RESET_MOCKS(); | 1984 VERIFY_AND_RESET_MOCKS(); |
1985 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 1985 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
1986 } | 1986 } |
1987 | 1987 |
1988 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { | 1988 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { |
1989 // None of the three touch points fall in the touch region. So the event | 1989 // None of the three touch points fall in the touch region. So the event |
1990 // should be dropped. | 1990 // should be dropped. |
1991 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 1991 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
1992 VERIFY_AND_RESET_MOCKS(); | 1992 VERIFY_AND_RESET_MOCKS(); |
1993 | 1993 |
1994 EXPECT_CALL(mock_input_handler_, | 1994 EXPECT_CALL( |
1995 GetEventListenerProperties(cc::EventListenerClass::kTouch)) | 1995 mock_input_handler_, |
| 1996 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) |
| 1997 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
| 1998 EXPECT_CALL( |
| 1999 mock_input_handler_, |
| 2000 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) |
1996 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); | 2001 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
1997 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) | 2002 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) |
1998 .WillOnce(testing::Return(false)); | 2003 .WillOnce(testing::Return(false)); |
1999 EXPECT_CALL(mock_input_handler_, | 2004 EXPECT_CALL(mock_input_handler_, |
2000 DoTouchEventsBlockScrollAt( | 2005 DoTouchEventsBlockScrollAt( |
2001 testing::Property(&gfx::Point::x, testing::Lt(0)))) | 2006 testing::Property(&gfx::Point::x, testing::Lt(0)))) |
2002 .WillOnce(testing::Return(false)); | 2007 .WillOnce(testing::Return(false)); |
2003 | 2008 |
2004 WebTouchEvent touch; | 2009 WebTouchEvent touch; |
2005 touch.type = WebInputEvent::TouchStart; | 2010 touch.type = WebInputEvent::TouchStart; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 | 2046 |
2042 VERIFY_AND_RESET_MOCKS(); | 2047 VERIFY_AND_RESET_MOCKS(); |
2043 } | 2048 } |
2044 | 2049 |
2045 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { | 2050 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { |
2046 // One of the touch points is on a touch-region. So the event should be sent | 2051 // One of the touch points is on a touch-region. So the event should be sent |
2047 // to the main thread. | 2052 // to the main thread. |
2048 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; | 2053 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; |
2049 VERIFY_AND_RESET_MOCKS(); | 2054 VERIFY_AND_RESET_MOCKS(); |
2050 | 2055 |
2051 EXPECT_CALL(mock_input_handler_, | 2056 EXPECT_CALL( |
2052 GetEventListenerProperties(cc::EventListenerClass::kTouch)) | 2057 mock_input_handler_, |
| 2058 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) |
2053 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); | 2059 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); |
2054 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) | 2060 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) |
2055 .WillRepeatedly(testing::Return(false)); | 2061 .WillRepeatedly(testing::Return(false)); |
2056 | 2062 |
2057 WebTouchEvent touch; | 2063 WebTouchEvent touch; |
2058 touch.type = WebInputEvent::TouchStart; | 2064 touch.type = WebInputEvent::TouchStart; |
2059 | 2065 |
2060 touch.touchesLength = 3; | 2066 touch.touchesLength = 3; |
2061 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); | 2067 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
2062 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); | 2068 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
2063 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); | 2069 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); |
2064 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); | 2070 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
2065 | 2071 |
2066 VERIFY_AND_RESET_MOCKS(); | 2072 VERIFY_AND_RESET_MOCKS(); |
2067 } | 2073 } |
2068 | 2074 |
| 2075 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) { |
| 2076 // The touch start is not in a touch-region but there is a touch end handler |
| 2077 // so to maintain targeting we need to dispatch the touch start as |
| 2078 // non-blocking but drop all touch moves. |
| 2079 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; |
| 2080 VERIFY_AND_RESET_MOCKS(); |
| 2081 |
| 2082 EXPECT_CALL( |
| 2083 mock_input_handler_, |
| 2084 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) |
| 2085 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
| 2086 EXPECT_CALL( |
| 2087 mock_input_handler_, |
| 2088 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) |
| 2089 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); |
| 2090 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) |
| 2091 .WillOnce(testing::Return(false)); |
| 2092 |
| 2093 WebTouchEvent touch; |
| 2094 touch.type = WebInputEvent::TouchStart; |
| 2095 touch.touchesLength = 1; |
| 2096 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); |
| 2097 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); |
| 2098 |
| 2099 touch.type = WebInputEvent::TouchMove; |
| 2100 touch.touchesLength = 1; |
| 2101 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); |
| 2102 EXPECT_EQ(InputHandlerProxy::DROP_EVENT, |
| 2103 input_handler_->HandleInputEvent(touch)); |
| 2104 VERIFY_AND_RESET_MOCKS(); |
| 2105 } |
| 2106 |
2069 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { | 2107 TEST_P(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { |
2070 // We shouldn't send any events to the widget for this gesture. | 2108 // We shouldn't send any events to the widget for this gesture. |
2071 expected_disposition_ = InputHandlerProxy::DID_HANDLE; | 2109 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
2072 VERIFY_AND_RESET_MOCKS(); | 2110 VERIFY_AND_RESET_MOCKS(); |
2073 | 2111 |
2074 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 2112 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
2075 .WillOnce(testing::Return(kImplThreadScrollState)); | 2113 .WillOnce(testing::Return(kImplThreadScrollState)); |
2076 gesture_.type = WebInputEvent::GestureScrollBegin; | 2114 gesture_.type = WebInputEvent::GestureScrollBegin; |
2077 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; | 2115 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen; |
2078 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 2116 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2820 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), | 2858 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), |
2821 base::Bucket(5, 1), base::Bucket(14, 1))); | 2859 base::Bucket(5, 1), base::Bucket(14, 1))); |
2822 } | 2860 } |
2823 | 2861 |
2824 | 2862 |
2825 INSTANTIATE_TEST_CASE_P(AnimateInput, | 2863 INSTANTIATE_TEST_CASE_P(AnimateInput, |
2826 InputHandlerProxyTest, | 2864 InputHandlerProxyTest, |
2827 testing::ValuesIn(test_types)); | 2865 testing::ValuesIn(test_types)); |
2828 } // namespace test | 2866 } // namespace test |
2829 } // namespace ui | 2867 } // namespace ui |
OLD | NEW |