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 "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 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 EXPECT_CALL(mock_input_handler_, | 1849 EXPECT_CALL(mock_input_handler_, |
1850 ScrollBy(testing::_, | 1850 ScrollBy(testing::_, |
1851 testing::Property(&gfx::Vector2dF::x, | 1851 testing::Property(&gfx::Vector2dF::x, |
1852 testing::Eq(expected_delta)))) | 1852 testing::Eq(expected_delta)))) |
1853 .WillOnce(testing::Return(true)); | 1853 .WillOnce(testing::Return(true)); |
1854 input_handler_->Animate(time); | 1854 input_handler_->Animate(time); |
1855 | 1855 |
1856 VERIFY_AND_RESET_MOCKS(); | 1856 VERIFY_AND_RESET_MOCKS(); |
1857 } | 1857 } |
1858 | 1858 |
| 1859 TEST_F(InputHandlerProxyTest, FlingBoostTerminatedDuringScrollSequence) { |
| 1860 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); |
| 1861 base::TimeTicks time = base::TimeTicks() + dt; |
| 1862 base::TimeTicks last_animate_time = time; |
| 1863 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
| 1864 WebPoint fling_point = WebPoint(7, 13); |
| 1865 StartFling( |
| 1866 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point); |
| 1867 |
| 1868 // Now cancel the fling. The fling cancellation should be deferred to allow |
| 1869 // fling boosting events to arrive. |
| 1870 time += dt; |
| 1871 CancelFling(time); |
| 1872 |
| 1873 // The GestureScrollBegin should be swallowed by the fling. |
| 1874 time += dt; |
| 1875 gesture_.timeStampSeconds = InSecondsF(time); |
| 1876 gesture_.type = WebInputEvent::GestureScrollBegin; |
| 1877 EXPECT_CALL(mock_input_handler_, |
| 1878 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) |
| 1879 .WillOnce(testing::Return(true)); |
| 1880 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1881 |
| 1882 VERIFY_AND_RESET_MOCKS(); |
| 1883 |
| 1884 // Now animate the fling to completion (in this case, the fling should |
| 1885 // terminate because the input handler reports a failed scroll). As the fling |
| 1886 // was cancelled during an active scroll sequence, a synthetic |
| 1887 // GestureScrollBegin should be processed, resuming the scroll. |
| 1888 time += dt; |
| 1889 float expected_delta = |
| 1890 (time - last_animate_time).InSecondsF() * -fling_delta.x; |
| 1891 EXPECT_CALL(mock_input_handler_, |
| 1892 ScrollBy(testing::_, |
| 1893 testing::Property(&gfx::Vector2dF::x, |
| 1894 testing::Eq(expected_delta)))) |
| 1895 .WillOnce(testing::Return(false)); |
| 1896 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1897 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1898 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1899 input_handler_->Animate(time); |
| 1900 |
| 1901 VERIFY_AND_RESET_MOCKS(); |
| 1902 |
| 1903 // Subsequent GestureScrollUpdates after the cancelled, boosted fling should |
| 1904 // cause scrolling as usual. |
| 1905 time += dt; |
| 1906 expected_delta = 7.3f; |
| 1907 gesture_.timeStampSeconds = InSecondsF(time); |
| 1908 gesture_.type = WebInputEvent::GestureScrollUpdate; |
| 1909 gesture_.data.scrollUpdate.deltaX = -expected_delta; |
| 1910 EXPECT_CALL(mock_input_handler_, |
| 1911 ScrollBy(testing::_, |
| 1912 testing::Property(&gfx::Vector2dF::x, |
| 1913 testing::Eq(expected_delta)))) |
| 1914 .WillOnce(testing::Return(true)); |
| 1915 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1916 |
| 1917 VERIFY_AND_RESET_MOCKS(); |
| 1918 |
| 1919 // GestureScrollEnd should terminate the resumed scroll properly. |
| 1920 time += dt; |
| 1921 gesture_.timeStampSeconds = InSecondsF(time); |
| 1922 gesture_.type = WebInputEvent::GestureScrollEnd; |
| 1923 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1924 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 1925 |
| 1926 VERIFY_AND_RESET_MOCKS(); |
| 1927 } |
| 1928 |
1859 } // namespace | 1929 } // namespace |
1860 } // namespace content | 1930 } // namespace content |
OLD | NEW |