Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2471523002: Make touch events uncancelable during fling when they are on the current active scroll layer (Closed)
Patch Set: fling layer Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 void MouseMoveAt(const gfx::Point& mouse_position) override {} 156 void MouseMoveAt(const gfx::Point& mouse_position) override {}
157 157
158 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, 158 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt,
159 bool(const gfx::Point& point, 159 bool(const gfx::Point& point,
160 cc::InputHandler::ScrollInputType type)); 160 cc::InputHandler::ScrollInputType type));
161 161
162 MOCK_CONST_METHOD1( 162 MOCK_CONST_METHOD1(
163 GetEventListenerProperties, 163 GetEventListenerProperties,
164 cc::EventListenerProperties(cc::EventListenerClass event_class)); 164 cc::EventListenerProperties(cc::EventListenerClass event_class));
165 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); 165 MOCK_METHOD1(EventListenerTypeForTouchStartAt,
166 cc::EventListenerProperties(const gfx::Point& point));
166 167
167 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void()); 168 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void());
168 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset, 169 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset,
169 void(const gfx::ScrollOffset& root_offset)); 170 void(const gfx::ScrollOffset& root_offset));
170 171
171 bool IsCurrentlyScrollingViewport() const override { 172 bool IsCurrentlyScrollingViewport() const override {
172 return is_scrolling_root_; 173 return is_scrolling_root_;
173 } 174 }
174 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } 175 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; }
175 176
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 VERIFY_AND_RESET_MOCKS(); 1935 VERIFY_AND_RESET_MOCKS();
1935 1936
1936 EXPECT_CALL( 1937 EXPECT_CALL(
1937 mock_input_handler_, 1938 mock_input_handler_,
1938 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 1939 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
1939 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1940 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1940 EXPECT_CALL( 1941 EXPECT_CALL(
1941 mock_input_handler_, 1942 mock_input_handler_,
1942 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) 1943 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
1943 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1944 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1944 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) 1945 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_))
1945 .WillOnce(testing::Return(false)); 1946 .Times(2)
1946 EXPECT_CALL(mock_input_handler_, 1947 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kNone));
1947 DoTouchEventsBlockScrollAt(
1948 testing::Property(&gfx::Point::x, testing::Lt(0))))
1949 .WillOnce(testing::Return(false));
1950 1948
1951 WebTouchEvent touch; 1949 WebTouchEvent touch;
1952 touch.type = WebInputEvent::TouchStart; 1950 touch.type = WebInputEvent::TouchStart;
1953 1951
1954 touch.touchesLength = 3; 1952 touch.touchesLength = 3;
1955 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); 1953 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0);
1956 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 1954 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
1957 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 1955 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
1958 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 1956 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
1959 1957
1960 VERIFY_AND_RESET_MOCKS(); 1958 VERIFY_AND_RESET_MOCKS();
1961 } 1959 }
1962 1960
1963 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { 1961 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) {
1964 // One of the touch points is on a touch-region. So the event should be sent 1962 // One of the touch points is on a touch-region. So the event should be sent
1965 // to the main thread. 1963 // to the main thread.
1966 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 1964 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1967 VERIFY_AND_RESET_MOCKS(); 1965 VERIFY_AND_RESET_MOCKS();
1968 1966
1969 EXPECT_CALL(mock_input_handler_, 1967 EXPECT_CALL(mock_input_handler_,
1970 DoTouchEventsBlockScrollAt( 1968 EventListenerTypeForTouchStartAt(
1971 testing::Property(&gfx::Point::x, testing::Eq(0)))) 1969 testing::Property(&gfx::Point::x, testing::Eq(0))))
1972 .WillOnce(testing::Return(false)); 1970 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1973 EXPECT_CALL(mock_input_handler_, 1971 EXPECT_CALL(mock_input_handler_,
1974 DoTouchEventsBlockScrollAt( 1972 EventListenerTypeForTouchStartAt(
1975 testing::Property(&gfx::Point::x, testing::Gt(0)))) 1973 testing::Property(&gfx::Point::x, testing::Gt(0))))
1976 .WillOnce(testing::Return(true)); 1974 .WillOnce(testing::Return(
1975 cc::EventListenerProperties::kBlockingAndMaybePassiveDueToFling));
1977 // Since the second touch point hits a touch-region, there should be no 1976 // Since the second touch point hits a touch-region, there should be no
1978 // hit-testing for the third touch point. 1977 // hit-testing for the third touch point.
1979 1978
1980 WebTouchEvent touch; 1979 WebTouchEvent touch;
1981 touch.type = WebInputEvent::TouchStart; 1980 touch.type = WebInputEvent::TouchStart;
1982 1981
1983 touch.touchesLength = 3; 1982 touch.touchesLength = 3;
1984 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 1983 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
1985 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 1984 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
1986 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 1985 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
1987 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 1986 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
1988 1987
1989 VERIFY_AND_RESET_MOCKS(); 1988 VERIFY_AND_RESET_MOCKS();
1990 } 1989 }
1991 1990
1992 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { 1991 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) {
1993 // One of the touch points is on a touch-region. So the event should be sent 1992 // One of the touch points is not on a touch-region. So the event should be
1994 // to the main thread. 1993 // sent to the impl thread.
1995 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; 1994 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
1996 VERIFY_AND_RESET_MOCKS(); 1995 VERIFY_AND_RESET_MOCKS();
1997 1996
1998 EXPECT_CALL( 1997 EXPECT_CALL(
1999 mock_input_handler_, 1998 mock_input_handler_,
2000 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 1999 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
2001 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); 2000 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive));
2002 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) 2001 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_))
2003 .WillRepeatedly(testing::Return(false)); 2002 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kNone));
2004 2003
2005 WebTouchEvent touch; 2004 WebTouchEvent touch;
2006 touch.type = WebInputEvent::TouchStart; 2005 touch.type = WebInputEvent::TouchStart;
2007 2006
2008 touch.touchesLength = 3; 2007 touch.touchesLength = 3;
2009 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 2008 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
2010 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2009 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
2011 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 2010 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
2012 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2011 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2013 2012
2014 VERIFY_AND_RESET_MOCKS(); 2013 VERIFY_AND_RESET_MOCKS();
2015 } 2014 }
2016 2015
2017 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) { 2016 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) {
2018 // The touch start is not in a touch-region but there is a touch end handler 2017 // The touch start is not in a touch-region but there is a touch end handler
2019 // so to maintain targeting we need to dispatch the touch start as 2018 // so to maintain targeting we need to dispatch the touch start as
2020 // non-blocking but drop all touch moves. 2019 // non-blocking but drop all touch moves.
2021 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; 2020 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
2022 VERIFY_AND_RESET_MOCKS(); 2021 VERIFY_AND_RESET_MOCKS();
2023 2022
2024 EXPECT_CALL( 2023 EXPECT_CALL(
2025 mock_input_handler_, 2024 mock_input_handler_,
2026 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 2025 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
2027 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2026 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
2028 EXPECT_CALL( 2027 EXPECT_CALL(
2029 mock_input_handler_, 2028 mock_input_handler_,
2030 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) 2029 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
2031 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 2030 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
2032 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) 2031 EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartAt(testing::_))
2033 .WillOnce(testing::Return(false)); 2032 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
2034 2033
2035 WebTouchEvent touch; 2034 WebTouchEvent touch;
2036 touch.type = WebInputEvent::TouchStart; 2035 touch.type = WebInputEvent::TouchStart;
2037 touch.touchesLength = 1; 2036 touch.touchesLength = 1;
2038 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 2037 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
2039 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2038 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2040 2039
2041 touch.type = WebInputEvent::TouchMove; 2040 touch.type = WebInputEvent::TouchMove;
2042 touch.touchesLength = 1; 2041 touch.touchesLength = 1;
2043 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2042 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), 2813 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1),
2815 base::Bucket(5, 1), base::Bucket(14, 1))); 2814 base::Bucket(5, 1), base::Bucket(14, 1)));
2816 } 2815 }
2817 2816
2818 2817
2819 INSTANTIATE_TEST_CASE_P(AnimateInput, 2818 INSTANTIATE_TEST_CASE_P(AnimateInput,
2820 InputHandlerProxyTest, 2819 InputHandlerProxyTest,
2821 testing::ValuesIn(test_types)); 2820 testing::ValuesIn(test_types));
2822 } // namespace test 2821 } // namespace test
2823 } // namespace ui 2822 } // namespace ui
OLDNEW
« cc/trees/layer_tree_host_impl_unittest.cc ('K') | « ui/events/blink/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698