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

Side by Side Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2265393002: Refactor compositor event handling path to be callback-based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 "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/macros.h" 9 #include "base/macros.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 blink::WebGestureCurve* CreateFlingAnimationCurve( 217 blink::WebGestureCurve* CreateFlingAnimationCurve(
218 WebGestureDevice deviceSource, 218 WebGestureDevice deviceSource,
219 const WebFloatPoint& velocity, 219 const WebFloatPoint& velocity,
220 const WebSize& cumulative_scroll) override { 220 const WebSize& cumulative_scroll) override {
221 return new FakeWebGestureCurve( 221 return new FakeWebGestureCurve(
222 blink::WebFloatSize(velocity.x, velocity.y), 222 blink::WebFloatSize(velocity.x, velocity.y),
223 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); 223 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
224 } 224 }
225 225
226 MOCK_METHOD4(DidOverscroll, 226 MOCK_METHOD5(DidOverscroll,
227 void(const gfx::Vector2dF& accumulated_overscroll, 227 void(const gfx::Vector2dF& accumulated_overscroll,
228 const gfx::Vector2dF& latest_overscroll_delta, 228 const gfx::Vector2dF& latest_overscroll_delta,
229 const gfx::Vector2dF& current_fling_velocity, 229 const gfx::Vector2dF& current_fling_velocity,
230 const gfx::PointF& causal_event_viewport_point)); 230 const gfx::PointF& causal_event_viewport_point,
231 bool bundle_ack_with_triggering_event));
231 void DidStartFlinging() override {} 232 void DidStartFlinging() override {}
232 void DidStopFlinging() override {} 233 void DidStopFlinging() override {}
233 void DidAnimateForInput() override {} 234 void DidAnimateForInput() override {}
234 235
235 private: 236 private:
236 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); 237 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
237 }; 238 };
238 239
239 class MockInputHandlerProxyClientWithDidAnimateForInput 240 class MockInputHandlerProxyClientWithDidAnimateForInput
240 : public MockInputHandlerProxyClient { 241 : public MockInputHandlerProxyClient {
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1701 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
1701 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); 1702 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
1702 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1703 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1703 .WillOnce(testing::Return(kImplThreadScrollState)); 1704 .WillOnce(testing::Return(kImplThreadScrollState));
1704 EXPECT_CALL( 1705 EXPECT_CALL(
1705 mock_input_handler_, 1706 mock_input_handler_,
1706 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 1707 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
1707 .WillOnce(testing::Return(overscroll)); 1708 .WillOnce(testing::Return(overscroll));
1708 EXPECT_CALL( 1709 EXPECT_CALL(
1709 mock_client_, 1710 mock_client_,
1710 DidOverscroll( 1711 DidOverscroll(overscroll.accumulated_root_overscroll,
1711 overscroll.accumulated_root_overscroll, 1712 overscroll.unused_scroll_delta,
1712 overscroll.unused_scroll_delta, 1713 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
1713 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 1714 testing::_, testing::_));
1714 testing::_));
1715 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1715 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1716 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1716 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1717 time += base::TimeDelta::FromMilliseconds(100); 1717 time += base::TimeDelta::FromMilliseconds(100);
1718 Animate(time); 1718 Animate(time);
1719 VERIFY_AND_RESET_MOCKS(); 1719 VERIFY_AND_RESET_MOCKS();
1720 1720
1721 // The next call to animate will no longer scroll vertically. 1721 // The next call to animate will no longer scroll vertically.
1722 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1722 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1723 EXPECT_CALL(mock_input_handler_, 1723 EXPECT_CALL(mock_input_handler_,
1724 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) 1724 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 1858
1859 // The third animate hits the bottom content edge. 1859 // The third animate hits the bottom content edge.
1860 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); 1860 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100);
1861 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); 1861 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100);
1862 EXPECT_CALL( 1862 EXPECT_CALL(
1863 mock_input_handler_, 1863 mock_input_handler_,
1864 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0)))) 1864 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Lt(0))))
1865 .WillOnce(testing::Return(overscroll)); 1865 .WillOnce(testing::Return(overscroll));
1866 EXPECT_CALL( 1866 EXPECT_CALL(
1867 mock_client_, 1867 mock_client_,
1868 DidOverscroll( 1868 DidOverscroll(overscroll.accumulated_root_overscroll,
1869 overscroll.accumulated_root_overscroll, 1869 overscroll.unused_scroll_delta,
1870 overscroll.unused_scroll_delta, 1870 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)),
1871 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), 1871 testing::_, testing::_));
1872 testing::_));
1873 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1872 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1874 time += base::TimeDelta::FromMilliseconds(10); 1873 time += base::TimeDelta::FromMilliseconds(10);
1875 Animate(time); 1874 Animate(time);
1876 VERIFY_AND_RESET_MOCKS(); 1875 VERIFY_AND_RESET_MOCKS();
1877 1876
1878 // The next call to animate will no longer scroll vertically. 1877 // The next call to animate will no longer scroll vertically.
1879 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); 1878 EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
1880 EXPECT_CALL( 1879 EXPECT_CALL(
1881 mock_input_handler_, 1880 mock_input_handler_,
1882 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0)))) 1881 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Eq(0))))
1883 .WillOnce(testing::Return(scroll_result_did_scroll_)); 1882 .WillOnce(testing::Return(scroll_result_did_scroll_));
1884 time += base::TimeDelta::FromMilliseconds(10); 1883 time += base::TimeDelta::FromMilliseconds(10);
1885 Animate(time); 1884 Animate(time);
1886 VERIFY_AND_RESET_MOCKS(); 1885 VERIFY_AND_RESET_MOCKS();
1887 1886
1888 // The next call will hit the right edge. 1887 // The next call will hit the right edge.
1889 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); 1888 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100);
1890 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); 1889 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0);
1891 EXPECT_CALL( 1890 EXPECT_CALL(
1892 mock_input_handler_, 1891 mock_input_handler_,
1893 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0)))) 1892 ScrollBy(testing::Property(&cc::ScrollState::delta_x, testing::Lt(0))))
1894 .WillOnce(testing::Return(overscroll)); 1893 .WillOnce(testing::Return(overscroll));
1895 EXPECT_CALL( 1894 EXPECT_CALL(
1896 mock_client_, 1895 mock_client_,
1897 DidOverscroll( 1896 DidOverscroll(overscroll.accumulated_root_overscroll,
1898 overscroll.accumulated_root_overscroll, 1897 overscroll.unused_scroll_delta,
1899 overscroll.unused_scroll_delta, 1898 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)),
1900 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), 1899 testing::_, testing::_));
1901 testing::_));
1902 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); 1900 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
1903 time += base::TimeDelta::FromMilliseconds(10); 1901 time += base::TimeDelta::FromMilliseconds(10);
1904 Animate(time); 1902 Animate(time);
1905 VERIFY_AND_RESET_MOCKS(); 1903 VERIFY_AND_RESET_MOCKS();
1906 1904
1907 // The next call to animate will no longer scroll horizontally or vertically, 1905 // The next call to animate will no longer scroll horizontally or vertically,
1908 // and the fling should be cancelled. 1906 // and the fling should be cancelled.
1909 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); 1907 EXPECT_SET_NEEDS_ANIMATE_INPUT(0);
1910 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0); 1908 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_)).Times(0);
1911 time += base::TimeDelta::FromMilliseconds(10); 1909 time += base::TimeDelta::FromMilliseconds(10);
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), 2785 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1),
2788 base::Bucket(5, 1), base::Bucket(14, 1))); 2786 base::Bucket(5, 1), base::Bucket(14, 1)));
2789 } 2787 }
2790 2788
2791 2789
2792 INSTANTIATE_TEST_CASE_P(AnimateInput, 2790 INSTANTIATE_TEST_CASE_P(AnimateInput,
2793 InputHandlerProxyTest, 2791 InputHandlerProxyTest,
2794 testing::ValuesIn(test_types)); 2792 testing::ValuesIn(test_types));
2795 } // namespace test 2793 } // namespace test
2796 } // namespace ui 2794 } // namespace ui
OLDNEW
« ui/events/blink/input_handler_proxy.cc ('K') | « 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