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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 WebGestureDevice deviceSource, | 167 WebGestureDevice deviceSource, |
168 const WebFloatPoint& velocity, | 168 const WebFloatPoint& velocity, |
169 const WebSize& cumulative_scroll) override { | 169 const WebSize& cumulative_scroll) override { |
170 return new FakeWebGestureCurve( | 170 return new FakeWebGestureCurve( |
171 blink::WebFloatSize(velocity.x, velocity.y), | 171 blink::WebFloatSize(velocity.x, velocity.y), |
172 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); | 172 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); |
173 } | 173 } |
174 | 174 |
175 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); | 175 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); |
176 virtual void DidStopFlinging() override {} | 176 virtual void DidStopFlinging() override {} |
177 virtual void DidReceiveInputEvent() override {} | 177 virtual void DidReceiveInputEvent(blink::WebInputEvent::Type) override {} |
| 178 virtual void DidAnimateForInput() override {} |
178 | 179 |
179 private: | 180 private: |
180 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); | 181 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); |
181 }; | 182 }; |
182 | 183 |
183 class MockInputHandlerProxyClientWithDidReceiveInputEvent | 184 class MockInputHandlerProxyClientWithDidReceiveInputEvent |
184 : public MockInputHandlerProxyClient { | 185 : public MockInputHandlerProxyClient { |
185 public: | 186 public: |
186 MockInputHandlerProxyClientWithDidReceiveInputEvent() {} | 187 MockInputHandlerProxyClientWithDidReceiveInputEvent() {} |
187 virtual ~MockInputHandlerProxyClientWithDidReceiveInputEvent() {} | 188 virtual ~MockInputHandlerProxyClientWithDidReceiveInputEvent() {} |
188 | 189 |
189 MOCK_METHOD0(DidReceiveInputEvent, void()); | 190 MOCK_METHOD1(DidReceiveInputEvent, void(blink::WebInputEvent::Type type)); |
| 191 MOCK_METHOD0(DidAnimateForInput, void()); |
190 | 192 |
191 private: | 193 private: |
192 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidReceiveInputEvent); | 194 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidReceiveInputEvent); |
193 }; | 195 }; |
194 | 196 |
195 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x, | 197 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x, |
196 float y) { | 198 float y) { |
197 WebTouchPoint point; | 199 WebTouchPoint point; |
198 point.state = state; | 200 point.state = state; |
199 point.screenPosition = WebFloatPoint(x, y); | 201 point.screenPosition = WebFloatPoint(x, y); |
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 testing::StrictMock< | 1991 testing::StrictMock< |
1990 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client; | 1992 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client; |
1991 input_handler_.reset( | 1993 input_handler_.reset( |
1992 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); | 1994 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); |
1993 | 1995 |
1994 // Note the type of input event isn't important. | 1996 // Note the type of input event isn't important. |
1995 WebMouseWheelEvent wheel; | 1997 WebMouseWheelEvent wheel; |
1996 wheel.type = WebInputEvent::MouseWheel; | 1998 wheel.type = WebInputEvent::MouseWheel; |
1997 wheel.scrollByPage = true; | 1999 wheel.scrollByPage = true; |
1998 | 2000 |
1999 EXPECT_CALL(mock_client, DidReceiveInputEvent()); | 2001 EXPECT_CALL(mock_client, DidReceiveInputEvent(WebInputEvent::MouseWheel)); |
2000 | 2002 |
2001 input_handler_->HandleInputEvent(wheel); | 2003 input_handler_->HandleInputEvent(wheel); |
2002 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2004 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2003 } | 2005 } |
2004 | 2006 |
| 2007 TEST_F(InputHandlerProxyTest, DidReceiveInputEvent_ForFling) { |
| 2008 testing::StrictMock< |
| 2009 MockInputHandlerProxyClientWithDidReceiveInputEvent> mock_client; |
| 2010 input_handler_.reset( |
| 2011 new content::InputHandlerProxy(&mock_input_handler_, &mock_client)); |
| 2012 |
| 2013 gesture_.type = WebInputEvent::GestureFlingStart; |
| 2014 WebFloatPoint fling_delta = WebFloatPoint(100, 100); |
| 2015 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 2016 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 2017 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 2018 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 2019 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 2020 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 2021 EXPECT_CALL(mock_client, |
| 2022 DidReceiveInputEvent(WebInputEvent::GestureFlingStart)); |
| 2023 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, |
| 2024 input_handler_->HandleInputEvent(gesture_)); |
| 2025 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 2026 testing::Mock::VerifyAndClearExpectations(&mock_client); |
| 2027 |
| 2028 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
| 2029 EXPECT_CALL(mock_client, DidAnimateForInput()); |
| 2030 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 2031 input_handler_->Animate(time); |
| 2032 |
| 2033 testing::Mock::VerifyAndClearExpectations(&mock_client); |
| 2034 } |
| 2035 |
2005 } // namespace | 2036 } // namespace |
2006 } // namespace content | 2037 } // namespace content |
OLD | NEW |