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

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

Issue 2854683002: Send a GSB to main thread before switching to it in the middle of scrolling. (Closed)
Patch Set: Created 3 years, 7 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/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 ~MockInputHandlerProxyClient() override {} 282 ~MockInputHandlerProxyClient() override {}
283 283
284 void WillShutdown() override {} 284 void WillShutdown() override {}
285 285
286 MOCK_METHOD1(TransferActiveWheelFlingAnimation, 286 MOCK_METHOD1(TransferActiveWheelFlingAnimation,
287 void(const WebActiveWheelFlingParameters&)); 287 void(const WebActiveWheelFlingParameters&));
288 288
289 MOCK_METHOD1(DispatchNonBlockingEventToMainThread_, 289 MOCK_METHOD1(DispatchNonBlockingEventToMainThread_,
290 void(const WebInputEvent&)); 290 void(const WebInputEvent&));
291 291
292 MOCK_METHOD1(GenerateScrollBeginAndSendToMainThread,
293 void(const blink::WebGestureEvent& update_event));
294
292 void DispatchNonBlockingEventToMainThread( 295 void DispatchNonBlockingEventToMainThread(
293 WebScopedInputEvent event, 296 WebScopedInputEvent event,
294 const ui::LatencyInfo& latency_info) override { 297 const ui::LatencyInfo& latency_info) override {
295 CHECK(event.get()); 298 CHECK(event.get());
296 DispatchNonBlockingEventToMainThread_(*event.get()); 299 DispatchNonBlockingEventToMainThread_(*event.get());
297 } 300 }
298 301
299 blink::WebGestureCurve* CreateFlingAnimationCurve( 302 blink::WebGestureCurve* CreateFlingAnimationCurve(
300 WebGestureDevice deviceSource, 303 WebGestureDevice deviceSource,
301 const WebFloatPoint& velocity, 304 const WebFloatPoint& velocity,
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 VERIFY_AND_RESET_MOCKS(); 1032 VERIFY_AND_RESET_MOCKS();
1030 } 1033 }
1031 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) { 1034 TEST_P(InputHandlerProxyTest, GestureFlingStartedTouchpad) {
1032 GestureFlingStartedTouchpad(); 1035 GestureFlingStartedTouchpad();
1033 } 1036 }
1034 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest, 1037 TEST_P(InputHandlerProxyWithoutWheelScrollLatchingTest,
1035 GestureFlingStartedTouchpad) { 1038 GestureFlingStartedTouchpad) {
1036 GestureFlingStartedTouchpad(); 1039 GestureFlingStartedTouchpad();
1037 } 1040 }
1038 1041
1042 TEST_P(InputHandlerProxyTest, GestureScrollHandlingSwitchedToMainThread) {
1043 // We shouldn't send any events to the widget for this gesture.
1044 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1045 VERIFY_AND_RESET_MOCKS();
1046
1047 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_))
1048 .WillOnce(testing::Return(kImplThreadScrollState));
1049
1050 // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
1051 gesture_.SetType(WebInputEvent::kGestureScrollBegin);
1052 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1053 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1054
1055 VERIFY_AND_RESET_MOCKS();
1056
1057 gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
1058 gesture_.data.scroll_update.delta_y = -40;
1059 EXPECT_CALL(
1060 mock_input_handler_,
1061 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
1062 .WillOnce(testing::Return(scroll_result_did_scroll_));
1063 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1064 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1065
1066 // The scroll handling switches to the main thread, a GSB is sent to the main
1067 // thread to initiate the hit testing and compute the scroll chain.
1068 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
1069 EXPECT_CALL(
1070 mock_input_handler_,
1071 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0))))
1072 .WillOnce(testing::Return(scroll_result_did_not_scroll_));
1073 EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
1074 .WillOnce(testing::Return(true));
1075 EXPECT_CALL(mock_client_,
1076 GenerateScrollBeginAndSendToMainThread(::testing::_));
1077 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1078 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1079
1080 VERIFY_AND_RESET_MOCKS();
1081
1082 gesture_.SetType(WebInputEvent::kGestureScrollEnd);
1083 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1084 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1085
1086 VERIFY_AND_RESET_MOCKS();
1087 }
1088
1039 TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) { 1089 TEST_P(InputHandlerProxyTest, GestureFlingTouchpadScrollLatchingEnabled) {
1040 // Reset the input_handler_ with wheel scroll latching enabled. 1090 // Reset the input_handler_ with wheel scroll latching enabled.
1041 input_handler_.reset( 1091 input_handler_.reset(
1042 new TestInputHandlerProxy(&mock_input_handler_, &mock_client_, true)); 1092 new TestInputHandlerProxy(&mock_input_handler_, &mock_client_, true));
1043 if (install_synchronous_handler_) { 1093 if (install_synchronous_handler_) {
1044 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) 1094 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler())
1045 .Times(1); 1095 .Times(1);
1046 input_handler_->SetOnlySynchronouslyAnimateRootFlings( 1096 input_handler_->SetOnlySynchronouslyAnimateRootFlings(
1047 &mock_synchronous_input_handler_); 1097 &mock_synchronous_input_handler_);
1048 } 1098 }
(...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after
3818 INSTANTIATE_TEST_CASE_P(AnimateInput, 3868 INSTANTIATE_TEST_CASE_P(AnimateInput,
3819 InputHandlerProxyWithoutWheelScrollLatchingTest, 3869 InputHandlerProxyWithoutWheelScrollLatchingTest,
3820 testing::ValuesIn(test_types)); 3870 testing::ValuesIn(test_types));
3821 3871
3822 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests, 3872 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests,
3823 InputHandlerProxyEventQueueTest, 3873 InputHandlerProxyEventQueueTest,
3824 testing::Bool()); 3874 testing::Bool());
3825 3875
3826 } // namespace test 3876 } // namespace test
3827 } // namespace ui 3877 } // 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