OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/gpu/input_handler_proxy.h" | 5 #include "content/renderer/gpu/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 "content/renderer/gpu/input_handler_proxy_client.h" | 9 #include "content/renderer/gpu/input_handler_proxy_client.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
13 #include "third_party/WebKit/public/platform/WebFloatSize.h" | 13 #include "third_party/WebKit/public/platform/WebFloatSize.h" |
14 #include "third_party/WebKit/public/platform/WebGestureCurve.h" | 14 #include "third_party/WebKit/public/platform/WebGestureCurve.h" |
15 #include "third_party/WebKit/public/platform/WebPoint.h" | 15 #include "third_party/WebKit/public/platform/WebPoint.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
17 | 17 |
18 using content::InputHandlerProxy; | |
jamesr
2013/06/03 20:45:59
one pattern i've seen for tests is to put the body
jdduke (slow)
2013/06/03 21:40:42
Done.
| |
19 | |
18 using WebKit::WebActiveWheelFlingParameters; | 20 using WebKit::WebActiveWheelFlingParameters; |
19 using WebKit::WebFloatPoint; | 21 using WebKit::WebFloatPoint; |
20 using WebKit::WebFloatSize; | 22 using WebKit::WebFloatSize; |
21 using WebKit::WebGestureEvent; | 23 using WebKit::WebGestureEvent; |
22 using WebKit::WebInputEvent; | 24 using WebKit::WebInputEvent; |
23 using WebKit::WebMouseWheelEvent; | 25 using WebKit::WebMouseWheelEvent; |
24 using WebKit::WebPoint; | 26 using WebKit::WebPoint; |
25 using WebKit::WebSize; | 27 using WebKit::WebSize; |
26 | 28 |
27 namespace { | 29 namespace { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 }; | 108 }; |
107 | 109 |
108 class MockInputHandlerProxyClient | 110 class MockInputHandlerProxyClient |
109 : public content::InputHandlerProxyClient { | 111 : public content::InputHandlerProxyClient { |
110 public: | 112 public: |
111 MockInputHandlerProxyClient() {} | 113 MockInputHandlerProxyClient() {} |
112 virtual ~MockInputHandlerProxyClient() {} | 114 virtual ~MockInputHandlerProxyClient() {} |
113 | 115 |
114 virtual void WillShutdown() OVERRIDE {} | 116 virtual void WillShutdown() OVERRIDE {} |
115 | 117 |
116 MOCK_METHOD0(DidHandleInputEvent, void()); | |
117 MOCK_METHOD1(DidNotHandleInputEvent, void(bool send_to_widget)); | |
118 | |
119 MOCK_METHOD1(TransferActiveWheelFlingAnimation, | 118 MOCK_METHOD1(TransferActiveWheelFlingAnimation, |
120 void(const WebActiveWheelFlingParameters&)); | 119 void(const WebActiveWheelFlingParameters&)); |
121 | 120 |
122 virtual WebKit::WebGestureCurve* CreateFlingAnimationCurve( | 121 virtual WebKit::WebGestureCurve* CreateFlingAnimationCurve( |
123 int deviceSource, | 122 int deviceSource, |
124 const WebFloatPoint& velocity, | 123 const WebFloatPoint& velocity, |
125 const WebSize& cumulative_scroll) OVERRIDE { | 124 const WebSize& cumulative_scroll) OVERRIDE { |
126 return new FakeWebGestureCurve(velocity, cumulative_scroll); | 125 return new FakeWebGestureCurve(velocity, cumulative_scroll); |
127 } | 126 } |
128 | 127 |
129 virtual void DidOverscroll(gfx::Vector2dF overscroll, | 128 virtual void DidOverscroll(gfx::Vector2dF overscroll, |
130 gfx::Vector2dF fling_velocity) {} | 129 gfx::Vector2dF fling_velocity) {} |
131 | 130 |
132 private: | 131 private: |
133 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); | 132 DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient); |
134 }; | 133 }; |
135 | 134 |
136 class InputHandlerProxyTest : public testing::Test { | 135 class InputHandlerProxyTest : public testing::Test { |
137 public: | 136 public: |
138 InputHandlerProxyTest() : expected_disposition_(DidHandle) { | 137 InputHandlerProxyTest() |
138 : expected_disposition_(InputHandlerProxy::DidHandle) { | |
139 input_handler_.reset( | 139 input_handler_.reset( |
140 new content::InputHandlerProxy(&mock_input_handler_)); | 140 new content::InputHandlerProxy(&mock_input_handler_)); |
141 input_handler_->SetClient(&mock_client_); | 141 input_handler_->SetClient(&mock_client_); |
142 } | 142 } |
143 | 143 |
144 ~InputHandlerProxyTest() { | 144 ~InputHandlerProxyTest() { |
145 input_handler_.reset(); | 145 input_handler_.reset(); |
146 } | 146 } |
147 | 147 |
148 // This is defined as a macro because when an expectation is not satisfied the | 148 // This is defined as a macro because when an expectation is not satisfied the |
149 // only output you get | 149 // only output you get |
150 // out of gmock is the line number that set the expectation. | 150 // out of gmock is the line number that set the expectation. |
151 #define VERIFY_AND_RESET_MOCKS() \ | 151 #define VERIFY_AND_RESET_MOCKS() \ |
152 do { \ | 152 do { \ |
153 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \ | 153 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \ |
154 testing::Mock::VerifyAndClearExpectations(&mock_client_); \ | 154 testing::Mock::VerifyAndClearExpectations(&mock_client_); \ |
155 switch (expected_disposition_) { \ | |
156 case DidHandle: \ | |
157 /* If we expect to handle events, we shouldn't get any */ \ | |
158 /* DidNotHandleInputEvent() calls with any parameter. */ \ | |
159 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(::testing::_)) \ | |
160 .Times(0); \ | |
161 EXPECT_CALL(mock_client_, DidHandleInputEvent()); \ | |
162 break; \ | |
163 case DidNotHandle: \ | |
164 /* If we aren't expecting to handle events, we shouldn't call */ \ | |
165 /* DidHandleInputEvent(). */ \ | |
166 EXPECT_CALL(mock_client_, DidHandleInputEvent()).Times(0); \ | |
167 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(false)).Times(0); \ | |
168 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(true)); \ | |
169 break; \ | |
170 case DropEvent: \ | |
171 /* If we're expecting to drop, we shouldn't get any didHandle..() */ \ | |
172 /* or DidNotHandleInputEvent(true) calls. */ \ | |
173 EXPECT_CALL(mock_client_, DidHandleInputEvent()).Times(0); \ | |
174 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(true)).Times(0); \ | |
175 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(false)); \ | |
176 break; \ | |
177 } \ | |
178 } while (false) | 155 } while (false) |
179 | 156 |
180 protected: | 157 protected: |
181 testing::StrictMock<MockInputHandler> mock_input_handler_; | 158 testing::StrictMock<MockInputHandler> mock_input_handler_; |
182 scoped_ptr<content::InputHandlerProxy> input_handler_; | 159 scoped_ptr<content::InputHandlerProxy> input_handler_; |
183 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; | 160 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; |
184 WebGestureEvent gesture_; | 161 WebGestureEvent gesture_; |
185 | 162 |
186 enum ExpectedDisposition { | 163 InputHandlerProxy::EventDisposition expected_disposition_; |
187 DidHandle, | |
188 DidNotHandle, | |
189 DropEvent | |
190 }; | |
191 ExpectedDisposition expected_disposition_; | |
192 }; | 164 }; |
193 | 165 |
194 TEST_F(InputHandlerProxyTest, MouseWheelByPageMainThread) { | 166 TEST_F(InputHandlerProxyTest, MouseWheelByPageMainThread) { |
167 expected_disposition_ = InputHandlerProxy::DidNotHandle; | |
195 WebMouseWheelEvent wheel; | 168 WebMouseWheelEvent wheel; |
196 wheel.type = WebInputEvent::MouseWheel; | 169 wheel.type = WebInputEvent::MouseWheel; |
197 wheel.scrollByPage = true; | 170 wheel.scrollByPage = true; |
198 | 171 |
199 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(true)).Times(1); | 172 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
200 input_handler_->HandleInputEvent(wheel); | |
201 testing::Mock::VerifyAndClearExpectations(&mock_client_); | 173 testing::Mock::VerifyAndClearExpectations(&mock_client_); |
202 } | 174 } |
203 | 175 |
204 TEST_F(InputHandlerProxyTest, GestureScrollStarted) { | 176 TEST_F(InputHandlerProxyTest, GestureScrollStarted) { |
205 // We shouldn't send any events to the widget for this gesture. | 177 // We shouldn't send any events to the widget for this gesture. |
206 expected_disposition_ = DidHandle; | 178 expected_disposition_ = InputHandlerProxy::DidHandle; |
207 VERIFY_AND_RESET_MOCKS(); | 179 VERIFY_AND_RESET_MOCKS(); |
208 | 180 |
209 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 181 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
210 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 182 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
211 | 183 |
212 gesture_.type = WebInputEvent::GestureScrollBegin; | 184 gesture_.type = WebInputEvent::GestureScrollBegin; |
213 input_handler_->HandleInputEvent(gesture_); | 185 EXPECT_EQ(expected_disposition_,input_handler_->HandleInputEvent(gesture_)); |
214 | 186 |
215 // The event should not be marked as handled if scrolling is not possible. | 187 // The event should not be marked as handled if scrolling is not possible. |
216 expected_disposition_ = DropEvent; | 188 expected_disposition_ = InputHandlerProxy::DropEvent; |
217 VERIFY_AND_RESET_MOCKS(); | 189 VERIFY_AND_RESET_MOCKS(); |
218 | 190 |
219 gesture_.type = WebInputEvent::GestureScrollUpdate; | 191 gesture_.type = WebInputEvent::GestureScrollUpdate; |
220 gesture_.data.scrollUpdate.deltaY = | 192 gesture_.data.scrollUpdate.deltaY = |
221 -40; // -Y means scroll down - i.e. in the +Y direction. | 193 -40; // -Y means scroll down - i.e. in the +Y direction. |
222 EXPECT_CALL(mock_input_handler_, | 194 EXPECT_CALL(mock_input_handler_, |
223 ScrollBy(testing::_, | 195 ScrollBy(testing::_, |
224 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) | 196 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) |
225 .WillOnce(testing::Return(false)); | 197 .WillOnce(testing::Return(false)); |
226 input_handler_->HandleInputEvent(gesture_); | 198 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
227 | 199 |
228 // Mark the event as handled if scroll happens. | 200 // Mark the event as handled if scroll happens. |
229 expected_disposition_ = DidHandle; | 201 expected_disposition_ = InputHandlerProxy::DidHandle; |
230 VERIFY_AND_RESET_MOCKS(); | 202 VERIFY_AND_RESET_MOCKS(); |
231 | 203 |
232 gesture_.type = WebInputEvent::GestureScrollUpdate; | 204 gesture_.type = WebInputEvent::GestureScrollUpdate; |
233 gesture_.data.scrollUpdate.deltaY = | 205 gesture_.data.scrollUpdate.deltaY = |
234 -40; // -Y means scroll down - i.e. in the +Y direction. | 206 -40; // -Y means scroll down - i.e. in the +Y direction. |
235 EXPECT_CALL(mock_input_handler_, | 207 EXPECT_CALL(mock_input_handler_, |
236 ScrollBy(testing::_, | 208 ScrollBy(testing::_, |
237 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) | 209 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) |
238 .WillOnce(testing::Return(true)); | 210 .WillOnce(testing::Return(true)); |
239 input_handler_->HandleInputEvent(gesture_); | 211 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
240 | 212 |
241 VERIFY_AND_RESET_MOCKS(); | 213 VERIFY_AND_RESET_MOCKS(); |
242 | 214 |
243 gesture_.type = WebInputEvent::GestureScrollEnd; | 215 gesture_.type = WebInputEvent::GestureScrollEnd; |
244 gesture_.data.scrollUpdate.deltaY = 0; | 216 gesture_.data.scrollUpdate.deltaY = 0; |
245 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 217 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
246 input_handler_->HandleInputEvent(gesture_); | 218 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
247 } | 219 } |
248 | 220 |
249 TEST_F(InputHandlerProxyTest, GestureScrollOnMainThread) { | 221 TEST_F(InputHandlerProxyTest, GestureScrollOnMainThread) { |
250 // We should send all events to the widget for this gesture. | 222 // We should send all events to the widget for this gesture. |
251 expected_disposition_ = DidNotHandle; | 223 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
252 VERIFY_AND_RESET_MOCKS(); | 224 VERIFY_AND_RESET_MOCKS(); |
253 | 225 |
254 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) | 226 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) |
255 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); | 227 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); |
256 | 228 |
257 gesture_.type = WebInputEvent::GestureScrollBegin; | 229 gesture_.type = WebInputEvent::GestureScrollBegin; |
258 input_handler_->HandleInputEvent(gesture_); | 230 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
259 | 231 |
260 VERIFY_AND_RESET_MOCKS(); | 232 VERIFY_AND_RESET_MOCKS(); |
261 | 233 |
262 gesture_.type = WebInputEvent::GestureScrollUpdate; | 234 gesture_.type = WebInputEvent::GestureScrollUpdate; |
263 gesture_.data.scrollUpdate.deltaY = 40; | 235 gesture_.data.scrollUpdate.deltaY = 40; |
264 input_handler_->HandleInputEvent(gesture_); | 236 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
265 | 237 |
266 VERIFY_AND_RESET_MOCKS(); | 238 VERIFY_AND_RESET_MOCKS(); |
267 | 239 |
268 gesture_.type = WebInputEvent::GestureScrollEnd; | 240 gesture_.type = WebInputEvent::GestureScrollEnd; |
269 gesture_.data.scrollUpdate.deltaY = 0; | 241 gesture_.data.scrollUpdate.deltaY = 0; |
270 input_handler_->HandleInputEvent(gesture_); | 242 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
271 } | 243 } |
272 | 244 |
273 TEST_F(InputHandlerProxyTest, GestureScrollIgnored) { | 245 TEST_F(InputHandlerProxyTest, GestureScrollIgnored) { |
274 // We shouldn't handle the GestureScrollBegin. | 246 // We shouldn't handle the GestureScrollBegin. |
275 // Instead, we should get one DidNotHandleInputEvent(false) call per | 247 // Instead, we should get a DropEvent result, indicating that we could |
276 // HandleInputEvent(), indicating that we could determine that there's nothing | 248 // determine that there's nothing that could scroll or otherwise react to this |
277 // that could scroll or otherwise react to this gesture sequence and thus we | 249 // gesture sequence and thus we should drop the whole gesture sequence on the |
278 // should drop the whole gesture sequence on the floor. | 250 // floor. |
279 expected_disposition_ = DropEvent; | 251 expected_disposition_ = InputHandlerProxy::DropEvent; |
280 VERIFY_AND_RESET_MOCKS(); | 252 VERIFY_AND_RESET_MOCKS(); |
281 | 253 |
282 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 254 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
283 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); | 255 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); |
284 | 256 |
285 gesture_.type = WebInputEvent::GestureScrollBegin; | 257 gesture_.type = WebInputEvent::GestureScrollBegin; |
286 input_handler_->HandleInputEvent(gesture_); | 258 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
287 } | 259 } |
288 | 260 |
289 TEST_F(InputHandlerProxyTest, GesturePinch) { | 261 TEST_F(InputHandlerProxyTest, GesturePinch) { |
290 // We shouldn't send any events to the widget for this gesture. | 262 // We shouldn't send any events to the widget for this gesture. |
291 expected_disposition_ = DidHandle; | 263 expected_disposition_ = InputHandlerProxy::DidHandle; |
292 VERIFY_AND_RESET_MOCKS(); | 264 VERIFY_AND_RESET_MOCKS(); |
293 | 265 |
294 gesture_.type = WebInputEvent::GesturePinchBegin; | 266 gesture_.type = WebInputEvent::GesturePinchBegin; |
295 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); | 267 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); |
296 input_handler_->HandleInputEvent(gesture_); | 268 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
297 | 269 |
298 VERIFY_AND_RESET_MOCKS(); | 270 VERIFY_AND_RESET_MOCKS(); |
299 | 271 |
300 gesture_.type = WebInputEvent::GesturePinchUpdate; | 272 gesture_.type = WebInputEvent::GesturePinchUpdate; |
301 gesture_.data.pinchUpdate.scale = 1.5; | 273 gesture_.data.pinchUpdate.scale = 1.5; |
302 gesture_.x = 7; | 274 gesture_.x = 7; |
303 gesture_.y = 13; | 275 gesture_.y = 13; |
304 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); | 276 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); |
305 input_handler_->HandleInputEvent(gesture_); | 277 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
306 | 278 |
307 VERIFY_AND_RESET_MOCKS(); | 279 VERIFY_AND_RESET_MOCKS(); |
308 | 280 |
309 gesture_.type = WebInputEvent::GesturePinchUpdate; | 281 gesture_.type = WebInputEvent::GesturePinchUpdate; |
310 gesture_.data.pinchUpdate.scale = 0.5; | 282 gesture_.data.pinchUpdate.scale = 0.5; |
311 gesture_.x = 9; | 283 gesture_.x = 9; |
312 gesture_.y = 6; | 284 gesture_.y = 6; |
313 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); | 285 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); |
314 input_handler_->HandleInputEvent(gesture_); | 286 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
315 | 287 |
316 VERIFY_AND_RESET_MOCKS(); | 288 VERIFY_AND_RESET_MOCKS(); |
317 | 289 |
318 gesture_.type = WebInputEvent::GesturePinchEnd; | 290 gesture_.type = WebInputEvent::GesturePinchEnd; |
319 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); | 291 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); |
320 input_handler_->HandleInputEvent(gesture_); | 292 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
321 } | 293 } |
322 | 294 |
323 TEST_F(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) { | 295 TEST_F(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) { |
324 // Scrolls will start by being sent to the main thread. | 296 // Scrolls will start by being sent to the main thread. |
325 expected_disposition_ = DidNotHandle; | 297 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
326 VERIFY_AND_RESET_MOCKS(); | 298 VERIFY_AND_RESET_MOCKS(); |
327 | 299 |
328 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) | 300 EXPECT_CALL(mock_input_handler_, ScrollBegin(::testing::_, ::testing::_)) |
329 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); | 301 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); |
330 | 302 |
331 gesture_.type = WebInputEvent::GestureScrollBegin; | 303 gesture_.type = WebInputEvent::GestureScrollBegin; |
332 input_handler_->HandleInputEvent(gesture_); | 304 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
333 | 305 |
334 VERIFY_AND_RESET_MOCKS(); | 306 VERIFY_AND_RESET_MOCKS(); |
335 | 307 |
336 gesture_.type = WebInputEvent::GestureScrollUpdate; | 308 gesture_.type = WebInputEvent::GestureScrollUpdate; |
337 gesture_.data.scrollUpdate.deltaY = 40; | 309 gesture_.data.scrollUpdate.deltaY = 40; |
338 input_handler_->HandleInputEvent(gesture_); | 310 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
339 | 311 |
340 // However, after the pinch gesture starts, they should go to the impl | 312 // However, after the pinch gesture starts, they should go to the impl |
341 // thread. | 313 // thread. |
342 expected_disposition_ = DidHandle; | 314 expected_disposition_ = InputHandlerProxy::DidHandle; |
343 VERIFY_AND_RESET_MOCKS(); | 315 VERIFY_AND_RESET_MOCKS(); |
344 | 316 |
345 gesture_.type = WebInputEvent::GesturePinchBegin; | 317 gesture_.type = WebInputEvent::GesturePinchBegin; |
346 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); | 318 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); |
347 input_handler_->HandleInputEvent(gesture_); | 319 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
348 | 320 |
349 VERIFY_AND_RESET_MOCKS(); | 321 VERIFY_AND_RESET_MOCKS(); |
350 | 322 |
351 gesture_.type = WebInputEvent::GesturePinchUpdate; | 323 gesture_.type = WebInputEvent::GesturePinchUpdate; |
352 gesture_.data.pinchUpdate.scale = 1.5; | 324 gesture_.data.pinchUpdate.scale = 1.5; |
353 gesture_.x = 7; | 325 gesture_.x = 7; |
354 gesture_.y = 13; | 326 gesture_.y = 13; |
355 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); | 327 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); |
356 input_handler_->HandleInputEvent(gesture_); | 328 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
357 | 329 |
358 VERIFY_AND_RESET_MOCKS(); | 330 VERIFY_AND_RESET_MOCKS(); |
359 | 331 |
360 gesture_.type = WebInputEvent::GestureScrollUpdate; | 332 gesture_.type = WebInputEvent::GestureScrollUpdate; |
361 gesture_.data.scrollUpdate.deltaY = | 333 gesture_.data.scrollUpdate.deltaY = |
362 -40; // -Y means scroll down - i.e. in the +Y direction. | 334 -40; // -Y means scroll down - i.e. in the +Y direction. |
363 EXPECT_CALL(mock_input_handler_, | 335 EXPECT_CALL(mock_input_handler_, |
364 ScrollBy(testing::_, | 336 ScrollBy(testing::_, |
365 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) | 337 testing::Property(&gfx::Vector2dF::y, testing::Gt(0)))) |
366 .WillOnce(testing::Return(true)); | 338 .WillOnce(testing::Return(true)); |
367 input_handler_->HandleInputEvent(gesture_); | 339 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
368 | 340 |
369 VERIFY_AND_RESET_MOCKS(); | 341 VERIFY_AND_RESET_MOCKS(); |
370 | 342 |
371 gesture_.type = WebInputEvent::GesturePinchUpdate; | 343 gesture_.type = WebInputEvent::GesturePinchUpdate; |
372 gesture_.data.pinchUpdate.scale = 0.5; | 344 gesture_.data.pinchUpdate.scale = 0.5; |
373 gesture_.x = 9; | 345 gesture_.x = 9; |
374 gesture_.y = 6; | 346 gesture_.y = 6; |
375 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); | 347 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6))); |
376 input_handler_->HandleInputEvent(gesture_); | 348 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
377 | 349 |
378 VERIFY_AND_RESET_MOCKS(); | 350 VERIFY_AND_RESET_MOCKS(); |
379 | 351 |
380 gesture_.type = WebInputEvent::GesturePinchEnd; | 352 gesture_.type = WebInputEvent::GesturePinchEnd; |
381 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); | 353 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); |
382 input_handler_->HandleInputEvent(gesture_); | 354 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
383 | 355 |
384 // After the pinch gesture ends, they should go to back to the main | 356 // After the pinch gesture ends, they should go to back to the main |
385 // thread. | 357 // thread. |
386 expected_disposition_ = DidNotHandle; | 358 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
387 VERIFY_AND_RESET_MOCKS(); | 359 VERIFY_AND_RESET_MOCKS(); |
388 | 360 |
389 gesture_.type = WebInputEvent::GestureScrollEnd; | 361 gesture_.type = WebInputEvent::GestureScrollEnd; |
390 gesture_.data.scrollUpdate.deltaY = 0; | 362 gesture_.data.scrollUpdate.deltaY = 0; |
391 input_handler_->HandleInputEvent(gesture_); | 363 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
392 } | 364 } |
393 | 365 |
394 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) { | 366 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchpad) { |
395 // We shouldn't send any events to the widget for this gesture. | 367 // We shouldn't send any events to the widget for this gesture. |
396 expected_disposition_ = DidHandle; | 368 expected_disposition_ = InputHandlerProxy::DidHandle; |
397 VERIFY_AND_RESET_MOCKS(); | 369 VERIFY_AND_RESET_MOCKS(); |
398 | 370 |
399 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 371 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
400 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 372 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
401 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 373 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
402 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 374 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
403 | 375 |
404 gesture_.type = WebInputEvent::GestureFlingStart; | 376 gesture_.type = WebInputEvent::GestureFlingStart; |
405 gesture_.data.flingStart.velocityX = 10; | 377 gesture_.data.flingStart.velocityX = 10; |
406 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 378 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
407 input_handler_->HandleInputEvent(gesture_); | 379 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
408 | 380 |
409 VERIFY_AND_RESET_MOCKS(); | 381 VERIFY_AND_RESET_MOCKS(); |
410 | 382 |
411 // Verify that a GestureFlingCancel during an animation cancels it. | 383 // Verify that a GestureFlingCancel during an animation cancels it. |
412 gesture_.type = WebInputEvent::GestureFlingCancel; | 384 gesture_.type = WebInputEvent::GestureFlingCancel; |
413 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 385 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
414 input_handler_->HandleInputEvent(gesture_); | 386 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
415 } | 387 } |
416 | 388 |
417 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) { | 389 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) { |
418 // We should send all events to the widget for this gesture. | 390 // We should send all events to the widget for this gesture. |
419 expected_disposition_ = DidNotHandle; | 391 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
420 VERIFY_AND_RESET_MOCKS(); | 392 VERIFY_AND_RESET_MOCKS(); |
421 | 393 |
422 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 394 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
423 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); | 395 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); |
424 | 396 |
425 gesture_.type = WebInputEvent::GestureFlingStart; | 397 gesture_.type = WebInputEvent::GestureFlingStart; |
426 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 398 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
427 input_handler_->HandleInputEvent(gesture_); | 399 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
428 | 400 |
429 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the | 401 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the |
430 // input handler knows it's scrolling off the impl thread | 402 // input handler knows it's scrolling off the impl thread |
431 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 403 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
432 | 404 |
433 VERIFY_AND_RESET_MOCKS(); | 405 VERIFY_AND_RESET_MOCKS(); |
434 | 406 |
435 // Even if we didn't start a fling ourselves, we still need to send the cancel | 407 // Even if we didn't start a fling ourselves, we still need to send the cancel |
436 // event to the widget. | 408 // event to the widget. |
437 gesture_.type = WebInputEvent::GestureFlingCancel; | 409 gesture_.type = WebInputEvent::GestureFlingCancel; |
438 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 410 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
439 input_handler_->HandleInputEvent(gesture_); | 411 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
440 } | 412 } |
441 | 413 |
442 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { | 414 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { |
443 expected_disposition_ = DidNotHandle; | 415 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
444 VERIFY_AND_RESET_MOCKS(); | 416 VERIFY_AND_RESET_MOCKS(); |
445 | 417 |
446 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 418 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
447 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); | 419 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); |
448 | 420 |
449 gesture_.type = WebInputEvent::GestureFlingStart; | 421 gesture_.type = WebInputEvent::GestureFlingStart; |
450 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 422 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
451 input_handler_->HandleInputEvent(gesture_); | 423 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
452 | 424 |
453 expected_disposition_ = DropEvent; | 425 expected_disposition_ = InputHandlerProxy::DropEvent; |
454 VERIFY_AND_RESET_MOCKS(); | 426 VERIFY_AND_RESET_MOCKS(); |
455 | 427 |
456 // Since the previous fling was ignored, we should also be dropping the next | 428 // Since the previous fling was ignored, we should also be dropping the next |
457 // fling_cancel. | 429 // fling_cancel. |
458 gesture_.type = WebInputEvent::GestureFlingCancel; | 430 gesture_.type = WebInputEvent::GestureFlingCancel; |
459 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 431 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
460 input_handler_->HandleInputEvent(gesture_); | 432 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
461 } | 433 } |
462 | 434 |
463 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { | 435 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { |
464 // We shouldn't send any events to the widget for this gesture. | 436 // We shouldn't send any events to the widget for this gesture. |
465 expected_disposition_ = DidHandle; | 437 expected_disposition_ = InputHandlerProxy::DidHandle; |
466 VERIFY_AND_RESET_MOCKS(); | 438 VERIFY_AND_RESET_MOCKS(); |
467 | 439 |
468 // On the fling start, we should schedule an animation but not actually start | 440 // On the fling start, we should schedule an animation but not actually start |
469 // scrolling. | 441 // scrolling. |
470 gesture_.type = WebInputEvent::GestureFlingStart; | 442 gesture_.type = WebInputEvent::GestureFlingStart; |
471 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 443 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
472 WebPoint fling_point = WebPoint(7, 13); | 444 WebPoint fling_point = WebPoint(7, 13); |
473 WebPoint fling_global_point = WebPoint(17, 23); | 445 WebPoint fling_global_point = WebPoint(17, 23); |
474 int modifiers = 7; | 446 int modifiers = 7; |
475 gesture_.data.flingStart.velocityX = fling_delta.x; | 447 gesture_.data.flingStart.velocityX = fling_delta.x; |
476 gesture_.data.flingStart.velocityY = fling_delta.y; | 448 gesture_.data.flingStart.velocityY = fling_delta.y; |
477 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 449 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
478 gesture_.x = fling_point.x; | 450 gesture_.x = fling_point.x; |
479 gesture_.y = fling_point.y; | 451 gesture_.y = fling_point.y; |
480 gesture_.globalX = fling_global_point.x; | 452 gesture_.globalX = fling_global_point.x; |
481 gesture_.globalY = fling_global_point.y; | 453 gesture_.globalY = fling_global_point.y; |
482 gesture_.modifiers = modifiers; | 454 gesture_.modifiers = modifiers; |
483 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 455 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
484 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 456 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
485 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 457 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
486 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 458 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
487 input_handler_->HandleInputEvent(gesture_); | 459 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
488 | 460 |
489 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 461 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
490 // The first animate call should let us pick up an animation start time, but | 462 // The first animate call should let us pick up an animation start time, but |
491 // we shouldn't actually move anywhere just yet. The first frame after the | 463 // we shouldn't actually move anywhere just yet. The first frame after the |
492 // fling start will typically include the last scroll from the gesture that | 464 // fling start will typically include the last scroll from the gesture that |
493 // lead to the scroll (either wheel or gesture scroll), so there should be no | 465 // lead to the scroll (either wheel or gesture scroll), so there should be no |
494 // visible hitch. | 466 // visible hitch. |
495 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 467 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
496 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 468 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
497 .Times(0); | 469 .Times(0); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 // frame being requested. | 529 // frame being requested. |
558 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).Times(0); | 530 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()).Times(0); |
559 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 531 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
560 .Times(0); | 532 .Times(0); |
561 time += base::TimeDelta::FromMilliseconds(100); | 533 time += base::TimeDelta::FromMilliseconds(100); |
562 input_handler_->Animate(time); | 534 input_handler_->Animate(time); |
563 | 535 |
564 // Since we've transferred the fling to the main thread, we need to pass the | 536 // Since we've transferred the fling to the main thread, we need to pass the |
565 // next GestureFlingCancel to the main | 537 // next GestureFlingCancel to the main |
566 // thread as well. | 538 // thread as well. |
567 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(true)); | 539 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
568 gesture_.type = WebInputEvent::GestureFlingCancel; | 540 gesture_.type = WebInputEvent::GestureFlingCancel; |
569 input_handler_->HandleInputEvent(gesture_); | 541 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
570 } | 542 } |
571 | 543 |
572 TEST_F(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { | 544 TEST_F(InputHandlerProxyTest, GestureFlingTransferResetsTouchpad) { |
573 // We shouldn't send any events to the widget for this gesture. | 545 // We shouldn't send any events to the widget for this gesture. |
574 expected_disposition_ = DidHandle; | 546 expected_disposition_ = InputHandlerProxy::DidHandle; |
575 VERIFY_AND_RESET_MOCKS(); | 547 VERIFY_AND_RESET_MOCKS(); |
576 | 548 |
577 // Start a gesture fling in the -X direction with zero Y movement. | 549 // Start a gesture fling in the -X direction with zero Y movement. |
578 gesture_.type = WebInputEvent::GestureFlingStart; | 550 gesture_.type = WebInputEvent::GestureFlingStart; |
579 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 551 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
580 WebPoint fling_point = WebPoint(7, 13); | 552 WebPoint fling_point = WebPoint(7, 13); |
581 WebPoint fling_global_point = WebPoint(17, 23); | 553 WebPoint fling_global_point = WebPoint(17, 23); |
582 int modifiers = 1; | 554 int modifiers = 1; |
583 gesture_.data.flingStart.velocityX = fling_delta.x; | 555 gesture_.data.flingStart.velocityX = fling_delta.x; |
584 gesture_.data.flingStart.velocityY = fling_delta.y; | 556 gesture_.data.flingStart.velocityY = fling_delta.y; |
585 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 557 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
586 gesture_.x = fling_point.x; | 558 gesture_.x = fling_point.x; |
587 gesture_.y = fling_point.y; | 559 gesture_.y = fling_point.y; |
588 gesture_.globalX = fling_global_point.x; | 560 gesture_.globalX = fling_global_point.x; |
589 gesture_.globalY = fling_global_point.y; | 561 gesture_.globalY = fling_global_point.y; |
590 gesture_.modifiers = modifiers; | 562 gesture_.modifiers = modifiers; |
591 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 563 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
592 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 564 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
593 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 565 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
594 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 566 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
595 input_handler_->HandleInputEvent(gesture_); | 567 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
596 | 568 |
597 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 569 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
598 | 570 |
599 // Start the fling animation at time 10. This shouldn't actually scroll, just | 571 // Start the fling animation at time 10. This shouldn't actually scroll, just |
600 // establish a start time. | 572 // establish a start time. |
601 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 573 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
602 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 574 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
603 .Times(0); | 575 .Times(0); |
604 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 576 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
605 input_handler_->Animate(time); | 577 input_handler_->Animate(time); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 638 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
667 .Times(0); | 639 .Times(0); |
668 time += base::TimeDelta::FromMilliseconds(100); | 640 time += base::TimeDelta::FromMilliseconds(100); |
669 input_handler_->Animate(time); | 641 input_handler_->Animate(time); |
670 | 642 |
671 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 643 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
672 | 644 |
673 // Since we've transferred the fling to the main thread, we need to pass the | 645 // Since we've transferred the fling to the main thread, we need to pass the |
674 // next GestureFlingCancel to the main | 646 // next GestureFlingCancel to the main |
675 // thread as well. | 647 // thread as well. |
676 EXPECT_CALL(mock_client_, DidNotHandleInputEvent(true)); | 648 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
677 gesture_.type = WebInputEvent::GestureFlingCancel; | 649 gesture_.type = WebInputEvent::GestureFlingCancel; |
678 input_handler_->HandleInputEvent(gesture_); | 650 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
679 | 651 |
680 VERIFY_AND_RESET_MOCKS(); | 652 VERIFY_AND_RESET_MOCKS(); |
681 input_handler_->MainThreadHasStoppedFlinging(); | 653 input_handler_->MainThreadHasStoppedFlinging(); |
682 | 654 |
683 // Start a second gesture fling, this time in the +Y direction with no X. | 655 // Start a second gesture fling, this time in the +Y direction with no X. |
684 gesture_.type = WebInputEvent::GestureFlingStart; | 656 gesture_.type = WebInputEvent::GestureFlingStart; |
685 fling_delta = WebFloatPoint(0, -1000); | 657 fling_delta = WebFloatPoint(0, -1000); |
686 fling_point = WebPoint(95, 87); | 658 fling_point = WebPoint(95, 87); |
687 fling_global_point = WebPoint(32, 71); | 659 fling_global_point = WebPoint(32, 71); |
688 modifiers = 2; | 660 modifiers = 2; |
689 gesture_.data.flingStart.velocityX = fling_delta.x; | 661 gesture_.data.flingStart.velocityX = fling_delta.x; |
690 gesture_.data.flingStart.velocityY = fling_delta.y; | 662 gesture_.data.flingStart.velocityY = fling_delta.y; |
691 gesture_.sourceDevice = WebGestureEvent::Touchpad; | 663 gesture_.sourceDevice = WebGestureEvent::Touchpad; |
692 gesture_.x = fling_point.x; | 664 gesture_.x = fling_point.x; |
693 gesture_.y = fling_point.y; | 665 gesture_.y = fling_point.y; |
694 gesture_.globalX = fling_global_point.x; | 666 gesture_.globalX = fling_global_point.x; |
695 gesture_.globalY = fling_global_point.y; | 667 gesture_.globalY = fling_global_point.y; |
696 gesture_.modifiers = modifiers; | 668 gesture_.modifiers = modifiers; |
697 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 669 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
698 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 670 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
699 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 671 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
700 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 672 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
701 input_handler_->HandleInputEvent(gesture_); | 673 expected_disposition_ = InputHandlerProxy::DidHandle; |
674 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | |
702 | 675 |
703 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 676 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
704 | 677 |
705 // Start the second fling animation at time 30. | 678 // Start the second fling animation at time 30. |
706 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 679 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
707 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 680 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
708 .Times(0); | 681 .Times(0); |
709 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); | 682 time = base::TimeTicks() + base::TimeDelta::FromSeconds(30); |
710 input_handler_->Animate(time); | 683 input_handler_->Animate(time); |
711 | 684 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
748 testing::Field(&WebActiveWheelFlingParameters::startTime, | 721 testing::Field(&WebActiveWheelFlingParameters::startTime, |
749 testing::Eq(30)), | 722 testing::Eq(30)), |
750 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, | 723 testing::Field(&WebActiveWheelFlingParameters::cumulativeScroll, |
751 testing::Field(&WebSize::height, testing::Lt(0)))))); | 724 testing::Field(&WebSize::height, testing::Lt(0)))))); |
752 time += base::TimeDelta::FromMilliseconds(100); | 725 time += base::TimeDelta::FromMilliseconds(100); |
753 input_handler_->Animate(time); | 726 input_handler_->Animate(time); |
754 } | 727 } |
755 | 728 |
756 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { | 729 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { |
757 // We shouldn't send any events to the widget for this gesture. | 730 // We shouldn't send any events to the widget for this gesture. |
758 expected_disposition_ = DidHandle; | 731 expected_disposition_ = InputHandlerProxy::DidHandle; |
759 VERIFY_AND_RESET_MOCKS(); | 732 VERIFY_AND_RESET_MOCKS(); |
760 | 733 |
761 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 734 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
762 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 735 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
763 gesture_.type = WebInputEvent::GestureScrollBegin; | 736 gesture_.type = WebInputEvent::GestureScrollBegin; |
764 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 737 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
765 input_handler_->HandleInputEvent(gesture_); | 738 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
766 | 739 |
767 VERIFY_AND_RESET_MOCKS(); | 740 VERIFY_AND_RESET_MOCKS(); |
768 | 741 |
769 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 742 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
770 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 743 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
771 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 744 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
772 | 745 |
773 gesture_.type = WebInputEvent::GestureFlingStart; | 746 gesture_.type = WebInputEvent::GestureFlingStart; |
774 gesture_.data.flingStart.velocityX = 10; | 747 gesture_.data.flingStart.velocityX = 10; |
775 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 748 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
776 input_handler_->HandleInputEvent(gesture_); | 749 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
777 | 750 |
778 VERIFY_AND_RESET_MOCKS(); | 751 VERIFY_AND_RESET_MOCKS(); |
779 | 752 |
780 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 753 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
781 | 754 |
782 // Verify that a GestureFlingCancel during an animation cancels it. | 755 // Verify that a GestureFlingCancel during an animation cancels it. |
783 gesture_.type = WebInputEvent::GestureFlingCancel; | 756 gesture_.type = WebInputEvent::GestureFlingCancel; |
784 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 757 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
785 input_handler_->HandleInputEvent(gesture_); | 758 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
786 } | 759 } |
787 | 760 |
788 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) { | 761 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) { |
789 // We should send all events to the widget for this gesture. | 762 // We should send all events to the widget for this gesture. |
790 expected_disposition_ = DidNotHandle; | 763 expected_disposition_ = InputHandlerProxy::DidNotHandle; |
791 VERIFY_AND_RESET_MOCKS(); | 764 VERIFY_AND_RESET_MOCKS(); |
792 | 765 |
793 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 766 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
794 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); | 767 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); |
795 | 768 |
796 gesture_.type = WebInputEvent::GestureScrollBegin; | 769 gesture_.type = WebInputEvent::GestureScrollBegin; |
797 input_handler_->HandleInputEvent(gesture_); | 770 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
798 | 771 |
799 VERIFY_AND_RESET_MOCKS(); | 772 VERIFY_AND_RESET_MOCKS(); |
800 | 773 |
801 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0); | 774 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0); |
802 | 775 |
803 gesture_.type = WebInputEvent::GestureFlingStart; | 776 gesture_.type = WebInputEvent::GestureFlingStart; |
804 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 777 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
805 input_handler_->HandleInputEvent(gesture_); | 778 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
806 | 779 |
807 VERIFY_AND_RESET_MOCKS(); | 780 VERIFY_AND_RESET_MOCKS(); |
808 | 781 |
809 // Even if we didn't start a fling ourselves, we still need to send the cancel | 782 // Even if we didn't start a fling ourselves, we still need to send the cancel |
810 // event to the widget. | 783 // event to the widget. |
811 gesture_.type = WebInputEvent::GestureFlingCancel; | 784 gesture_.type = WebInputEvent::GestureFlingCancel; |
812 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 785 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
813 input_handler_->HandleInputEvent(gesture_); | 786 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
814 } | 787 } |
815 | 788 |
816 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) { | 789 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) { |
817 expected_disposition_ = DidHandle; | 790 expected_disposition_ = InputHandlerProxy::DidHandle; |
818 VERIFY_AND_RESET_MOCKS(); | 791 VERIFY_AND_RESET_MOCKS(); |
819 | 792 |
820 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 793 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
821 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 794 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
822 | 795 |
823 gesture_.type = WebInputEvent::GestureScrollBegin; | 796 gesture_.type = WebInputEvent::GestureScrollBegin; |
824 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 797 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
825 input_handler_->HandleInputEvent(gesture_); | 798 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
826 | 799 |
827 expected_disposition_ = DropEvent; | 800 expected_disposition_ = InputHandlerProxy::DropEvent; |
828 VERIFY_AND_RESET_MOCKS(); | 801 VERIFY_AND_RESET_MOCKS(); |
829 | 802 |
830 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 803 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
831 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); | 804 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); |
832 | 805 |
833 gesture_.type = WebInputEvent::GestureFlingStart; | 806 gesture_.type = WebInputEvent::GestureFlingStart; |
834 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 807 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
835 input_handler_->HandleInputEvent(gesture_); | 808 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
836 | 809 |
837 VERIFY_AND_RESET_MOCKS(); | 810 VERIFY_AND_RESET_MOCKS(); |
838 | 811 |
839 // Even if we didn't start a fling ourselves, we still need to send the cancel | 812 // Even if we didn't start a fling ourselves, we still need to send the cancel |
840 // event to the widget. | 813 // event to the widget. |
841 gesture_.type = WebInputEvent::GestureFlingCancel; | 814 gesture_.type = WebInputEvent::GestureFlingCancel; |
842 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 815 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
843 input_handler_->HandleInputEvent(gesture_); | 816 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
844 } | 817 } |
845 | 818 |
846 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) { | 819 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) { |
847 // We shouldn't send any events to the widget for this gesture. | 820 // We shouldn't send any events to the widget for this gesture. |
848 expected_disposition_ = DidHandle; | 821 expected_disposition_ = InputHandlerProxy::DidHandle; |
849 VERIFY_AND_RESET_MOCKS(); | 822 VERIFY_AND_RESET_MOCKS(); |
850 | 823 |
851 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 824 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
852 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 825 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
853 | 826 |
854 gesture_.type = WebInputEvent::GestureScrollBegin; | 827 gesture_.type = WebInputEvent::GestureScrollBegin; |
855 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 828 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
856 input_handler_->HandleInputEvent(gesture_); | 829 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
857 | 830 |
858 VERIFY_AND_RESET_MOCKS(); | 831 VERIFY_AND_RESET_MOCKS(); |
859 | 832 |
860 // On the fling start, we should schedule an animation but not actually start | 833 // On the fling start, we should schedule an animation but not actually start |
861 // scrolling. | 834 // scrolling. |
862 gesture_.type = WebInputEvent::GestureFlingStart; | 835 gesture_.type = WebInputEvent::GestureFlingStart; |
863 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 836 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
864 WebPoint fling_point = WebPoint(7, 13); | 837 WebPoint fling_point = WebPoint(7, 13); |
865 WebPoint fling_global_point = WebPoint(17, 23); | 838 WebPoint fling_global_point = WebPoint(17, 23); |
866 int modifiers = 7; | 839 int modifiers = 7; |
867 gesture_.data.flingStart.velocityX = fling_delta.x; | 840 gesture_.data.flingStart.velocityX = fling_delta.x; |
868 gesture_.data.flingStart.velocityY = fling_delta.y; | 841 gesture_.data.flingStart.velocityY = fling_delta.y; |
869 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 842 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
870 gesture_.x = fling_point.x; | 843 gesture_.x = fling_point.x; |
871 gesture_.y = fling_point.y; | 844 gesture_.y = fling_point.y; |
872 gesture_.globalX = fling_global_point.x; | 845 gesture_.globalX = fling_global_point.x; |
873 gesture_.globalY = fling_global_point.y; | 846 gesture_.globalY = fling_global_point.y; |
874 gesture_.modifiers = modifiers; | 847 gesture_.modifiers = modifiers; |
875 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 848 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
876 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 849 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
877 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 850 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
878 input_handler_->HandleInputEvent(gesture_); | 851 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
879 | 852 |
880 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 853 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
881 // The first animate call should let us pick up an animation start time, but | 854 // The first animate call should let us pick up an animation start time, but |
882 // we shouldn't actually move anywhere just yet. The first frame after the | 855 // we shouldn't actually move anywhere just yet. The first frame after the |
883 // fling start will typically include the last scroll from the gesture that | 856 // fling start will typically include the last scroll from the gesture that |
884 // lead to the scroll (either wheel or gesture scroll), so there should be no | 857 // lead to the scroll (either wheel or gesture scroll), so there should be no |
885 // visible hitch. | 858 // visible hitch. |
886 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 859 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
887 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 860 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
888 input_handler_->Animate(time); | 861 input_handler_->Animate(time); |
889 | 862 |
890 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 863 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
891 | 864 |
892 // The second call should start scrolling in the -X direction. | 865 // The second call should start scrolling in the -X direction. |
893 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 866 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
894 EXPECT_CALL(mock_input_handler_, | 867 EXPECT_CALL(mock_input_handler_, |
895 ScrollBy(testing::_, | 868 ScrollBy(testing::_, |
896 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 869 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
897 .WillOnce(testing::Return(true)); | 870 .WillOnce(testing::Return(true)); |
898 time += base::TimeDelta::FromMilliseconds(100); | 871 time += base::TimeDelta::FromMilliseconds(100); |
899 input_handler_->Animate(time); | 872 input_handler_->Animate(time); |
900 | 873 |
901 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 874 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
902 | 875 |
903 EXPECT_CALL(mock_client_, DidHandleInputEvent()); | |
904 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 876 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
905 gesture_.type = WebInputEvent::GestureFlingCancel; | 877 gesture_.type = WebInputEvent::GestureFlingCancel; |
906 input_handler_->HandleInputEvent(gesture_); | 878 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
907 } | 879 } |
908 | 880 |
909 TEST_F(InputHandlerProxyTest, | 881 TEST_F(InputHandlerProxyTest, |
910 GestureScrollOnImplThreadFlagClearedAfterFling) { | 882 GestureScrollOnImplThreadFlagClearedAfterFling) { |
911 // We shouldn't send any events to the widget for this gesture. | 883 // We shouldn't send any events to the widget for this gesture. |
912 expected_disposition_ = DidHandle; | 884 expected_disposition_ = InputHandlerProxy::DidHandle; |
913 VERIFY_AND_RESET_MOCKS(); | 885 VERIFY_AND_RESET_MOCKS(); |
914 | 886 |
915 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | 887 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
916 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 888 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
917 | 889 |
918 gesture_.type = WebInputEvent::GestureScrollBegin; | 890 gesture_.type = WebInputEvent::GestureScrollBegin; |
919 input_handler_->HandleInputEvent(gesture_); | 891 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
920 | 892 |
921 // After sending a GestureScrollBegin, the member variable | 893 // After sending a GestureScrollBegin, the member variable |
922 // |gesture_scroll_on_impl_thread_| should be true. | 894 // |gesture_scroll_on_impl_thread_| should be true. |
923 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 895 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
924 | 896 |
925 expected_disposition_ = DidHandle; | 897 expected_disposition_ = InputHandlerProxy::DidHandle; |
926 VERIFY_AND_RESET_MOCKS(); | 898 VERIFY_AND_RESET_MOCKS(); |
927 | 899 |
928 // On the fling start, we should schedule an animation but not actually start | 900 // On the fling start, we should schedule an animation but not actually start |
929 // scrolling. | 901 // scrolling. |
930 gesture_.type = WebInputEvent::GestureFlingStart; | 902 gesture_.type = WebInputEvent::GestureFlingStart; |
931 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); | 903 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); |
932 WebPoint fling_point = WebPoint(7, 13); | 904 WebPoint fling_point = WebPoint(7, 13); |
933 WebPoint fling_global_point = WebPoint(17, 23); | 905 WebPoint fling_global_point = WebPoint(17, 23); |
934 int modifiers = 7; | 906 int modifiers = 7; |
935 gesture_.data.flingStart.velocityX = fling_delta.x; | 907 gesture_.data.flingStart.velocityX = fling_delta.x; |
936 gesture_.data.flingStart.velocityY = fling_delta.y; | 908 gesture_.data.flingStart.velocityY = fling_delta.y; |
937 gesture_.sourceDevice = WebGestureEvent::Touchscreen; | 909 gesture_.sourceDevice = WebGestureEvent::Touchscreen; |
938 gesture_.x = fling_point.x; | 910 gesture_.x = fling_point.x; |
939 gesture_.y = fling_point.y; | 911 gesture_.y = fling_point.y; |
940 gesture_.globalX = fling_global_point.x; | 912 gesture_.globalX = fling_global_point.x; |
941 gesture_.globalY = fling_global_point.y; | 913 gesture_.globalY = fling_global_point.y; |
942 gesture_.modifiers = modifiers; | 914 gesture_.modifiers = modifiers; |
943 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 915 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
944 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) | 916 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) |
945 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); | 917 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
946 input_handler_->HandleInputEvent(gesture_); | 918 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
947 | 919 |
948 // |gesture_scroll_on_impl_thread_| should still be true after | 920 // |gesture_scroll_on_impl_thread_| should still be true after |
949 // a GestureFlingStart is sent. | 921 // a GestureFlingStart is sent. |
950 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 922 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
951 | 923 |
952 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 924 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
953 // The first animate call should let us pick up an animation start time, but | 925 // The first animate call should let us pick up an animation start time, but |
954 // we shouldn't actually move anywhere just yet. The first frame after the | 926 // we shouldn't actually move anywhere just yet. The first frame after the |
955 // fling start will typically include the last scroll from the gesture that | 927 // fling start will typically include the last scroll from the gesture that |
956 // lead to the scroll (either wheel or gesture scroll), so there should be no | 928 // lead to the scroll (either wheel or gesture scroll), so there should be no |
957 // visible hitch. | 929 // visible hitch. |
958 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 930 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
959 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); | 931 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
960 input_handler_->Animate(time); | 932 input_handler_->Animate(time); |
961 | 933 |
962 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 934 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
963 | 935 |
964 // The second call should start scrolling in the -X direction. | 936 // The second call should start scrolling in the -X direction. |
965 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); | 937 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
966 EXPECT_CALL(mock_input_handler_, | 938 EXPECT_CALL(mock_input_handler_, |
967 ScrollBy(testing::_, | 939 ScrollBy(testing::_, |
968 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) | 940 testing::Property(&gfx::Vector2dF::x, testing::Lt(0)))) |
969 .WillOnce(testing::Return(true)); | 941 .WillOnce(testing::Return(true)); |
970 time += base::TimeDelta::FromMilliseconds(100); | 942 time += base::TimeDelta::FromMilliseconds(100); |
971 input_handler_->Animate(time); | 943 input_handler_->Animate(time); |
972 | 944 |
973 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 945 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
974 | 946 |
975 EXPECT_CALL(mock_client_, DidHandleInputEvent()); | |
976 EXPECT_CALL(mock_input_handler_, ScrollEnd()); | 947 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
977 gesture_.type = WebInputEvent::GestureFlingCancel; | 948 gesture_.type = WebInputEvent::GestureFlingCancel; |
978 input_handler_->HandleInputEvent(gesture_); | 949 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
979 | 950 |
980 // |gesture_scroll_on_impl_thread_| should be false once | 951 // |gesture_scroll_on_impl_thread_| should be false once |
981 // the fling has finished (note no GestureScrollEnd has been sent). | 952 // the fling has finished (note no GestureScrollEnd has been sent). |
982 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); | 953 EXPECT_TRUE(!input_handler_->gesture_scroll_on_impl_thread_for_testing()); |
983 } | 954 } |
984 | 955 |
985 TEST_F(InputHandlerProxyTest, LastInputEventForVSync) { | 956 TEST_F(InputHandlerProxyTest, LastInputEventForVSync) { |
986 expected_disposition_ = DropEvent; | 957 expected_disposition_ = InputHandlerProxy::DropEvent; |
987 VERIFY_AND_RESET_MOCKS(); | 958 VERIFY_AND_RESET_MOCKS(); |
988 | 959 |
989 gesture_.type = WebInputEvent::GestureFlingCancel; | 960 gesture_.type = WebInputEvent::GestureFlingCancel; |
990 gesture_.timeStampSeconds = 1234; | 961 gesture_.timeStampSeconds = 1234; |
991 base::TimeTicks time = | 962 base::TimeTicks time = |
992 base::TimeTicks() + | 963 base::TimeTicks() + |
993 base::TimeDelta::FromSeconds(gesture_.timeStampSeconds); | 964 base::TimeDelta::FromSeconds(gesture_.timeStampSeconds); |
994 gesture_.modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync; | 965 gesture_.modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync; |
995 EXPECT_CALL(mock_input_handler_, DidReceiveLastInputEventForBeginFrame(time)); | 966 EXPECT_CALL(mock_input_handler_, DidReceiveLastInputEventForBeginFrame(time)); |
996 input_handler_->HandleInputEvent(gesture_); | 967 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
997 } | 968 } |
998 | 969 |
999 } // namespace | 970 } // namespace |
OLD | NEW |