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/trees/swap_promise_monitor.h" | 9 #include "cc/trees/swap_promise_monitor.h" |
10 #include "content/common/input/did_overscroll_params.h" | 10 #include "content/common/input/did_overscroll_params.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 source_device, | 68 source_device, |
69 velocity, | 69 velocity, |
70 point, | 70 point, |
71 global_point, | 71 global_point, |
72 modifiers); | 72 modifiers); |
73 } | 73 } |
74 | 74 |
75 class MockInputHandler : public cc::InputHandler { | 75 class MockInputHandler : public cc::InputHandler { |
76 public: | 76 public: |
77 MockInputHandler() {} | 77 MockInputHandler() {} |
78 virtual ~MockInputHandler() {} | 78 ~MockInputHandler() override {} |
79 | 79 |
80 MOCK_METHOD0(PinchGestureBegin, void()); | 80 MOCK_METHOD0(PinchGestureBegin, void()); |
81 MOCK_METHOD2(PinchGestureUpdate, | 81 MOCK_METHOD2(PinchGestureUpdate, |
82 void(float magnify_delta, const gfx::Point& anchor)); | 82 void(float magnify_delta, const gfx::Point& anchor)); |
83 MOCK_METHOD0(PinchGestureEnd, void()); | 83 MOCK_METHOD0(PinchGestureEnd, void()); |
84 | 84 |
85 MOCK_METHOD0(SetNeedsAnimate, void()); | 85 MOCK_METHOD0(SetNeedsAnimate, void()); |
86 | 86 |
87 MOCK_METHOD2(ScrollBegin, | 87 MOCK_METHOD2(ScrollBegin, |
88 ScrollStatus(const gfx::Point& viewport_point, | 88 ScrollStatus(const gfx::Point& viewport_point, |
89 cc::InputHandler::ScrollInputType type)); | 89 cc::InputHandler::ScrollInputType type)); |
90 MOCK_METHOD2(ScrollAnimated, | 90 MOCK_METHOD2(ScrollAnimated, |
91 ScrollStatus(const gfx::Point& viewport_point, | 91 ScrollStatus(const gfx::Point& viewport_point, |
92 const gfx::Vector2dF& scroll_delta)); | 92 const gfx::Vector2dF& scroll_delta)); |
93 MOCK_METHOD2(ScrollBy, | 93 MOCK_METHOD2(ScrollBy, |
94 cc::InputHandlerScrollResult( | 94 cc::InputHandlerScrollResult( |
95 const gfx::Point& viewport_point, | 95 const gfx::Point& viewport_point, |
96 const gfx::Vector2dF& scroll_delta)); | 96 const gfx::Vector2dF& scroll_delta)); |
97 MOCK_METHOD2(ScrollVerticallyByPage, | 97 MOCK_METHOD2(ScrollVerticallyByPage, |
98 bool(const gfx::Point& viewport_point, | 98 bool(const gfx::Point& viewport_point, |
99 cc::ScrollDirection direction)); | 99 cc::ScrollDirection direction)); |
100 MOCK_METHOD0(ScrollEnd, void()); | 100 MOCK_METHOD0(ScrollEnd, void()); |
101 MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus()); | 101 MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus()); |
102 | 102 |
103 virtual scoped_ptr<cc::SwapPromiseMonitor> | 103 scoped_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( |
104 CreateLatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency) override { | 104 ui::LatencyInfo* latency) override { |
105 return scoped_ptr<cc::SwapPromiseMonitor>(); | 105 return scoped_ptr<cc::SwapPromiseMonitor>(); |
106 } | 106 } |
107 | 107 |
108 cc::ScrollElasticityHelper* CreateScrollElasticityHelper() override { | 108 cc::ScrollElasticityHelper* CreateScrollElasticityHelper() override { |
109 return NULL; | 109 return NULL; |
110 } | 110 } |
111 | 111 |
112 virtual void BindToClient(cc::InputHandlerClient* client) override {} | 112 void BindToClient(cc::InputHandlerClient* client) override {} |
113 | 113 |
114 virtual void MouseMoveAt(const gfx::Point& mouse_position) override {} | 114 void MouseMoveAt(const gfx::Point& mouse_position) override {} |
115 | 115 |
116 MOCK_METHOD2(IsCurrentlyScrollingLayerAt, | 116 MOCK_METHOD2(IsCurrentlyScrollingLayerAt, |
117 bool(const gfx::Point& point, | 117 bool(const gfx::Point& point, |
118 cc::InputHandler::ScrollInputType type)); | 118 cc::InputHandler::ScrollInputType type)); |
119 | 119 |
120 MOCK_METHOD1(HaveWheelEventHandlersAt, bool(const gfx::Point& point)); | 120 MOCK_METHOD1(HaveWheelEventHandlersAt, bool(const gfx::Point& point)); |
121 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); | 121 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); |
122 | 122 |
123 virtual void SetRootLayerScrollOffsetDelegate( | 123 void SetRootLayerScrollOffsetDelegate( |
124 cc::LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) | 124 cc::LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) |
125 override {} | 125 override {} |
126 | 126 |
127 virtual void OnRootLayerDelegatedScrollOffsetChanged() override {} | 127 void OnRootLayerDelegatedScrollOffsetChanged() override {} |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(MockInputHandler); | 129 DISALLOW_COPY_AND_ASSIGN(MockInputHandler); |
130 }; | 130 }; |
131 | 131 |
132 // A simple WebGestureCurve implementation that flings at a constant velocity | 132 // A simple WebGestureCurve implementation that flings at a constant velocity |
133 // indefinitely. | 133 // indefinitely. |
134 class FakeWebGestureCurve : public blink::WebGestureCurve { | 134 class FakeWebGestureCurve : public blink::WebGestureCurve { |
135 public: | 135 public: |
136 FakeWebGestureCurve(const blink::WebFloatSize& velocity, | 136 FakeWebGestureCurve(const blink::WebFloatSize& velocity, |
137 const blink::WebFloatSize& cumulative_scroll) | 137 const blink::WebFloatSize& cumulative_scroll) |
(...skipping 18 matching lines...) Expand all Loading... |
156 blink::WebFloatSize velocity_; | 156 blink::WebFloatSize velocity_; |
157 blink::WebFloatSize cumulative_scroll_; | 157 blink::WebFloatSize cumulative_scroll_; |
158 | 158 |
159 DISALLOW_COPY_AND_ASSIGN(FakeWebGestureCurve); | 159 DISALLOW_COPY_AND_ASSIGN(FakeWebGestureCurve); |
160 }; | 160 }; |
161 | 161 |
162 class MockInputHandlerProxyClient | 162 class MockInputHandlerProxyClient |
163 : public content::InputHandlerProxyClient { | 163 : public content::InputHandlerProxyClient { |
164 public: | 164 public: |
165 MockInputHandlerProxyClient() {} | 165 MockInputHandlerProxyClient() {} |
166 virtual ~MockInputHandlerProxyClient() {} | 166 ~MockInputHandlerProxyClient() override {} |
167 | 167 |
168 virtual void WillShutdown() override {} | 168 void WillShutdown() override {} |
169 | 169 |
170 MOCK_METHOD1(TransferActiveWheelFlingAnimation, | 170 MOCK_METHOD1(TransferActiveWheelFlingAnimation, |
171 void(const WebActiveWheelFlingParameters&)); | 171 void(const WebActiveWheelFlingParameters&)); |
172 | 172 |
173 virtual blink::WebGestureCurve* CreateFlingAnimationCurve( | 173 blink::WebGestureCurve* CreateFlingAnimationCurve( |
174 WebGestureDevice deviceSource, | 174 WebGestureDevice deviceSource, |
175 const WebFloatPoint& velocity, | 175 const WebFloatPoint& velocity, |
176 const WebSize& cumulative_scroll) override { | 176 const WebSize& cumulative_scroll) override { |
177 return new FakeWebGestureCurve( | 177 return new FakeWebGestureCurve( |
178 blink::WebFloatSize(velocity.x, velocity.y), | 178 blink::WebFloatSize(velocity.x, velocity.y), |
179 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); | 179 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); |
180 } | 180 } |
181 | 181 |
182 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); | 182 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); |
183 virtual void DidStopFlinging() override {} | 183 void DidStopFlinging() override {} |
184 virtual void DidReceiveInputEvent(const blink::WebInputEvent&) override {} | 184 void DidReceiveInputEvent(const blink::WebInputEvent&) override {} |
185 virtual void DidAnimateForInput() override {} | 185 void DidAnimateForInput() override {} |
186 | 186 |
187 private: | 187 private: |
188 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); | 188 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); |
189 }; | 189 }; |
190 | 190 |
191 class MockInputHandlerProxyClientWithDidReceiveInputEvent | 191 class MockInputHandlerProxyClientWithDidReceiveInputEvent |
192 : public MockInputHandlerProxyClient { | 192 : public MockInputHandlerProxyClient { |
193 public: | 193 public: |
194 MockInputHandlerProxyClientWithDidReceiveInputEvent() {} | 194 MockInputHandlerProxyClientWithDidReceiveInputEvent() {} |
195 virtual ~MockInputHandlerProxyClientWithDidReceiveInputEvent() {} | 195 ~MockInputHandlerProxyClientWithDidReceiveInputEvent() override {} |
196 | 196 |
197 MOCK_METHOD1(DidReceiveInputEvent, void(const blink::WebInputEvent&)); | 197 MOCK_METHOD1(DidReceiveInputEvent, void(const blink::WebInputEvent&)); |
198 MOCK_METHOD0(DidAnimateForInput, void()); | 198 MOCK_METHOD0(DidAnimateForInput, void()); |
199 | 199 |
200 private: | 200 private: |
201 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidReceiveInputEvent); | 201 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidReceiveInputEvent); |
202 }; | 202 }; |
203 | 203 |
204 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x, | 204 WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state, float x, |
205 float y) { | 205 float y) { |
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); | 2131 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); |
2132 EXPECT_CALL(mock_client, DidAnimateForInput()); | 2132 EXPECT_CALL(mock_client, DidAnimateForInput()); |
2133 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 2133 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
2134 input_handler_->Animate(time); | 2134 input_handler_->Animate(time); |
2135 | 2135 |
2136 testing::Mock::VerifyAndClearExpectations(&mock_client); | 2136 testing::Mock::VerifyAndClearExpectations(&mock_client); |
2137 } | 2137 } |
2138 | 2138 |
2139 } // namespace | 2139 } // namespace |
2140 } // namespace content | 2140 } // namespace content |
OLD | NEW |