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

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

Issue 2341873002: Handle touchpad flings with passive event listeners on compositor thread. (Closed)
Patch Set: Try to fix funky windows build failure Created 4 years, 3 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_client.h ('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 <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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 DISALLOW_COPY_AND_ASSIGN(FakeWebGestureCurve); 204 DISALLOW_COPY_AND_ASSIGN(FakeWebGestureCurve);
205 }; 205 };
206 206
207 class MockInputHandlerProxyClient 207 class MockInputHandlerProxyClient
208 : public InputHandlerProxyClient { 208 : public InputHandlerProxyClient {
209 public: 209 public:
210 MockInputHandlerProxyClient() {} 210 MockInputHandlerProxyClient() {}
211 ~MockInputHandlerProxyClient() override {} 211 ~MockInputHandlerProxyClient() override {}
212 212
213 void WillShutdown() override {} 213 MOCK_METHOD0(WillShutdown, void());
214 214
215 MOCK_METHOD1(TransferActiveWheelFlingAnimation, 215 MOCK_METHOD1(TransferActiveWheelFlingAnimation,
216 void(const WebActiveWheelFlingParameters&)); 216 void(const WebActiveWheelFlingParameters&));
217 217
218 MOCK_METHOD2(DispatchNonBlockingEventToMainThread_,
219 void(const WebInputEvent& event,
220 const ui::LatencyInfo& latency_info));
221
222 void DispatchNonBlockingEventToMainThread(
223 ui::ScopedWebInputEvent event,
224 const ui::LatencyInfo& latency_info) {
225 CHECK(event.get());
226 DispatchNonBlockingEventToMainThread_(*event.get(), latency_info);
227 }
228
218 blink::WebGestureCurve* CreateFlingAnimationCurve( 229 blink::WebGestureCurve* CreateFlingAnimationCurve(
219 WebGestureDevice deviceSource, 230 WebGestureDevice deviceSource,
220 const WebFloatPoint& velocity, 231 const WebFloatPoint& velocity,
221 const WebSize& cumulative_scroll) override { 232 const WebSize& cumulative_scroll) {
222 return new FakeWebGestureCurve( 233 return new FakeWebGestureCurve(
223 blink::WebFloatSize(velocity.x, velocity.y), 234 blink::WebFloatSize(velocity.x, velocity.y),
224 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); 235 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
225 } 236 }
226 237
227 MOCK_METHOD4(DidOverscroll, 238 MOCK_METHOD4(DidOverscroll,
228 void(const gfx::Vector2dF& accumulated_overscroll, 239 void(const gfx::Vector2dF& accumulated_overscroll,
229 const gfx::Vector2dF& latest_overscroll_delta, 240 const gfx::Vector2dF& latest_overscroll_delta,
230 const gfx::Vector2dF& current_fling_velocity, 241 const gfx::Vector2dF& current_fling_velocity,
231 const gfx::PointF& causal_event_viewport_point)); 242 const gfx::PointF& causal_event_viewport_point));
232 void DidStartFlinging() override {} 243 void DidStartFlinging() override{};
Rick Byers 2016/09/16 14:00:54 nit: why the semicolons? Definitions don't normal
dtapuska 2016/09/19 19:37:39 Err; I initially tried to mock this entire class;
233 void DidStopFlinging() override {} 244 void DidStopFlinging() override{};
234 void DidAnimateForInput() override {} 245 void DidAnimateForInput() override{};
235 246
236 private: 247 private:
237 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); 248 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
238 }; 249 };
239 250
240 class MockInputHandlerProxyClientWithDidAnimateForInput 251 class MockInputHandlerProxyClientWithDidAnimateForInput
241 : public MockInputHandlerProxyClient { 252 : public MockInputHandlerProxyClient {
242 public: 253 public:
243 MockInputHandlerProxyClientWithDidAnimateForInput() {} 254 MockInputHandlerProxyClientWithDidAnimateForInput() {}
244 ~MockInputHandlerProxyClientWithDidAnimateForInput() override {} 255 ~MockInputHandlerProxyClientWithDidAnimateForInput() override {}
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // lead to the scroll (either wheel or gesture scroll), so there should be no 1005 // lead to the scroll (either wheel or gesture scroll), so there should be no
995 // visible hitch. 1006 // visible hitch.
996 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1007 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
997 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1008 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
998 .Times(0); 1009 .Times(0);
999 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); 1010 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1000 Animate(time); 1011 Animate(time);
1001 1012
1002 VERIFY_AND_RESET_MOCKS(); 1013 VERIFY_AND_RESET_MOCKS();
1003 1014
1004 // The second call should punt the fling to the main thread 1015 // The second call should punt activate the fling and call the method
1005 // because of a passive event listener. 1016 // dispatching the events for the passive event listeners.
1006 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); 1017 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1007 EXPECT_CALL(mock_input_handler_, 1018 EXPECT_CALL(mock_input_handler_,
1008 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1019 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1009 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive)); 1020 .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
1010 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1021 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1011 .Times(0); 1022 .WillOnce(testing::Return(kImplThreadScrollState));
1012 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
1013 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(0);
1014 // Expected wheel fling animation parameters:
1015 // *) fling_delta and fling_point should match the original GestureFlingStart
1016 // event
1017 // *) startTime should be 10 to match the time parameter of the first
1018 // Animate() call after the GestureFlingStart
1019 EXPECT_CALL( 1023 EXPECT_CALL(
1020 mock_client_, 1024 mock_input_handler_,
1021 TransferActiveWheelFlingAnimation(testing::AllOf( 1025 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1022 testing::Field(&WebActiveWheelFlingParameters::delta, 1026 .WillOnce(testing::Return(scroll_result_did_scroll_));
1023 testing::Eq(fling_delta)), 1027 EXPECT_CALL(mock_client_,
1024 testing::Field(&WebActiveWheelFlingParameters::point, 1028 DispatchNonBlockingEventToMainThread_(testing::_, testing::_))
Rick Byers 2016/09/16 14:00:54 nit: Don't you want to still test the parameters o
dtapuska 2016/09/19 19:37:39 Done.
1025 testing::Eq(fling_point)), 1029 .Times(1);
1026 testing::Field(&WebActiveWheelFlingParameters::globalPoint, 1030 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(1);
1027 testing::Eq(fling_global_point)), 1031
1028 testing::Field(&WebActiveWheelFlingParameters::modifiers,
1029 testing::Eq(modifiers)),
1030 testing::Field(&WebActiveWheelFlingParameters::startTime,
1031 testing::Eq(10)),
1032 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll,
1033 testing::_))));
1034 time += base::TimeDelta::FromMilliseconds(100); 1032 time += base::TimeDelta::FromMilliseconds(100);
1035 Animate(time); 1033 Animate(time);
1036 1034
1037 VERIFY_AND_RESET_MOCKS(); 1035 VERIFY_AND_RESET_MOCKS();
1038 1036
1039 // Since we've aborted the fling, the next animation should be a no-op and 1037 // Ensure we can cancel the gesture.
1040 // should not result in another 1038 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1041 // frame being requested.
1042 EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
1043 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1044 .Times(0);
1045 time += base::TimeDelta::FromMilliseconds(100);
1046 Animate(time);
1047
1048 // Since we've transferred the fling to the main thread, we need to pass the
1049 // next GestureFlingCancel to the main
1050 // thread as well.
1051 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1052 gesture_.type = WebInputEvent::GestureFlingCancel; 1039 gesture_.type = WebInputEvent::GestureFlingCancel;
1053 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1040 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1054 1041
1055 VERIFY_AND_RESET_MOCKS(); 1042 VERIFY_AND_RESET_MOCKS();
1056 } 1043 }
1057 1044
1058 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { 1045 TEST_P(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) {
1059 // We shouldn't send any events to the widget for this gesture. 1046 // We shouldn't send any events to the widget for this gesture.
1060 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1047 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1061 VERIFY_AND_RESET_MOCKS(); 1048 VERIFY_AND_RESET_MOCKS();
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after
2803 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), 2790 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1),
2804 base::Bucket(5, 1), base::Bucket(14, 1))); 2791 base::Bucket(5, 1), base::Bucket(14, 1)));
2805 } 2792 }
2806 2793
2807 2794
2808 INSTANTIATE_TEST_CASE_P(AnimateInput, 2795 INSTANTIATE_TEST_CASE_P(AnimateInput,
2809 InputHandlerProxyTest, 2796 InputHandlerProxyTest,
2810 testing::ValuesIn(test_types)); 2797 testing::ValuesIn(test_types));
2811 } // namespace test 2798 } // namespace test
2812 } // namespace ui 2799 } // namespace ui
OLDNEW
« no previous file with comments | « 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