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

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

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