| OLD | NEW |
| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 std::unique_ptr<blink::WebGestureCurve> CreateFlingAnimationCurve( | 303 std::unique_ptr<blink::WebGestureCurve> CreateFlingAnimationCurve( |
| 304 WebGestureDevice deviceSource, | 304 WebGestureDevice deviceSource, |
| 305 const WebFloatPoint& velocity, | 305 const WebFloatPoint& velocity, |
| 306 const WebSize& cumulative_scroll) override { | 306 const WebSize& cumulative_scroll) override { |
| 307 return base::MakeUnique<FakeWebGestureCurve>( | 307 return base::MakeUnique<FakeWebGestureCurve>( |
| 308 blink::WebFloatSize(velocity.x, velocity.y), | 308 blink::WebFloatSize(velocity.x, velocity.y), |
| 309 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); | 309 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); |
| 310 } | 310 } |
| 311 | 311 |
| 312 MOCK_METHOD4(DidOverscroll, | 312 MOCK_METHOD5( |
| 313 void(const gfx::Vector2dF& accumulated_overscroll, | 313 DidOverscroll, |
| 314 const gfx::Vector2dF& latest_overscroll_delta, | 314 void(const gfx::Vector2dF& accumulated_overscroll, |
| 315 const gfx::Vector2dF& current_fling_velocity, | 315 const gfx::Vector2dF& latest_overscroll_delta, |
| 316 const gfx::PointF& causal_event_viewport_point)); | 316 const gfx::Vector2dF& current_fling_velocity, |
| 317 const gfx::PointF& causal_event_viewport_point, |
| 318 const cc::ScrollBoundaryBehavior& scroll_boundary_behavior)); |
| 317 void DidStopFlinging() override {} | 319 void DidStopFlinging() override {} |
| 318 void DidAnimateForInput() override {} | 320 void DidAnimateForInput() override {} |
| 319 | 321 |
| 320 private: | 322 private: |
| 321 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); | 323 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); |
| 322 }; | 324 }; |
| 323 | 325 |
| 324 class MockInputHandlerProxyClientWithDidAnimateForInput | 326 class MockInputHandlerProxyClientWithDidAnimateForInput |
| 325 : public MockInputHandlerProxyClient { | 327 : public MockInputHandlerProxyClient { |
| 326 public: | 328 public: |
| (...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 if (!touchpad_and_wheel_scroll_latching_enabled_) { | 2194 if (!touchpad_and_wheel_scroll_latching_enabled_) { |
| 2193 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 2195 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 2194 .WillOnce(testing::Return(kImplThreadScrollState)); | 2196 .WillOnce(testing::Return(kImplThreadScrollState)); |
| 2195 } | 2197 } |
| 2196 EXPECT_CALL( | 2198 EXPECT_CALL( |
| 2197 mock_input_handler_, | 2199 mock_input_handler_, |
| 2198 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) | 2200 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) |
| 2199 .WillOnce(testing::Return(overscroll)); | 2201 .WillOnce(testing::Return(overscroll)); |
| 2200 EXPECT_CALL( | 2202 EXPECT_CALL( |
| 2201 mock_client_, | 2203 mock_client_, |
| 2202 DidOverscroll( | 2204 DidOverscroll(overscroll.accumulated_root_overscroll, |
| 2203 overscroll.accumulated_root_overscroll, | 2205 overscroll.unused_scroll_delta, |
| 2204 overscroll.unused_scroll_delta, | 2206 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), |
| 2205 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), | 2207 testing::_, overscroll.scroll_boundary_behavior)); |
| 2206 testing::_)); | |
| 2207 if (!touchpad_and_wheel_scroll_latching_enabled_) | 2208 if (!touchpad_and_wheel_scroll_latching_enabled_) |
| 2208 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 2209 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
| 2209 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 2210 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 2210 time += base::TimeDelta::FromMilliseconds(100); | 2211 time += base::TimeDelta::FromMilliseconds(100); |
| 2211 Animate(time); | 2212 Animate(time); |
| 2212 VERIFY_AND_RESET_MOCKS(); | 2213 VERIFY_AND_RESET_MOCKS(); |
| 2213 | 2214 |
| 2214 // The next call to animate will no longer scroll vertically. | 2215 // The next call to animate will no longer scroll vertically. |
| 2215 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 2216 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 2216 EXPECT_CALL(mock_input_handler_, | 2217 EXPECT_CALL(mock_input_handler_, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 | 2358 |
| 2358 // The third animate hits the bottom content edge. | 2359 // The third animate hits the bottom content edge. |
| 2359 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); | 2360 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); |
| 2360 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); | 2361 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); |
| 2361 EXPECT_CALL( | 2362 EXPECT_CALL( |
| 2362 mock_input_handler_, | 2363 mock_input_handler_, |
| 2363 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) | 2364 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) |
| 2364 .WillOnce(testing::Return(overscroll)); | 2365 .WillOnce(testing::Return(overscroll)); |
| 2365 EXPECT_CALL( | 2366 EXPECT_CALL( |
| 2366 mock_client_, | 2367 mock_client_, |
| 2367 DidOverscroll( | 2368 DidOverscroll(overscroll.accumulated_root_overscroll, |
| 2368 overscroll.accumulated_root_overscroll, | 2369 overscroll.unused_scroll_delta, |
| 2369 overscroll.unused_scroll_delta, | 2370 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), |
| 2370 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), | 2371 testing::_, overscroll.scroll_boundary_behavior)); |
| 2371 testing::_)); | |
| 2372 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 2372 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 2373 time += base::TimeDelta::FromMilliseconds(10); | 2373 time += base::TimeDelta::FromMilliseconds(10); |
| 2374 Animate(time); | 2374 Animate(time); |
| 2375 VERIFY_AND_RESET_MOCKS(); | 2375 VERIFY_AND_RESET_MOCKS(); |
| 2376 | 2376 |
| 2377 // The next call to animate will no longer scroll vertically. | 2377 // The next call to animate will no longer scroll vertically. |
| 2378 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 2378 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
| 2379 EXPECT_CALL( | 2379 EXPECT_CALL( |
| 2380 mock_input_handler_, | 2380 mock_input_handler_, |
| 2381 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) | 2381 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) |
| 2382 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 2382 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
| 2383 time += base::TimeDelta::FromMilliseconds(10); | 2383 time += base::TimeDelta::FromMilliseconds(10); |
| 2384 Animate(time); | 2384 Animate(time); |
| 2385 VERIFY_AND_RESET_MOCKS(); | 2385 VERIFY_AND_RESET_MOCKS(); |
| 2386 | 2386 |
| 2387 // The next call will hit the right edge. | 2387 // The next call will hit the right edge. |
| 2388 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); | 2388 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); |
| 2389 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); | 2389 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); |
| 2390 EXPECT_CALL( | 2390 EXPECT_CALL( |
| 2391 mock_input_handler_, | 2391 mock_input_handler_, |
| 2392 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) | 2392 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) |
| 2393 .WillOnce(testing::Return(overscroll)); | 2393 .WillOnce(testing::Return(overscroll)); |
| 2394 EXPECT_CALL( | 2394 EXPECT_CALL( |
| 2395 mock_client_, | 2395 mock_client_, |
| 2396 DidOverscroll( | 2396 DidOverscroll(overscroll.accumulated_root_overscroll, |
| 2397 overscroll.accumulated_root_overscroll, | 2397 overscroll.unused_scroll_delta, |
| 2398 overscroll.unused_scroll_delta, | 2398 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), |
| 2399 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), | 2399 testing::_, overscroll.scroll_boundary_behavior)); |
| 2400 testing::_)); | |
| 2401 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | 2400 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
| 2402 time += base::TimeDelta::FromMilliseconds(10); | 2401 time += base::TimeDelta::FromMilliseconds(10); |
| 2403 Animate(time); | 2402 Animate(time); |
| 2404 VERIFY_AND_RESET_MOCKS(); | 2403 VERIFY_AND_RESET_MOCKS(); |
| 2405 | 2404 |
| 2406 // The next call to animate will no longer scroll horizontally or vertically, | 2405 // The next call to animate will no longer scroll horizontally or vertically, |
| 2407 // and the fling should be cancelled. | 2406 // and the fling should be cancelled. |
| 2408 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); | 2407 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); |
| 2409 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); | 2408 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); |
| 2410 time += base::TimeDelta::FromMilliseconds(10); | 2409 time += base::TimeDelta::FromMilliseconds(10); |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3910 INSTANTIATE_TEST_CASE_P(AnimateInput, | 3909 INSTANTIATE_TEST_CASE_P(AnimateInput, |
| 3911 InputHandlerProxyWithoutWheelScrollLatchingTest, | 3910 InputHandlerProxyWithoutWheelScrollLatchingTest, |
| 3912 testing::ValuesIn(test_types)); | 3911 testing::ValuesIn(test_types)); |
| 3913 | 3912 |
| 3914 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests, | 3913 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests, |
| 3915 InputHandlerProxyEventQueueTest, | 3914 InputHandlerProxyEventQueueTest, |
| 3916 testing::Bool()); | 3915 testing::Bool()); |
| 3917 | 3916 |
| 3918 } // namespace test | 3917 } // namespace test |
| 3919 } // namespace ui | 3918 } // namespace ui |
| OLD | NEW |