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

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, 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/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 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 if (!touchpad_and_wheel_scroll_latching_enabled_) { 2234 if (!touchpad_and_wheel_scroll_latching_enabled_) {
2233 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 2235 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
2234 .WillOnce(testing::Return(kImplThreadScrollState)); 2236 .WillOnce(testing::Return(kImplThreadScrollState));
2235 } 2237 }
2236 EXPECT_CALL( 2238 EXPECT_CALL(
2237 mock_input_handler_, 2239 mock_input_handler_,
2238 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2240 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
2239 .WillOnce(testing::Return(overscroll)); 2241 .WillOnce(testing::Return(overscroll));
2240 EXPECT_CALL( 2242 EXPECT_CALL(
2241 mock_client_, 2243 mock_client_,
2242 DidOverscroll( 2244 DidOverscroll(overscroll.accumulated_root_overscroll,
2243 overscroll.accumulated_root_overscroll, 2245 overscroll.unused_scroll_delta,
2244 overscroll.unused_scroll_delta, 2246 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
2245 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 2247 testing::_, overscroll.scroll_boundary_behavior));
2246 testing::_));
2247 if (!touchpad_and_wheel_scroll_latching_enabled_) 2248 if (!touchpad_and_wheel_scroll_latching_enabled_)
2248 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2249 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2249 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2250 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2250 time += base::TimeDelta::FromMilliseconds(100); 2251 time += base::TimeDelta::FromMilliseconds(100);
2251 Animate(time); 2252 Animate(time);
2252 VERIFY_AND_RESET_MOCKS(); 2253 VERIFY_AND_RESET_MOCKS();
2253 2254
2254 // The next call to animate will no longer scroll vertically. 2255 // The next call to animate will no longer scroll vertically.
2255 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2256 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2256 EXPECT_CALL(mock_input_handler_, 2257 EXPECT_CALL(mock_input_handler_,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 2398
2398 // The third animate hits the bottom content edge. 2399 // The third animate hits the bottom content edge.
2399 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 2400 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
2400 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); 2401 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100);
2401 EXPECT_CALL( 2402 EXPECT_CALL(
2402 mock_input_handler_, 2403 mock_input_handler_,
2403 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 2404 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
2404 .WillOnce(testing::Return(overscroll)); 2405 .WillOnce(testing::Return(overscroll));
2405 EXPECT_CALL( 2406 EXPECT_CALL(
2406 mock_client_, 2407 mock_client_,
2407 DidOverscroll( 2408 DidOverscroll(overscroll.accumulated_root_overscroll,
2408 overscroll.accumulated_root_overscroll, 2409 overscroll.unused_scroll_delta,
2409 overscroll.unused_scroll_delta, 2410 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
2410 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 2411 testing::_, overscroll.scroll_boundary_behavior));
2411 testing::_));
2412 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2412 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2413 time += base::TimeDelta::FromMilliseconds(10); 2413 time += base::TimeDelta::FromMilliseconds(10);
2414 Animate(time); 2414 Animate(time);
2415 VERIFY_AND_RESET_MOCKS(); 2415 VERIFY_AND_RESET_MOCKS();
2416 2416
2417 // The next call to animate will no longer scroll vertically. 2417 // The next call to animate will no longer scroll vertically.
2418 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 2418 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
2419 EXPECT_CALL( 2419 EXPECT_CALL(
2420 mock_input_handler_, 2420 mock_input_handler_,
2421 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) 2421 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0))))
2422 .WillOnce(testing::Return(scroll_result_did_scroll_)); 2422 .WillOnce(testing::Return(scroll_result_did_scroll_));
2423 time += base::TimeDelta::FromMilliseconds(10); 2423 time += base::TimeDelta::FromMilliseconds(10);
2424 Animate(time); 2424 Animate(time);
2425 VERIFY_AND_RESET_MOCKS(); 2425 VERIFY_AND_RESET_MOCKS();
2426 2426
2427 // The next call will hit the right edge. 2427 // The next call will hit the right edge.
2428 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); 2428 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100);
2429 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); 2429 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0);
2430 EXPECT_CALL( 2430 EXPECT_CALL(
2431 mock_input_handler_, 2431 mock_input_handler_,
2432 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 2432 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
2433 .WillOnce(testing::Return(overscroll)); 2433 .WillOnce(testing::Return(overscroll));
2434 EXPECT_CALL( 2434 EXPECT_CALL(
2435 mock_client_, 2435 mock_client_,
2436 DidOverscroll( 2436 DidOverscroll(overscroll.accumulated_root_overscroll,
2437 overscroll.accumulated_root_overscroll, 2437 overscroll.unused_scroll_delta,
2438 overscroll.unused_scroll_delta, 2438 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
2439 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), 2439 testing::_, overscroll.scroll_boundary_behavior));
2440 testing::_));
2441 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 2440 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
2442 time += base::TimeDelta::FromMilliseconds(10); 2441 time += base::TimeDelta::FromMilliseconds(10);
2443 Animate(time); 2442 Animate(time);
2444 VERIFY_AND_RESET_MOCKS(); 2443 VERIFY_AND_RESET_MOCKS();
2445 2444
2446 // The next call to animate will no longer scroll horizontally or vertically, 2445 // The next call to animate will no longer scroll horizontally or vertically,
2447 // and the fling should be cancelled. 2446 // and the fling should be cancelled.
2448 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); 2447 EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
2449 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); 2448 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
2450 time += base::TimeDelta::FromMilliseconds(10); 2449 time += base::TimeDelta::FromMilliseconds(10);
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
4172 INSTANTIATE_TEST_CASE_P(AnimateInput, 4171 INSTANTIATE_TEST_CASE_P(AnimateInput,
4173 InputHandlerProxyWithoutWheelScrollLatchingTest, 4172 InputHandlerProxyWithoutWheelScrollLatchingTest,
4174 testing::ValuesIn(test_types)); 4173 testing::ValuesIn(test_types));
4175 4174
4176 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests, 4175 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests,
4177 InputHandlerProxyEventQueueTest, 4176 InputHandlerProxyEventQueueTest,
4178 testing::Bool()); 4177 testing::Bool());
4179 4178
4180 } // namespace test 4179 } // namespace test
4181 } // namespace ui 4180 } // 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