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

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: clean up code 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(DoTouchEventsBlockScrollAt,
166 TouchStartHitResult(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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return new FakeWebGestureCurve( 249 return new FakeWebGestureCurve(
249 blink::WebFloatSize(velocity.x, velocity.y), 250 blink::WebFloatSize(velocity.x, velocity.y),
250 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); 251 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
251 } 252 }
252 253
253 MOCK_METHOD4(DidOverscroll, 254 MOCK_METHOD4(DidOverscroll,
254 void(const gfx::Vector2dF& accumulated_overscroll, 255 void(const gfx::Vector2dF& accumulated_overscroll,
255 const gfx::Vector2dF& latest_overscroll_delta, 256 const gfx::Vector2dF& latest_overscroll_delta,
256 const gfx::Vector2dF& current_fling_velocity, 257 const gfx::Vector2dF& current_fling_velocity,
257 const gfx::PointF& causal_event_viewport_point)); 258 const gfx::PointF& causal_event_viewport_point));
258 void DidStartFlinging() override {}
259 void DidStopFlinging() override {} 259 void DidStopFlinging() override {}
260 void DidAnimateForInput() override {} 260 void DidAnimateForInput() override {}
261 261
262 private: 262 private:
263 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); 263 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
264 }; 264 };
265 265
266 class MockInputHandlerProxyClientWithDidAnimateForInput 266 class MockInputHandlerProxyClientWithDidAnimateForInput
267 : public MockInputHandlerProxyClient { 267 : public MockInputHandlerProxyClient {
268 public: 268 public:
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 1936
1937 EXPECT_CALL( 1937 EXPECT_CALL(
1938 mock_input_handler_, 1938 mock_input_handler_,
1939 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 1939 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
1940 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1940 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1941 EXPECT_CALL( 1941 EXPECT_CALL(
1942 mock_input_handler_, 1942 mock_input_handler_,
1943 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) 1943 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
1944 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1944 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1945 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) 1945 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_))
1946 .WillOnce(testing::Return(false)); 1946 .WillOnce(
1947 EXPECT_CALL(mock_input_handler_, 1947 testing::Return(cc::InputHandler::TouchStartHitResult::HANDLER));
1948 DoTouchEventsBlockScrollAt( 1948 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::Property(
1949 testing::Property(&gfx::Point::x, testing::Lt(0)))) 1949 &gfx::Point::x, testing::Lt(0))))
1950 .WillOnce(testing::Return(false)); 1950 .WillOnce(
1951 testing::Return(cc::InputHandler::TouchStartHitResult::HANDLER));
1951 1952
1952 WebTouchEvent touch; 1953 WebTouchEvent touch;
1953 touch.type = WebInputEvent::TouchStart; 1954 touch.type = WebInputEvent::TouchStart;
1954 1955
1955 touch.touchesLength = 3; 1956 touch.touchesLength = 3;
1956 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0); 1957 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StateStationary, 0, 0);
1957 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 1958 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
1958 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 1959 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
1959 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 1960 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
1960 1961
1961 VERIFY_AND_RESET_MOCKS(); 1962 VERIFY_AND_RESET_MOCKS();
1962 } 1963 }
1963 1964
1964 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { 1965 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) {
1965 // One of the touch points is on a touch-region. So the event should be sent 1966 // One of the touch points is on a touch-region. So the event should be sent
1966 // to the main thread. 1967 // to the main thread.
1967 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 1968 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1968 VERIFY_AND_RESET_MOCKS(); 1969 VERIFY_AND_RESET_MOCKS();
1969 1970
1970 EXPECT_CALL(mock_input_handler_, 1971 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::Property(
1971 DoTouchEventsBlockScrollAt( 1972 &gfx::Point::x, testing::Eq(0))))
1972 testing::Property(&gfx::Point::x, testing::Eq(0)))) 1973 .WillOnce(
1973 .WillOnce(testing::Return(false)); 1974 testing::Return(cc::InputHandler::TouchStartHitResult::HANDLER));
1974 EXPECT_CALL(mock_input_handler_, 1975 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::Property(
1975 DoTouchEventsBlockScrollAt( 1976 &gfx::Point::x, testing::Gt(0))))
1976 testing::Property(&gfx::Point::x, testing::Gt(0)))) 1977 .WillOnce(
1977 .WillOnce(testing::Return(true)); 1978 testing::Return(cc::InputHandler::TouchStartHitResult::SAME_LAYER));
1978 // Since the second touch point hits a touch-region, there should be no 1979 // Since the second touch point hits a touch-region, there should be no
1979 // hit-testing for the third touch point. 1980 // hit-testing for the third touch point.
1980 1981
1981 WebTouchEvent touch; 1982 WebTouchEvent touch;
1982 touch.type = WebInputEvent::TouchStart; 1983 touch.type = WebInputEvent::TouchStart;
1983 1984
1984 touch.touchesLength = 3; 1985 touch.touchesLength = 3;
1985 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 1986 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
1986 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 1987 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
1987 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 1988 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
1988 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 1989 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
1989 1990
1990 VERIFY_AND_RESET_MOCKS(); 1991 VERIFY_AND_RESET_MOCKS();
1991 } 1992 }
1992 1993
1993 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { 1994 TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) {
1994 // One of the touch points is on a touch-region. So the event should be sent 1995 // One of the touch points is on a touch-region. So the event should be sent
1995 // to the main thread. 1996 // to the main thread.
1996 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; 1997 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
1997 VERIFY_AND_RESET_MOCKS(); 1998 VERIFY_AND_RESET_MOCKS();
1998 1999
1999 EXPECT_CALL( 2000 EXPECT_CALL(
2000 mock_input_handler_, 2001 mock_input_handler_,
2001 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 2002 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
2002 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive)); 2003 .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive));
2003 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) 2004 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_))
2004 .WillRepeatedly(testing::Return(false)); 2005 .WillRepeatedly(
2006 testing::Return(cc::InputHandler::TouchStartHitResult::HANDLER));
2005 2007
2006 WebTouchEvent touch; 2008 WebTouchEvent touch;
2007 touch.type = WebInputEvent::TouchStart; 2009 touch.type = WebInputEvent::TouchStart;
2008 2010
2009 touch.touchesLength = 3; 2011 touch.touchesLength = 3;
2010 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 2012 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
2011 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2013 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
2012 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 2014 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
2013 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2015 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2014 2016
2015 VERIFY_AND_RESET_MOCKS(); 2017 VERIFY_AND_RESET_MOCKS();
2016 } 2018 }
2017 2019
2018 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) { 2020 TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) {
2019 // The touch start is not in a touch-region but there is a touch end handler 2021 // The touch start is not in a touch-region but there is a touch end handler
2020 // so to maintain targeting we need to dispatch the touch start as 2022 // so to maintain targeting we need to dispatch the touch start as
2021 // non-blocking but drop all touch moves. 2023 // non-blocking but drop all touch moves.
2022 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING; 2024 expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
2023 VERIFY_AND_RESET_MOCKS(); 2025 VERIFY_AND_RESET_MOCKS();
2024 2026
2025 EXPECT_CALL( 2027 EXPECT_CALL(
2026 mock_input_handler_, 2028 mock_input_handler_,
2027 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove)) 2029 GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
2028 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 2030 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
2029 EXPECT_CALL( 2031 EXPECT_CALL(
2030 mock_input_handler_, 2032 mock_input_handler_,
2031 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel)) 2033 GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
2032 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking)); 2034 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
2033 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_)) 2035 EXPECT_CALL(mock_input_handler_, DoTouchEventsBlockScrollAt(testing::_))
2034 .WillOnce(testing::Return(false)); 2036 .WillOnce(
2037 testing::Return(cc::InputHandler::TouchStartHitResult::HANDLER));
2035 2038
2036 WebTouchEvent touch; 2039 WebTouchEvent touch;
2037 touch.type = WebInputEvent::TouchStart; 2040 touch.type = WebInputEvent::TouchStart;
2038 touch.touchesLength = 1; 2041 touch.touchesLength = 1;
2039 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 2042 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
2040 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 2043 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
2041 2044
2042 touch.type = WebInputEvent::TouchMove; 2045 touch.type = WebInputEvent::TouchMove;
2043 touch.touchesLength = 1; 2046 touch.touchesLength = 1;
2044 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 2047 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2815 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), 2818 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1),
2816 base::Bucket(5, 1), base::Bucket(14, 1))); 2819 base::Bucket(5, 1), base::Bucket(14, 1)));
2817 } 2820 }
2818 2821
2819 2822
2820 INSTANTIATE_TEST_CASE_P(AnimateInput, 2823 INSTANTIATE_TEST_CASE_P(AnimateInput,
2821 InputHandlerProxyTest, 2824 InputHandlerProxyTest,
2822 testing::ValuesIn(test_types)); 2825 testing::ValuesIn(test_types));
2823 } // namespace test 2826 } // namespace test
2824 } // namespace ui 2827 } // namespace ui
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « ui/events/blink/input_handler_proxy_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698