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

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

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: Update ScrollManager to pass the test. Created 3 years, 4 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
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 std::unique_ptr<blink::WebGestureCurve> CreateFlingAnimationCurve( 306 std::unique_ptr<blink::WebGestureCurve> CreateFlingAnimationCurve(
307 WebGestureDevice deviceSource, 307 WebGestureDevice deviceSource,
308 const WebFloatPoint& velocity, 308 const WebFloatPoint& velocity,
309 const WebSize& cumulative_scroll) override { 309 const WebSize& cumulative_scroll) override {
310 return base::MakeUnique<FakeWebGestureCurve>( 310 return base::MakeUnique<FakeWebGestureCurve>(
311 blink::WebFloatSize(velocity.x, velocity.y), 311 blink::WebFloatSize(velocity.x, velocity.y),
312 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); 312 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
313 } 313 }
314 314
315 MOCK_METHOD4(DidOverscroll, 315 MOCK_METHOD5(
316 void(const gfx::Vector2dF& accumulated_overscroll, 316 DidOverscroll,
317 const gfx::Vector2dF& latest_overscroll_delta, 317 void(const gfx::Vector2dF& accumulated_overscroll,
318 const gfx::Vector2dF& current_fling_velocity, 318 const gfx::Vector2dF& latest_overscroll_delta,
319 const gfx::PointF& causal_event_viewport_point)); 319 const gfx::Vector2dF& current_fling_velocity,
320 const gfx::PointF& causal_event_viewport_point,
321 const cc::ScrollBoundaryBehavior& scroll_boundary_behavior));
320 void DidStopFlinging() override {} 322 void DidStopFlinging() override {}
321 void DidAnimateForInput() override {} 323 void DidAnimateForInput() override {}
322 MOCK_METHOD3(SetWhiteListedTouchAction, 324 MOCK_METHOD3(SetWhiteListedTouchAction,
323 void(cc::TouchAction touch_action, 325 void(cc::TouchAction touch_action,
324 uint32_t unique_touch_event_id, 326 uint32_t unique_touch_event_id,
325 InputHandlerProxy::EventDisposition event_disposition)); 327 InputHandlerProxy::EventDisposition event_disposition));
326 328
327 private: 329 private:
328 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); 330 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
329 }; 331 };
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 if (!touchpad_and_wheel_scroll_latching_enabled_) { 2226 if (!touchpad_and_wheel_scroll_latching_enabled_) {
2225 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2227 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2226 .WillOnce(testing::Return(kImplThreadScrollState)); 2228 .WillOnce(testing::Return(kImplThreadScrollState));
2227 } 2229 }
2228 EXPECT_CALL( 2230 EXPECT_CALL(
2229 mock_input_handler_, 2231 mock_input_handler_,
2230 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2232 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
2231 .WillOnce(testing::Return(overscroll)); 2233 .WillOnce(testing::Return(overscroll));
2232 EXPECT_CALL( 2234 EXPECT_CALL(
2233 mock_client_, 2235 mock_client_,
2234 DidOverscroll( 2236 DidOverscroll(overscroll.accumulated_root_overscroll,
2235 overscroll.accumulated_root_overscroll, 2237 overscroll.unused_scroll_delta,
2236 overscroll.unused_scroll_delta, 2238 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
2237 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 2239 testing::_, overscroll.scroll_boundary_behavior));
2238 testing::_));
2239 if (!touchpad_and_wheel_scroll_latching_enabled_) 2240 if (!touchpad_and_wheel_scroll_latching_enabled_)
2240 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2241 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2241 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2242 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2242 time += base::TimeDelta::FromMilliseconds(100); 2243 time += base::TimeDelta::FromMilliseconds(100);
2243 Animate(time); 2244 Animate(time);
2244 VERIFY_AND_RESET_MOCKS(); 2245 VERIFY_AND_RESET_MOCKS();
2245 2246
2246 // The next call to animate will no longer scroll vertically. 2247 // The next call to animate will no longer scroll vertically.
2247 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2248 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2248 EXPECT_CALL(mock_input_handler_, 2249 EXPECT_CALL(mock_input_handler_,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 2390
2390 // The third animate hits the bottom content edge. 2391 // The third animate hits the bottom content edge.
2391 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 2392 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
2392 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); 2393 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100);
2393 EXPECT_CALL( 2394 EXPECT_CALL(
2394 mock_input_handler_, 2395 mock_input_handler_,
2395 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2396 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
2396 .WillOnce(testing::Return(overscroll)); 2397 .WillOnce(testing::Return(overscroll));
2397 EXPECT_CALL( 2398 EXPECT_CALL(
2398 mock_client_, 2399 mock_client_,
2399 DidOverscroll( 2400 DidOverscroll(overscroll.accumulated_root_overscroll,
2400 overscroll.accumulated_root_overscroll, 2401 overscroll.unused_scroll_delta,
2401 overscroll.unused_scroll_delta, 2402 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
2402 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 2403 testing::_, overscroll.scroll_boundary_behavior));
2403 testing::_));
2404 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2404 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2405 time += base::TimeDelta::FromMilliseconds(10); 2405 time += base::TimeDelta::FromMilliseconds(10);
2406 Animate(time); 2406 Animate(time);
2407 VERIFY_AND_RESET_MOCKS(); 2407 VERIFY_AND_RESET_MOCKS();
2408 2408
2409 // The next call to animate will no longer scroll vertically. 2409 // The next call to animate will no longer scroll vertically.
2410 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2410 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2411 EXPECT_CALL( 2411 EXPECT_CALL(
2412 mock_input_handler_, 2412 mock_input_handler_,
2413 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) 2413 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0))))
2414 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2414 .WillOnce(testing::Return(scroll_result_did_scroll_));
2415 time += base::TimeDelta::FromMilliseconds(10); 2415 time += base::TimeDelta::FromMilliseconds(10);
2416 Animate(time); 2416 Animate(time);
2417 VERIFY_AND_RESET_MOCKS(); 2417 VERIFY_AND_RESET_MOCKS();
2418 2418
2419 // The next call will hit the right edge. 2419 // The next call will hit the right edge.
2420 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); 2420 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100);
2421 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); 2421 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0);
2422 EXPECT_CALL( 2422 EXPECT_CALL(
2423 mock_input_handler_, 2423 mock_input_handler_,
2424 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 2424 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
2425 .WillOnce(testing::Return(overscroll)); 2425 .WillOnce(testing::Return(overscroll));
2426 EXPECT_CALL( 2426 EXPECT_CALL(
2427 mock_client_, 2427 mock_client_,
2428 DidOverscroll( 2428 DidOverscroll(overscroll.accumulated_root_overscroll,
2429 overscroll.accumulated_root_overscroll, 2429 overscroll.unused_scroll_delta,
2430 overscroll.unused_scroll_delta, 2430 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
2431 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), 2431 testing::_, overscroll.scroll_boundary_behavior));
2432 testing::_));
2433 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2432 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2434 time += base::TimeDelta::FromMilliseconds(10); 2433 time += base::TimeDelta::FromMilliseconds(10);
2435 Animate(time); 2434 Animate(time);
2436 VERIFY_AND_RESET_MOCKS(); 2435 VERIFY_AND_RESET_MOCKS();
2437 2436
2438 // The next call to animate will no longer scroll horizontally or vertically, 2437 // The next call to animate will no longer scroll horizontally or vertically,
2439 // and the fling should be cancelled. 2438 // and the fling should be cancelled.
2440 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); 2439 EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
2441 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); 2440 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
2442 time += base::TimeDelta::FromMilliseconds(10); 2441 time += base::TimeDelta::FromMilliseconds(10);
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
4164 INSTANTIATE_TEST_CASE_P(AnimateInput, 4163 INSTANTIATE_TEST_CASE_P(AnimateInput,
4165 InputHandlerProxyWithoutWheelScrollLatchingTest, 4164 InputHandlerProxyWithoutWheelScrollLatchingTest,
4166 testing::ValuesIn(test_types)); 4165 testing::ValuesIn(test_types));
4167 4166
4168 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests, 4167 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests,
4169 InputHandlerProxyEventQueueTest, 4168 InputHandlerProxyEventQueueTest,
4170 testing::Bool()); 4169 testing::Bool());
4171 4170
4172 } // namespace test 4171 } // namespace test
4173 } // namespace ui 4172 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698