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

Side by Side Diff: content/renderer/input/input_handler_proxy_unittest.cc

Issue 367173003: [Android] Implementation of overscroll effect for Android L (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 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 "content/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/base/swap_promise_monitor.h" 9 #include "cc/base/swap_promise_monitor.h"
10 #include "content/common/input/did_overscroll_params.h" 10 #include "content/common/input/did_overscroll_params.h"
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1201 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1202 .WillOnce(testing::Return(true)); 1202 .WillOnce(testing::Return(true));
1203 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1203 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1204 time += base::TimeDelta::FromMilliseconds(100); 1204 time += base::TimeDelta::FromMilliseconds(100);
1205 input_handler_->Animate(time); 1205 input_handler_->Animate(time);
1206 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1206 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1207 1207
1208 // Simulate hitting the bottom content edge. 1208 // Simulate hitting the bottom content edge.
1209 gfx::Vector2dF accumulated_overscroll(0, 100); 1209 gfx::Vector2dF accumulated_overscroll(0, 100);
1210 gfx::Vector2dF latest_overscroll_delta(0, 10); 1210 gfx::Vector2dF latest_overscroll_delta(0, 10);
1211 EXPECT_CALL(mock_client_, 1211 gfx::PointF scroll_point(10, 0);
1212 DidOverscroll(testing::AllOf( 1212 EXPECT_CALL(
1213 testing::Field(&DidOverscrollParams::accumulated_overscroll, 1213 mock_client_,
1214 testing::Eq(accumulated_overscroll)), 1214 DidOverscroll(testing::AllOf(
1215 testing::Field(&DidOverscrollParams::latest_overscroll_delta, 1215 testing::Field(&DidOverscrollParams::accumulated_overscroll,
1216 testing::Eq(latest_overscroll_delta)), 1216 testing::Eq(accumulated_overscroll)),
1217 testing::Field( 1217 testing::Field(&DidOverscrollParams::latest_overscroll_delta,
1218 &DidOverscrollParams::current_fling_velocity, 1218 testing::Eq(latest_overscroll_delta)),
1219 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1219 testing::Field(&DidOverscrollParams::current_fling_velocity,
1220 input_handler_->DidOverscroll(accumulated_overscroll, 1220 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))),
1221 latest_overscroll_delta); 1221 testing::Field(&DidOverscrollParams::causal_event_viewport_point,
1222 testing::Eq(scroll_point)))));
1223 input_handler_->DidOverscroll(
1224 scroll_point, accumulated_overscroll, latest_overscroll_delta);
1222 1225
1223 // The next call to animate will no longer scroll vertically. 1226 // The next call to animate will no longer scroll vertically.
1224 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1227 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1225 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1228 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1226 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1229 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1227 EXPECT_CALL(mock_input_handler_, 1230 EXPECT_CALL(mock_input_handler_,
1228 ScrollBy(testing::_, 1231 ScrollBy(testing::_,
1229 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1232 testing::Property(&gfx::Vector2dF::y, testing::Eq(0))))
1230 .WillOnce(testing::Return(true)); 1233 .WillOnce(testing::Return(true));
1231 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1234 EXPECT_CALL(mock_input_handler_, ScrollEnd());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 ScrollBy(testing::_, 1350 ScrollBy(testing::_,
1348 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) 1351 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1349 .WillOnce(testing::Return(true)); 1352 .WillOnce(testing::Return(true));
1350 time += base::TimeDelta::FromMilliseconds(10); 1353 time += base::TimeDelta::FromMilliseconds(10);
1351 input_handler_->Animate(time); 1354 input_handler_->Animate(time);
1352 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1355 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1353 1356
1354 // Simulate hitting the bottom content edge. 1357 // Simulate hitting the bottom content edge.
1355 gfx::Vector2dF accumulated_overscroll(0, 100); 1358 gfx::Vector2dF accumulated_overscroll(0, 100);
1356 gfx::Vector2dF latest_overscroll_delta(0, 100); 1359 gfx::Vector2dF latest_overscroll_delta(0, 100);
1357 EXPECT_CALL(mock_client_, 1360 gfx::PointF scroll_point(10, -50);
1358 DidOverscroll(testing::AllOf( 1361 EXPECT_CALL(
1359 testing::Field(&DidOverscrollParams::accumulated_overscroll, 1362 mock_client_,
1360 testing::Eq(accumulated_overscroll)), 1363 DidOverscroll(testing::AllOf(
1361 testing::Field(&DidOverscrollParams::latest_overscroll_delta, 1364 testing::Field(&DidOverscrollParams::accumulated_overscroll,
1362 testing::Eq(latest_overscroll_delta)), 1365 testing::Eq(accumulated_overscroll)),
1363 testing::Field( 1366 testing::Field(&DidOverscrollParams::latest_overscroll_delta,
1364 &DidOverscrollParams::current_fling_velocity, 1367 testing::Eq(latest_overscroll_delta)),
1365 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); 1368 testing::Field(&DidOverscrollParams::current_fling_velocity,
1366 input_handler_->DidOverscroll(accumulated_overscroll, 1369 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))),
1367 latest_overscroll_delta); 1370 testing::Field(&DidOverscrollParams::causal_event_viewport_point,
1371 testing::Eq(scroll_point)))));
1372 input_handler_->DidOverscroll(
1373 scroll_point, accumulated_overscroll, latest_overscroll_delta);
1368 1374
1369 // The next call to animate will no longer scroll vertically. 1375 // The next call to animate will no longer scroll vertically.
1370 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1376 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1371 EXPECT_CALL(mock_input_handler_, 1377 EXPECT_CALL(mock_input_handler_,
1372 ScrollBy(testing::_, 1378 ScrollBy(testing::_,
1373 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) 1379 testing::Property(&gfx::Vector2dF::y, testing::Eq(0))))
1374 .WillOnce(testing::Return(true)); 1380 .WillOnce(testing::Return(true));
1375 time += base::TimeDelta::FromMilliseconds(10); 1381 time += base::TimeDelta::FromMilliseconds(10);
1376 input_handler_->Animate(time); 1382 input_handler_->Animate(time);
1377 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1383 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1378 1384
1379 // Simulate hitting the right content edge. 1385 // Simulate hitting the right content edge.
1380 accumulated_overscroll = gfx::Vector2dF(100, 100); 1386 accumulated_overscroll = gfx::Vector2dF(100, 100);
1381 latest_overscroll_delta = gfx::Vector2dF(100, 0); 1387 latest_overscroll_delta = gfx::Vector2dF(100, 0);
1382 EXPECT_CALL(mock_client_, 1388 scroll_point = gfx::PointF(50, 0);
1383 DidOverscroll(testing::AllOf( 1389 EXPECT_CALL(
1384 testing::Field(&DidOverscrollParams::accumulated_overscroll, 1390 mock_client_,
1385 testing::Eq(accumulated_overscroll)), 1391 DidOverscroll(testing::AllOf(
1386 testing::Field(&DidOverscrollParams::latest_overscroll_delta, 1392 testing::Field(&DidOverscrollParams::accumulated_overscroll,
1387 testing::Eq(latest_overscroll_delta)), 1393 testing::Eq(accumulated_overscroll)),
1388 testing::Field( 1394 testing::Field(&DidOverscrollParams::latest_overscroll_delta,
1389 &DidOverscrollParams::current_fling_velocity, 1395 testing::Eq(latest_overscroll_delta)),
1390 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); 1396 testing::Field(&DidOverscrollParams::current_fling_velocity,
1391 input_handler_->DidOverscroll(accumulated_overscroll, 1397 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))),
1392 latest_overscroll_delta); 1398 testing::Field(&DidOverscrollParams::causal_event_viewport_point,
1399 testing::Eq(scroll_point)))));
1400 input_handler_->DidOverscroll(
1401 scroll_point, accumulated_overscroll, latest_overscroll_delta);
1393 // The next call to animate will no longer scroll horizontally or vertically, 1402 // The next call to animate will no longer scroll horizontally or vertically,
1394 // and the fling should be cancelled. 1403 // and the fling should be cancelled.
1395 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0); 1404 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()).Times(0);
1396 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); 1405 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0);
1397 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1406 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1398 time += base::TimeDelta::FromMilliseconds(10); 1407 time += base::TimeDelta::FromMilliseconds(10);
1399 input_handler_->Animate(time); 1408 input_handler_->Animate(time);
1400 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1409 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1401 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1410 EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1402 } 1411 }
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 testing::Property(&gfx::Vector2dF::x, 1860 testing::Property(&gfx::Vector2dF::x,
1852 testing::Eq(expected_delta)))) 1861 testing::Eq(expected_delta))))
1853 .WillOnce(testing::Return(true)); 1862 .WillOnce(testing::Return(true));
1854 input_handler_->Animate(time); 1863 input_handler_->Animate(time);
1855 1864
1856 VERIFY_AND_RESET_MOCKS(); 1865 VERIFY_AND_RESET_MOCKS();
1857 } 1866 }
1858 1867
1859 } // namespace 1868 } // namespace
1860 } // namespace content 1869 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | ui/base/android/system_ui_resource_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698