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 "ui/events/blink/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/trees/swap_promise_monitor.h" | 9 #include "cc/trees/swap_promise_monitor.h" |
10 #include "content/common/input/did_overscroll_params.h" | |
11 #include "content/renderer/input/input_handler_proxy_client.h" | |
12 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
15 #include "third_party/WebKit/public/platform/WebFloatSize.h" | 13 #include "third_party/WebKit/public/platform/WebFloatSize.h" |
16 #include "third_party/WebKit/public/platform/WebGestureCurve.h" | 14 #include "third_party/WebKit/public/platform/WebGestureCurve.h" |
17 #include "third_party/WebKit/public/platform/WebPoint.h" | 15 #include "third_party/WebKit/public/platform/WebPoint.h" |
18 #include "third_party/WebKit/public/web/WebInputEvent.h" | 16 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 17 #include "ui/events/blink/input_handler_proxy_client.h" |
19 #include "ui/events/latency_info.h" | 18 #include "ui/events/latency_info.h" |
20 #include "ui/gfx/geometry/scroll_offset.h" | 19 #include "ui/gfx/geometry/scroll_offset.h" |
21 #include "ui/gfx/geometry/size_f.h" | 20 #include "ui/gfx/geometry/size_f.h" |
22 | 21 |
23 using blink::WebActiveWheelFlingParameters; | 22 using blink::WebActiveWheelFlingParameters; |
24 using blink::WebFloatPoint; | 23 using blink::WebFloatPoint; |
25 using blink::WebFloatSize; | 24 using blink::WebFloatSize; |
26 using blink::WebGestureDevice; | 25 using blink::WebGestureDevice; |
27 using blink::WebGestureEvent; | 26 using blink::WebGestureEvent; |
28 using blink::WebInputEvent; | 27 using blink::WebInputEvent; |
29 using blink::WebKeyboardEvent; | 28 using blink::WebKeyboardEvent; |
30 using blink::WebMouseWheelEvent; | 29 using blink::WebMouseWheelEvent; |
31 using blink::WebPoint; | 30 using blink::WebPoint; |
32 using blink::WebSize; | 31 using blink::WebSize; |
33 using blink::WebTouchEvent; | 32 using blink::WebTouchEvent; |
34 using blink::WebTouchPoint; | 33 using blink::WebTouchPoint; |
35 using testing::Field; | 34 using testing::Field; |
36 | 35 |
37 namespace content { | 36 namespace ui { |
38 namespace test { | 37 namespace test { |
39 | 38 |
40 namespace { | 39 namespace { |
41 | 40 |
42 enum InputHandlerProxyTestType { | 41 enum InputHandlerProxyTestType { |
43 ROOT_SCROLL_NORMAL_HANDLER, | 42 ROOT_SCROLL_NORMAL_HANDLER, |
44 ROOT_SCROLL_SYNCHRONOUS_HANDLER, | 43 ROOT_SCROLL_SYNCHRONOUS_HANDLER, |
45 CHILD_SCROLL_NORMAL_HANDLER, | 44 CHILD_SCROLL_NORMAL_HANDLER, |
46 CHILD_SCROLL_SYNCHRONOUS_HANDLER, | 45 CHILD_SCROLL_SYNCHRONOUS_HANDLER, |
47 }; | 46 }; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 bool IsCurrentlyScrollingInnerViewport() const override { | 142 bool IsCurrentlyScrollingInnerViewport() const override { |
144 return is_scrolling_root_; | 143 return is_scrolling_root_; |
145 } | 144 } |
146 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } | 145 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } |
147 | 146 |
148 private: | 147 private: |
149 bool is_scrolling_root_ = true; | 148 bool is_scrolling_root_ = true; |
150 DISALLOW_COPY_AND_ASSIGN(MockInputHandler); | 149 DISALLOW_COPY_AND_ASSIGN(MockInputHandler); |
151 }; | 150 }; |
152 | 151 |
153 class MockSynchronousInputHandler : public content::SynchronousInputHandler { | 152 class MockSynchronousInputHandler : public SynchronousInputHandler { |
154 public: | 153 public: |
155 MOCK_METHOD0(SetNeedsSynchronousAnimateInput, void()); | 154 MOCK_METHOD0(SetNeedsSynchronousAnimateInput, void()); |
156 MOCK_METHOD6(UpdateRootLayerState, | 155 MOCK_METHOD6(UpdateRootLayerState, |
157 void(const gfx::ScrollOffset& total_scroll_offset, | 156 void(const gfx::ScrollOffset& total_scroll_offset, |
158 const gfx::ScrollOffset& max_scroll_offset, | 157 const gfx::ScrollOffset& max_scroll_offset, |
159 const gfx::SizeF& scrollable_size, | 158 const gfx::SizeF& scrollable_size, |
160 float page_scale_factor, | 159 float page_scale_factor, |
161 float min_page_scale_factor, | 160 float min_page_scale_factor, |
162 float max_page_scale_factor)); | 161 float max_page_scale_factor)); |
163 }; | 162 }; |
(...skipping 22 matching lines...) Expand all Loading... |
186 } | 185 } |
187 | 186 |
188 private: | 187 private: |
189 blink::WebFloatSize velocity_; | 188 blink::WebFloatSize velocity_; |
190 blink::WebFloatSize cumulative_scroll_; | 189 blink::WebFloatSize cumulative_scroll_; |
191 | 190 |
192 DISALLOW_COPY_AND_ASSIGN(FakeWebGestureCurve); | 191 DISALLOW_COPY_AND_ASSIGN(FakeWebGestureCurve); |
193 }; | 192 }; |
194 | 193 |
195 class MockInputHandlerProxyClient | 194 class MockInputHandlerProxyClient |
196 : public content::InputHandlerProxyClient { | 195 : public InputHandlerProxyClient { |
197 public: | 196 public: |
198 MockInputHandlerProxyClient() {} | 197 MockInputHandlerProxyClient() {} |
199 ~MockInputHandlerProxyClient() override {} | 198 ~MockInputHandlerProxyClient() override {} |
200 | 199 |
201 void WillShutdown() override {} | 200 void WillShutdown() override {} |
202 | 201 |
203 MOCK_METHOD1(TransferActiveWheelFlingAnimation, | 202 MOCK_METHOD1(TransferActiveWheelFlingAnimation, |
204 void(const WebActiveWheelFlingParameters&)); | 203 void(const WebActiveWheelFlingParameters&)); |
205 | 204 |
206 blink::WebGestureCurve* CreateFlingAnimationCurve( | 205 blink::WebGestureCurve* CreateFlingAnimationCurve( |
207 WebGestureDevice deviceSource, | 206 WebGestureDevice deviceSource, |
208 const WebFloatPoint& velocity, | 207 const WebFloatPoint& velocity, |
209 const WebSize& cumulative_scroll) override { | 208 const WebSize& cumulative_scroll) override { |
210 return new FakeWebGestureCurve( | 209 return new FakeWebGestureCurve( |
211 blink::WebFloatSize(velocity.x, velocity.y), | 210 blink::WebFloatSize(velocity.x, velocity.y), |
212 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); | 211 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); |
213 } | 212 } |
214 | 213 |
215 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); | 214 MOCK_METHOD4(DidOverscroll, |
| 215 void(const gfx::Vector2dF& accumulated_overscroll, |
| 216 const gfx::Vector2dF& latest_overscroll_delta, |
| 217 const gfx::Vector2dF& current_fling_velocity, |
| 218 const gfx::PointF& causal_event_viewport_point)); |
216 void DidStopFlinging() override {} | 219 void DidStopFlinging() override {} |
217 void DidAnimateForInput() override {} | 220 void DidAnimateForInput() override {} |
218 | 221 |
219 private: | 222 private: |
220 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); | 223 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); |
221 }; | 224 }; |
222 | 225 |
223 class MockInputHandlerProxyClientWithDidAnimateForInput | 226 class MockInputHandlerProxyClientWithDidAnimateForInput |
224 : public MockInputHandlerProxyClient { | 227 : public MockInputHandlerProxyClient { |
225 public: | 228 public: |
(...skipping 21 matching lines...) Expand all Loading... |
247 : public testing::Test, | 250 : public testing::Test, |
248 public testing::WithParamInterface<InputHandlerProxyTestType> { | 251 public testing::WithParamInterface<InputHandlerProxyTestType> { |
249 public: | 252 public: |
250 InputHandlerProxyTest() | 253 InputHandlerProxyTest() |
251 : synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER), | 254 : synchronous_root_scroll_(GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER), |
252 install_synchronous_handler_( | 255 install_synchronous_handler_( |
253 GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER || | 256 GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER || |
254 GetParam() == CHILD_SCROLL_SYNCHRONOUS_HANDLER), | 257 GetParam() == CHILD_SCROLL_SYNCHRONOUS_HANDLER), |
255 expected_disposition_(InputHandlerProxy::DID_HANDLE) { | 258 expected_disposition_(InputHandlerProxy::DID_HANDLE) { |
256 input_handler_.reset( | 259 input_handler_.reset( |
257 new content::InputHandlerProxy(&mock_input_handler_, &mock_client_)); | 260 new ui::InputHandlerProxy( |
| 261 &mock_input_handler_, &mock_client_)); |
258 scroll_result_did_scroll_.did_scroll = true; | 262 scroll_result_did_scroll_.did_scroll = true; |
259 scroll_result_did_not_scroll_.did_scroll = false; | 263 scroll_result_did_not_scroll_.did_scroll = false; |
260 | 264 |
261 if (install_synchronous_handler_) { | 265 if (install_synchronous_handler_) { |
262 EXPECT_CALL(mock_input_handler_, | 266 EXPECT_CALL(mock_input_handler_, |
263 RequestUpdateForSynchronousInputHandler()) | 267 RequestUpdateForSynchronousInputHandler()) |
264 .Times(1); | 268 .Times(1); |
265 input_handler_->SetOnlySynchronouslyAnimateRootFlings( | 269 input_handler_->SetOnlySynchronouslyAnimateRootFlings( |
266 &mock_synchronous_input_handler_); | 270 &mock_synchronous_input_handler_); |
267 } | 271 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 void SetSmoothScrollEnabled(bool value) { | 355 void SetSmoothScrollEnabled(bool value) { |
352 input_handler_->smooth_scroll_enabled_ = value; | 356 input_handler_->smooth_scroll_enabled_ = value; |
353 } | 357 } |
354 | 358 |
355 protected: | 359 protected: |
356 const bool synchronous_root_scroll_; | 360 const bool synchronous_root_scroll_; |
357 const bool install_synchronous_handler_; | 361 const bool install_synchronous_handler_; |
358 testing::StrictMock<MockInputHandler> mock_input_handler_; | 362 testing::StrictMock<MockInputHandler> mock_input_handler_; |
359 testing::StrictMock<MockSynchronousInputHandler> | 363 testing::StrictMock<MockSynchronousInputHandler> |
360 mock_synchronous_input_handler_; | 364 mock_synchronous_input_handler_; |
361 scoped_ptr<content::InputHandlerProxy> input_handler_; | 365 scoped_ptr<ui::InputHandlerProxy> input_handler_; |
362 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; | 366 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; |
363 WebGestureEvent gesture_; | 367 WebGestureEvent gesture_; |
364 InputHandlerProxy::EventDisposition expected_disposition_; | 368 InputHandlerProxy::EventDisposition expected_disposition_; |
365 cc::InputHandlerScrollResult scroll_result_did_scroll_; | 369 cc::InputHandlerScrollResult scroll_result_did_scroll_; |
366 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; | 370 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; |
367 }; | 371 }; |
368 | 372 |
369 TEST_P(InputHandlerProxyTest, MouseWheelByPageMainThread) { | 373 TEST_P(InputHandlerProxyTest, MouseWheelByPageMainThread) { |
370 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; | 374 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; |
371 WebMouseWheelEvent wheel; | 375 WebMouseWheelEvent wheel; |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); | 1507 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); |
1504 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); | 1508 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 10); |
1505 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1509 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1506 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1510 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
1507 EXPECT_CALL(mock_input_handler_, | 1511 EXPECT_CALL(mock_input_handler_, |
1508 ScrollBy(testing::_, | 1512 ScrollBy(testing::_, |
1509 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) | 1513 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
1510 .WillOnce(testing::Return(overscroll)); | 1514 .WillOnce(testing::Return(overscroll)); |
1511 EXPECT_CALL( | 1515 EXPECT_CALL( |
1512 mock_client_, | 1516 mock_client_, |
1513 DidOverscroll(testing::AllOf( | 1517 DidOverscroll( |
1514 testing::Field( | 1518 overscroll.accumulated_root_overscroll, |
1515 &DidOverscrollParams::accumulated_overscroll, | 1519 overscroll.unused_scroll_delta, |
1516 testing::Eq(overscroll.accumulated_root_overscroll)), | 1520 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), |
1517 testing::Field( | 1521 testing::_)); |
1518 &DidOverscrollParams::latest_overscroll_delta, | |
1519 testing::Eq(overscroll.unused_scroll_delta)), | |
1520 testing::Field( | |
1521 &DidOverscrollParams::current_fling_velocity, | |
1522 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); | |
1523 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1522 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1524 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1523 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1525 time += base::TimeDelta::FromMilliseconds(100); | 1524 time += base::TimeDelta::FromMilliseconds(100); |
1526 Animate(time); | 1525 Animate(time); |
1527 VERIFY_AND_RESET_MOCKS(); | 1526 VERIFY_AND_RESET_MOCKS(); |
1528 | 1527 |
1529 // The next call to animate will no longer scroll vertically. | 1528 // The next call to animate will no longer scroll vertically. |
1530 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1529 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1531 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 1530 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
1532 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); | 1531 .WillOnce(testing::Return(cc::InputHandler::SCROLL_STARTED)); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 | 1662 |
1664 // The third animate hits the bottom content edge. | 1663 // The third animate hits the bottom content edge. |
1665 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); | 1664 overscroll.accumulated_root_overscroll = gfx::Vector2dF(0, 100); |
1666 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); | 1665 overscroll.unused_scroll_delta = gfx::Vector2dF(0, 100); |
1667 EXPECT_CALL(mock_input_handler_, | 1666 EXPECT_CALL(mock_input_handler_, |
1668 ScrollBy(testing::_, | 1667 ScrollBy(testing::_, |
1669 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) | 1668 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
1670 .WillOnce(testing::Return(overscroll)); | 1669 .WillOnce(testing::Return(overscroll)); |
1671 EXPECT_CALL( | 1670 EXPECT_CALL( |
1672 mock_client_, | 1671 mock_client_, |
1673 DidOverscroll(testing::AllOf( | 1672 DidOverscroll( |
1674 testing::Field( | 1673 overscroll.accumulated_root_overscroll, |
1675 &DidOverscrollParams::accumulated_overscroll, | 1674 overscroll.unused_scroll_delta, |
1676 testing::Eq(overscroll.accumulated_root_overscroll)), | 1675 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)), |
1677 testing::Field( | 1676 testing::_)); |
1678 &DidOverscrollParams::latest_overscroll_delta, | |
1679 testing::Eq(overscroll.unused_scroll_delta)), | |
1680 testing::Field( | |
1681 &DidOverscrollParams::current_fling_velocity, | |
1682 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))))); | |
1683 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1677 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1684 time += base::TimeDelta::FromMilliseconds(10); | 1678 time += base::TimeDelta::FromMilliseconds(10); |
1685 Animate(time); | 1679 Animate(time); |
1686 VERIFY_AND_RESET_MOCKS(); | 1680 VERIFY_AND_RESET_MOCKS(); |
1687 | 1681 |
1688 // The next call to animate will no longer scroll vertically. | 1682 // The next call to animate will no longer scroll vertically. |
1689 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); | 1683 EXPECT_SET_NEEDS_ANIMATE_INPUT(1); |
1690 EXPECT_CALL(mock_input_handler_, | 1684 EXPECT_CALL(mock_input_handler_, |
1691 ScrollBy(testing::_, | 1685 ScrollBy(testing::_, |
1692 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) | 1686 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) |
1693 .WillOnce(testing::Return(scroll_result_did_scroll_)); | 1687 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
1694 time += base::TimeDelta::FromMilliseconds(10); | 1688 time += base::TimeDelta::FromMilliseconds(10); |
1695 Animate(time); | 1689 Animate(time); |
1696 VERIFY_AND_RESET_MOCKS(); | 1690 VERIFY_AND_RESET_MOCKS(); |
1697 | 1691 |
1698 // The next call will hit the right edge. | 1692 // The next call will hit the right edge. |
1699 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); | 1693 overscroll.accumulated_root_overscroll = gfx::Vector2dF(100, 100); |
1700 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); | 1694 overscroll.unused_scroll_delta = gfx::Vector2dF(100, 0); |
1701 EXPECT_CALL(mock_input_handler_, | 1695 EXPECT_CALL(mock_input_handler_, |
1702 ScrollBy(testing::_, | 1696 ScrollBy(testing::_, |
1703 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 1697 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
1704 .WillOnce(testing::Return(overscroll)); | 1698 .WillOnce(testing::Return(overscroll)); |
1705 EXPECT_CALL( | 1699 EXPECT_CALL( |
1706 mock_client_, | 1700 mock_client_, |
1707 DidOverscroll(testing::AllOf( | 1701 DidOverscroll( |
1708 testing::Field( | 1702 overscroll.accumulated_root_overscroll, |
1709 &DidOverscrollParams::accumulated_overscroll, | 1703 overscroll.unused_scroll_delta, |
1710 testing::Eq(overscroll.accumulated_root_overscroll)), | 1704 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)), |
1711 testing::Field( | 1705 testing::_)); |
1712 &DidOverscrollParams::latest_overscroll_delta, | |
1713 testing::Eq(overscroll.unused_scroll_delta)), | |
1714 testing::Field( | |
1715 &DidOverscrollParams::current_fling_velocity, | |
1716 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))))); | |
1717 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 1706 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
1718 time += base::TimeDelta::FromMilliseconds(10); | 1707 time += base::TimeDelta::FromMilliseconds(10); |
1719 Animate(time); | 1708 Animate(time); |
1720 VERIFY_AND_RESET_MOCKS(); | 1709 VERIFY_AND_RESET_MOCKS(); |
1721 | 1710 |
1722 // The next call to animate will no longer scroll horizontally or vertically, | 1711 // The next call to animate will no longer scroll horizontally or vertically, |
1723 // and the fling should be cancelled. | 1712 // and the fling should be cancelled. |
1724 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); | 1713 EXPECT_SET_NEEDS_ANIMATE_INPUT(0); |
1725 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); | 1714 EXPECT_CALL(mock_input_handler_, ScrollBy(testing::_, testing::_)).Times(0); |
1726 time += base::TimeDelta::FromMilliseconds(10); | 1715 time += base::TimeDelta::FromMilliseconds(10); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 2355 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
2367 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 2356 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
2368 | 2357 |
2369 VERIFY_AND_RESET_MOCKS(); | 2358 VERIFY_AND_RESET_MOCKS(); |
2370 } | 2359 } |
2371 | 2360 |
2372 TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { | 2361 TEST_P(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { |
2373 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> | 2362 testing::StrictMock<MockInputHandlerProxyClientWithDidAnimateForInput> |
2374 mock_client; | 2363 mock_client; |
2375 input_handler_.reset( | 2364 input_handler_.reset( |
2376 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); | 2365 new ui::InputHandlerProxy( |
| 2366 &mock_input_handler_, &mock_client)); |
2377 if (install_synchronous_handler_) { | 2367 if (install_synchronous_handler_) { |
2378 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) | 2368 EXPECT_CALL(mock_input_handler_, RequestUpdateForSynchronousInputHandler()) |
2379 .Times(1); | 2369 .Times(1); |
2380 input_handler_->SetOnlySynchronouslyAnimateRootFlings( | 2370 input_handler_->SetOnlySynchronouslyAnimateRootFlings( |
2381 &mock_synchronous_input_handler_); | 2371 &mock_synchronous_input_handler_); |
2382 } | 2372 } |
2383 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_); | 2373 mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_); |
2384 | 2374 |
2385 gesture_.type = WebInputEvent::GestureFlingStart; | 2375 gesture_.type = WebInputEvent::GestureFlingStart; |
2386 WebFloatPoint fling_delta = WebFloatPoint(100, 100); | 2376 WebFloatPoint fling_delta = WebFloatPoint(100, 100); |
(...skipping 13 matching lines...) Expand all Loading... |
2400 Animate(time); | 2390 Animate(time); |
2401 | 2391 |
2402 VERIFY_AND_RESET_MOCKS(); | 2392 VERIFY_AND_RESET_MOCKS(); |
2403 } | 2393 } |
2404 | 2394 |
2405 TEST(SynchronousInputHandlerProxyTest, StartupShutdown) { | 2395 TEST(SynchronousInputHandlerProxyTest, StartupShutdown) { |
2406 testing::StrictMock<MockInputHandler> mock_input_handler; | 2396 testing::StrictMock<MockInputHandler> mock_input_handler; |
2407 testing::StrictMock<MockInputHandlerProxyClient> mock_client; | 2397 testing::StrictMock<MockInputHandlerProxyClient> mock_client; |
2408 testing::StrictMock<MockSynchronousInputHandler> | 2398 testing::StrictMock<MockSynchronousInputHandler> |
2409 mock_synchronous_input_handler; | 2399 mock_synchronous_input_handler; |
2410 content::InputHandlerProxy proxy(&mock_input_handler, &mock_client); | 2400 ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client); |
2411 | 2401 |
2412 // When adding a SynchronousInputHandler, immediately request an | 2402 // When adding a SynchronousInputHandler, immediately request an |
2413 // UpdateRootLayerStateForSynchronousInputHandler() call. | 2403 // UpdateRootLayerStateForSynchronousInputHandler() call. |
2414 EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler()) | 2404 EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler()) |
2415 .Times(1); | 2405 .Times(1); |
2416 proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); | 2406 proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); |
2417 | 2407 |
2418 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); | 2408 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); |
2419 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2409 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2420 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); | 2410 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); |
2421 | 2411 |
2422 EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler()) | 2412 EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler()) |
2423 .Times(0); | 2413 .Times(0); |
2424 proxy.SetOnlySynchronouslyAnimateRootFlings(nullptr); | 2414 proxy.SetOnlySynchronouslyAnimateRootFlings(nullptr); |
2425 | 2415 |
2426 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); | 2416 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); |
2427 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2417 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2428 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); | 2418 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); |
2429 } | 2419 } |
2430 | 2420 |
2431 TEST(SynchronousInputHandlerProxyTest, UpdateRootLayerState) { | 2421 TEST(SynchronousInputHandlerProxyTest, UpdateRootLayerState) { |
2432 testing::NiceMock<MockInputHandler> mock_input_handler; | 2422 testing::NiceMock<MockInputHandler> mock_input_handler; |
2433 testing::StrictMock<MockInputHandlerProxyClient> mock_client; | 2423 testing::StrictMock<MockInputHandlerProxyClient> mock_client; |
2434 testing::StrictMock<MockSynchronousInputHandler> | 2424 testing::StrictMock<MockSynchronousInputHandler> |
2435 mock_synchronous_input_handler; | 2425 mock_synchronous_input_handler; |
2436 content::InputHandlerProxy proxy(&mock_input_handler, &mock_client); | 2426 ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client); |
2437 | 2427 |
2438 proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); | 2428 proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); |
2439 | 2429 |
2440 // When adding a SynchronousInputHandler, immediately request an | 2430 // When adding a SynchronousInputHandler, immediately request an |
2441 // UpdateRootLayerStateForSynchronousInputHandler() call. | 2431 // UpdateRootLayerStateForSynchronousInputHandler() call. |
2442 EXPECT_CALL( | 2432 EXPECT_CALL( |
2443 mock_synchronous_input_handler, | 2433 mock_synchronous_input_handler, |
2444 UpdateRootLayerState(gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4), | 2434 UpdateRootLayerState(gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4), |
2445 gfx::SizeF(5, 6), 7, 8, 9)) | 2435 gfx::SizeF(5, 6), 7, 8, 9)) |
2446 .Times(1); | 2436 .Times(1); |
2447 proxy.UpdateRootLayerStateForSynchronousInputHandler( | 2437 proxy.UpdateRootLayerStateForSynchronousInputHandler( |
2448 gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4), gfx::SizeF(5, 6), 7, 8, | 2438 gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4), gfx::SizeF(5, 6), 7, 8, |
2449 9); | 2439 9); |
2450 | 2440 |
2451 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); | 2441 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); |
2452 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2442 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2453 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); | 2443 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); |
2454 } | 2444 } |
2455 | 2445 |
2456 TEST(SynchronousInputHandlerProxyTest, SetOffset) { | 2446 TEST(SynchronousInputHandlerProxyTest, SetOffset) { |
2457 testing::NiceMock<MockInputHandler> mock_input_handler; | 2447 testing::NiceMock<MockInputHandler> mock_input_handler; |
2458 testing::StrictMock<MockInputHandlerProxyClient> mock_client; | 2448 testing::StrictMock<MockInputHandlerProxyClient> mock_client; |
2459 testing::StrictMock<MockSynchronousInputHandler> | 2449 testing::StrictMock<MockSynchronousInputHandler> |
2460 mock_synchronous_input_handler; | 2450 mock_synchronous_input_handler; |
2461 content::InputHandlerProxy proxy(&mock_input_handler, &mock_client); | 2451 ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client); |
2462 | 2452 |
2463 proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); | 2453 proxy.SetOnlySynchronouslyAnimateRootFlings(&mock_synchronous_input_handler); |
2464 | 2454 |
2465 EXPECT_CALL(mock_input_handler, SetSynchronousInputHandlerRootScrollOffset( | 2455 EXPECT_CALL(mock_input_handler, SetSynchronousInputHandlerRootScrollOffset( |
2466 gfx::ScrollOffset(5, 6))); | 2456 gfx::ScrollOffset(5, 6))); |
2467 proxy.SynchronouslySetRootScrollOffset(gfx::ScrollOffset(5, 6)); | 2457 proxy.SynchronouslySetRootScrollOffset(gfx::ScrollOffset(5, 6)); |
2468 | 2458 |
2469 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); | 2459 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); |
2470 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2460 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2471 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); | 2461 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); |
2472 } | 2462 } |
2473 | 2463 |
2474 INSTANTIATE_TEST_CASE_P(AnimateInput, | 2464 INSTANTIATE_TEST_CASE_P(AnimateInput, |
2475 InputHandlerProxyTest, | 2465 InputHandlerProxyTest, |
2476 testing::ValuesIn(test_types)); | 2466 testing::ValuesIn(test_types)); |
2477 } // namespace test | 2467 } // namespace test |
2478 } // namespace content | 2468 } // namespace ui |
OLD | NEW |