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

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

Issue 602873002: Prevent orthogonal fling accumulation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cleanup Created 6 years, 2 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 | « content/renderer/input/input_handler_proxy.cc ('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 "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 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 // timeout window, the fling should be cancelled and scrolling should resume. 1786 // timeout window, the fling should be cancelled and scrolling should resume.
1787 time += base::TimeDelta::FromMilliseconds(100); 1787 time += base::TimeDelta::FromMilliseconds(100);
1788 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1788 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1789 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1789 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1790 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1790 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1791 input_handler_->Animate(time); 1791 input_handler_->Animate(time);
1792 1792
1793 VERIFY_AND_RESET_MOCKS(); 1793 VERIFY_AND_RESET_MOCKS();
1794 } 1794 }
1795 1795
1796 TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingInDifferentDirection) {
1797 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1798 base::TimeTicks time = base::TimeTicks() + dt;
1799 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1800 WebPoint fling_point = WebPoint(7, 13);
1801 StartFling(
1802 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
1803
1804 // Cancel the fling. The fling cancellation should be deferred to allow
1805 // fling boosting events to arrive.
1806 time += dt;
1807 CancelFling(time);
1808
1809 // If the new fling is orthogonal to the existing fling, no boosting should
1810 // take place, with the new fling replacing the old.
1811 WebFloatPoint orthogonal_fling_delta =
1812 WebFloatPoint(fling_delta.y, -fling_delta.x);
1813 gesture_ = CreateFling(time,
1814 blink::WebGestureDeviceTouchscreen,
1815 orthogonal_fling_delta,
1816 fling_point,
1817 fling_point,
1818 0);
1819 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1820
1821 VERIFY_AND_RESET_MOCKS();
1822
1823 // Note that the new fling delta uses the orthogonal, unboosted fling
1824 // velocity.
1825 time += dt;
1826 float expected_delta = dt.InSecondsF() * -orthogonal_fling_delta.y;
1827 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1828 EXPECT_CALL(mock_input_handler_,
1829 ScrollBy(testing::_,
1830 testing::Property(&gfx::Vector2dF::y,
1831 testing::Eq(expected_delta))))
1832 .WillOnce(testing::Return(true));
1833 input_handler_->Animate(time);
1834
1835 VERIFY_AND_RESET_MOCKS();
1836 }
1837
1796 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) { 1838 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) {
1797 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1839 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1798 base::TimeTicks time = base::TimeTicks() + dt; 1840 base::TimeTicks time = base::TimeTicks() + dt;
1799 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1841 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1800 WebPoint fling_point = WebPoint(7, 13); 1842 WebPoint fling_point = WebPoint(7, 13);
1801 StartFling( 1843 StartFling(
1802 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); 1844 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
1803 1845
1804 // Cancel the fling. The fling cancellation should be deferred to allow 1846 // Cancel the fling. The fling cancellation should be deferred to allow
1805 // fling boosting events to arrive. 1847 // fling boosting events to arrive.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 wheel.scrollByPage = true; 2002 wheel.scrollByPage = true;
1961 2003
1962 EXPECT_CALL(mock_client, DidReceiveInputEvent()); 2004 EXPECT_CALL(mock_client, DidReceiveInputEvent());
1963 2005
1964 input_handler_->HandleInputEvent(wheel); 2006 input_handler_->HandleInputEvent(wheel);
1965 testing::Mock::VerifyAndClearExpectations(&mock_client); 2007 testing::Mock::VerifyAndClearExpectations(&mock_client);
1966 } 2008 }
1967 2009
1968 } // namespace 2010 } // namespace
1969 } // namespace content 2011 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698