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

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: rebase Created 3 years, 5 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_METHOD1(SetWhiteListedTouchAction, void(cc::TouchAction touch_action)); 324 MOCK_METHOD1(SetWhiteListedTouchAction, void(cc::TouchAction touch_action));
323 325
324 private: 326 private:
325 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); 327 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
326 }; 328 };
327 329
328 class MockInputHandlerProxyClientWithDidAnimateForInput 330 class MockInputHandlerProxyClientWithDidAnimateForInput
329 : public MockInputHandlerProxyClient { 331 : public MockInputHandlerProxyClient {
(...skipping 1888 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 if (!touchpad_and_wheel_scroll_latching_enabled_) { 2220 if (!touchpad_and_wheel_scroll_latching_enabled_) {
2219 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2221 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2220 .WillOnce(testing::Return(kImplThreadScrollState)); 2222 .WillOnce(testing::Return(kImplThreadScrollState));
2221 } 2223 }
2222 EXPECT_CALL( 2224 EXPECT_CALL(
2223 mock_input_handler_, 2225 mock_input_handler_,
2224 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2226 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
2225 .WillOnce(testing::Return(overscroll)); 2227 .WillOnce(testing::Return(overscroll));
2226 EXPECT_CALL( 2228 EXPECT_CALL(
2227 mock_client_, 2229 mock_client_,
2228 DidOverscroll( 2230 DidOverscroll(overscroll.accumulated_root_overscroll,
2229 overscroll.accumulated_root_overscroll, 2231 overscroll.unused_scroll_delta,
2230 overscroll.unused_scroll_delta, 2232 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
2231 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 2233 testing::_, overscroll.scroll_boundary_behavior));
2232 testing::_));
2233 if (!touchpad_and_wheel_scroll_latching_enabled_) 2234 if (!touchpad_and_wheel_scroll_latching_enabled_)
2234 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2235 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2235 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2236 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2236 time += base::TimeDelta::FromMilliseconds(100); 2237 time += base::TimeDelta::FromMilliseconds(100);
2237 Animate(time); 2238 Animate(time);
2238 VERIFY_AND_RESET_MOCKS(); 2239 VERIFY_AND_RESET_MOCKS();
2239 2240
2240 // The next call to animate will no longer scroll vertically. 2241 // The next call to animate will no longer scroll vertically.
2241 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2242 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2242 EXPECT_CALL(mock_input_handler_, 2243 EXPECT_CALL(mock_input_handler_,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 2384
2384 // The third animate hits the bottom content edge. 2385 // The third animate hits the bottom content edge.
2385 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 2386 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
2386 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); 2387 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100);
2387 EXPECT_CALL( 2388 EXPECT_CALL(
2388 mock_input_handler_, 2389 mock_input_handler_,
2389 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2390 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
2390 .WillOnce(testing::Return(overscroll)); 2391 .WillOnce(testing::Return(overscroll));
2391 EXPECT_CALL( 2392 EXPECT_CALL(
2392 mock_client_, 2393 mock_client_,
2393 DidOverscroll( 2394 DidOverscroll(overscroll.accumulated_root_overscroll,
2394 overscroll.accumulated_root_overscroll, 2395 overscroll.unused_scroll_delta,
2395 overscroll.unused_scroll_delta, 2396 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
2396 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 2397 testing::_, overscroll.scroll_boundary_behavior));
2397 testing::_));
2398 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2398 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2399 time += base::TimeDelta::FromMilliseconds(10); 2399 time += base::TimeDelta::FromMilliseconds(10);
2400 Animate(time); 2400 Animate(time);
2401 VERIFY_AND_RESET_MOCKS(); 2401 VERIFY_AND_RESET_MOCKS();
2402 2402
2403 // The next call to animate will no longer scroll vertically. 2403 // The next call to animate will no longer scroll vertically.
2404 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2404 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2405 EXPECT_CALL( 2405 EXPECT_CALL(
2406 mock_input_handler_, 2406 mock_input_handler_,
2407 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) 2407 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0))))
2408 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2408 .WillOnce(testing::Return(scroll_result_did_scroll_));
2409 time += base::TimeDelta::FromMilliseconds(10); 2409 time += base::TimeDelta::FromMilliseconds(10);
2410 Animate(time); 2410 Animate(time);
2411 VERIFY_AND_RESET_MOCKS(); 2411 VERIFY_AND_RESET_MOCKS();
2412 2412
2413 // The next call will hit the right edge. 2413 // The next call will hit the right edge.
2414 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); 2414 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100);
2415 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); 2415 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0);
2416 EXPECT_CALL( 2416 EXPECT_CALL(
2417 mock_input_handler_, 2417 mock_input_handler_,
2418 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 2418 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
2419 .WillOnce(testing::Return(overscroll)); 2419 .WillOnce(testing::Return(overscroll));
2420 EXPECT_CALL( 2420 EXPECT_CALL(
2421 mock_client_, 2421 mock_client_,
2422 DidOverscroll( 2422 DidOverscroll(overscroll.accumulated_root_overscroll,
2423 overscroll.accumulated_root_overscroll, 2423 overscroll.unused_scroll_delta,
2424 overscroll.unused_scroll_delta, 2424 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
2425 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), 2425 testing::_, overscroll.scroll_boundary_behavior));
2426 testing::_));
2427 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2426 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2428 time += base::TimeDelta::FromMilliseconds(10); 2427 time += base::TimeDelta::FromMilliseconds(10);
2429 Animate(time); 2428 Animate(time);
2430 VERIFY_AND_RESET_MOCKS(); 2429 VERIFY_AND_RESET_MOCKS();
2431 2430
2432 // The next call to animate will no longer scroll horizontally or vertically, 2431 // The next call to animate will no longer scroll horizontally or vertically,
2433 // and the fling should be cancelled. 2432 // and the fling should be cancelled.
2434 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); 2433 EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
2435 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); 2434 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
2436 time += base::TimeDelta::FromMilliseconds(10); 2435 time += base::TimeDelta::FromMilliseconds(10);
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after
4110 INSTANTIATE_TEST_CASE_P(AnimateInput, 4109 INSTANTIATE_TEST_CASE_P(AnimateInput,
4111 InputHandlerProxyWithoutWheelScrollLatchingTest, 4110 InputHandlerProxyWithoutWheelScrollLatchingTest,
4112 testing::ValuesIn(test_types)); 4111 testing::ValuesIn(test_types));
4113 4112
4114 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests, 4113 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests,
4115 InputHandlerProxyEventQueueTest, 4114 InputHandlerProxyEventQueueTest,
4116 testing::Bool()); 4115 testing::Bool());
4117 4116
4118 } // namespace test 4117 } // namespace test
4119 } // namespace ui 4118 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698