OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/events/event_constants.h" | 11 #include "ui/events/event_constants.h" |
12 #include "ui/events/gesture_detection/gesture_event_data.h" | 12 #include "ui/events/gesture_detection/gesture_event_data.h" |
13 #include "ui/events/gesture_detection/gesture_provider.h" | 13 #include "ui/events/gesture_detection/gesture_provider.h" |
14 #include "ui/events/gesture_detection/motion_event.h" | 14 #include "ui/events/gesture_detection/motion_event.h" |
15 #include "ui/events/test/mock_motion_event.h" | 15 #include "ui/events/test/motion_event_test_utils.h" |
16 #include "ui/gfx/geometry/point_f.h" | 16 #include "ui/gfx/geometry/point_f.h" |
17 | 17 |
18 using base::TimeDelta; | 18 using base::TimeDelta; |
19 using base::TimeTicks; | 19 using base::TimeTicks; |
20 using ui::test::MockMotionEvent; | 20 using ui::test::MockMotionEvent; |
21 | 21 |
22 namespace ui { | 22 namespace ui { |
23 namespace { | 23 namespace { |
24 | 24 |
25 const float kFakeCoordX = 42.f; | 25 const float kFakeCoordX = 42.f; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 active_scroll_begin_event_.reset(new GestureEventData(gesture)); | 136 active_scroll_begin_event_.reset(new GestureEventData(gesture)); |
137 gestures_.push_back(gesture); | 137 gestures_.push_back(gesture); |
138 } | 138 } |
139 | 139 |
140 void SetUpWithConfig(const GestureProvider::Config& config) { | 140 void SetUpWithConfig(const GestureProvider::Config& config) { |
141 gesture_provider_.reset(new GestureProvider(config, this)); | 141 gesture_provider_.reset(new GestureProvider(config, this)); |
142 gesture_provider_->SetMultiTouchZoomSupportEnabled(false); | 142 gesture_provider_->SetMultiTouchZoomSupportEnabled(false); |
143 } | 143 } |
144 | 144 |
145 void ResetGestureDetection() { | 145 void ResetGestureDetection() { |
146 CancelActiveTouchSequence(); | 146 gesture_provider_->ResetDetection(); |
147 gestures_.clear(); | 147 gestures_.clear(); |
148 } | 148 } |
| 149 |
149 bool CancelActiveTouchSequence() { | 150 bool CancelActiveTouchSequence() { |
150 if (!gesture_provider_->current_down_event()) | 151 if (!gesture_provider_->current_down_event()) |
151 return false; | 152 return false; |
152 return gesture_provider_->OnTouchEvent( | 153 return gesture_provider_->OnTouchEvent( |
153 *gesture_provider_->current_down_event()->Cancel()); | 154 *gesture_provider_->current_down_event()->Cancel()); |
154 } | 155 } |
155 | 156 |
156 bool HasReceivedGesture(EventType type) const { | 157 bool HasReceivedGesture(EventType type) const { |
157 for (size_t i = 0; i < gestures_.size(); ++i) { | 158 for (size_t i = 0; i < gestures_.size(); ++i) { |
158 if (gestures_[i].type() == type) | 159 if (gestures_[i].type() == type) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 267 } |
267 | 268 |
268 bool HasDownEvent() const { return gesture_provider_->current_down_event(); } | 269 bool HasDownEvent() const { return gesture_provider_->current_down_event(); } |
269 | 270 |
270 protected: | 271 protected: |
271 void CheckScrollEventSequenceForEndActionType( | 272 void CheckScrollEventSequenceForEndActionType( |
272 MotionEvent::Action end_action_type) { | 273 MotionEvent::Action end_action_type) { |
273 base::TimeTicks event_time = base::TimeTicks::Now(); | 274 base::TimeTicks event_time = base::TimeTicks::Now(); |
274 const float scroll_to_x = kFakeCoordX + 100; | 275 const float scroll_to_x = kFakeCoordX + 100; |
275 const float scroll_to_y = kFakeCoordY + 100; | 276 const float scroll_to_y = kFakeCoordY + 100; |
276 int motion_event_id = 0; | 277 int motion_event_id = 3; |
277 int motion_event_flags = EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN; | 278 int motion_event_flags = EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN; |
278 | 279 |
279 MockMotionEvent event = | 280 MockMotionEvent event = |
280 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 281 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
281 event.set_id(++motion_event_id); | 282 event.SetPrimaryPointerId(motion_event_id); |
282 event.set_flags(motion_event_flags); | 283 event.set_flags(motion_event_flags); |
283 | 284 |
284 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 285 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
285 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 286 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
286 | 287 |
287 event = ObtainMotionEvent(event_time + kOneSecond, | 288 event = ObtainMotionEvent(event_time + kOneSecond, |
288 MotionEvent::ACTION_MOVE, | 289 MotionEvent::ACTION_MOVE, |
289 scroll_to_x, | 290 scroll_to_x, |
290 scroll_to_y); | 291 scroll_to_y); |
291 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); | 292 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); |
292 event.set_id(++motion_event_id); | 293 event.SetPrimaryPointerId(motion_event_id); |
293 event.set_flags(motion_event_flags); | 294 event.set_flags(motion_event_flags); |
294 | 295 |
295 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 296 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
296 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); | 297 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); |
297 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); | 298 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
298 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 299 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
299 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 300 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
300 EXPECT_EQ(event.GetToolType(0), | 301 EXPECT_EQ(event.GetToolType(0), |
301 GetMostRecentGestureEvent().primary_tool_type); | 302 GetMostRecentGestureEvent().primary_tool_type); |
302 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); | 303 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); |
303 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y), | 304 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y), |
304 GetMostRecentGestureEvent().details.bounding_box()); | 305 GetMostRecentGestureEvent().details.bounding_box()); |
305 ASSERT_EQ(3U, GetReceivedGestureCount()) << "Only TapDown, " | 306 ASSERT_EQ(3U, GetReceivedGestureCount()) << "Only TapDown, " |
306 "ScrollBegin and ScrollBy " | 307 "ScrollBegin and ScrollBy " |
307 "should have been sent"; | 308 "should have been sent"; |
308 | 309 |
309 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); | 310 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); |
310 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); | 311 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); |
311 EXPECT_EQ(event_time + kOneSecond, GetReceivedGesture(1).time) | 312 EXPECT_EQ(event_time + kOneSecond, GetReceivedGesture(1).time) |
312 << "ScrollBegin should have the time of the ACTION_MOVE"; | 313 << "ScrollBegin should have the time of the ACTION_MOVE"; |
313 | 314 |
314 event = ObtainMotionEvent( | 315 event = ObtainMotionEvent( |
315 event_time + kOneSecond, end_action_type, scroll_to_x, scroll_to_y); | 316 event_time + kOneSecond, end_action_type, scroll_to_x, scroll_to_y); |
316 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); | 317 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); |
317 event.set_id(++motion_event_id); | 318 event.SetPrimaryPointerId(motion_event_id); |
318 | 319 |
319 gesture_provider_->OnTouchEvent(event); | 320 gesture_provider_->OnTouchEvent(event); |
320 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); | 321 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); |
321 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); | 322 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); |
322 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); | 323 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); |
323 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 324 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
324 EXPECT_EQ(event.GetToolType(0), | 325 EXPECT_EQ(event.GetToolType(0), |
325 GetMostRecentGestureEvent().primary_tool_type); | 326 GetMostRecentGestureEvent().primary_tool_type); |
326 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 327 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
327 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y), | 328 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y), |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 409 |
409 std::vector<GestureEventData> gestures_; | 410 std::vector<GestureEventData> gestures_; |
410 scoped_ptr<GestureProvider> gesture_provider_; | 411 scoped_ptr<GestureProvider> gesture_provider_; |
411 scoped_ptr<GestureEventData> active_scroll_begin_event_; | 412 scoped_ptr<GestureEventData> active_scroll_begin_event_; |
412 base::MessageLoopForUI message_loop_; | 413 base::MessageLoopForUI message_loop_; |
413 }; | 414 }; |
414 | 415 |
415 // Verify that a DOWN followed shortly by an UP will trigger a single tap. | 416 // Verify that a DOWN followed shortly by an UP will trigger a single tap. |
416 TEST_F(GestureProviderTest, GestureTap) { | 417 TEST_F(GestureProviderTest, GestureTap) { |
417 base::TimeTicks event_time = base::TimeTicks::Now(); | 418 base::TimeTicks event_time = base::TimeTicks::Now(); |
418 int motion_event_id = 0; | 419 int motion_event_id = 6; |
419 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN; | 420 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN; |
420 | 421 |
421 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); | 422 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); |
422 | 423 |
423 MockMotionEvent event = | 424 MockMotionEvent event = |
424 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 425 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
425 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); | 426 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); |
426 event.set_id(++motion_event_id); | 427 event.SetPrimaryPointerId(motion_event_id); |
427 event.set_flags(motion_event_flags); | 428 event.set_flags(motion_event_flags); |
428 | 429 |
429 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 430 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
430 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 431 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
431 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 432 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
432 EXPECT_EQ(event.GetToolType(0), | 433 EXPECT_EQ(event.GetToolType(0), |
433 GetMostRecentGestureEvent().primary_tool_type); | 434 GetMostRecentGestureEvent().primary_tool_type); |
434 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 435 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
435 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), | 436 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), |
436 GetMostRecentGestureEvent().details.bounding_box()); | 437 GetMostRecentGestureEvent().details.bounding_box()); |
437 | 438 |
438 event = ObtainMotionEvent(event_time + kOneMicrosecond, | 439 event = ObtainMotionEvent(event_time + kOneMicrosecond, |
439 MotionEvent::ACTION_UP); | 440 MotionEvent::ACTION_UP); |
440 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); | 441 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); |
441 event.set_id(++motion_event_id); | 442 event.SetPrimaryPointerId(motion_event_id); |
442 event.set_flags(motion_event_flags); | 443 event.set_flags(motion_event_flags); |
443 | 444 |
444 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 445 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
445 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 446 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
446 // Ensure tap details have been set. | 447 // Ensure tap details have been set. |
447 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 448 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
448 EXPECT_EQ(event.GetToolType(0), | 449 EXPECT_EQ(event.GetToolType(0), |
449 GetMostRecentGestureEvent().primary_tool_type); | 450 GetMostRecentGestureEvent().primary_tool_type); |
450 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 451 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
451 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 452 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
452 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 453 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
453 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), | 454 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), |
454 GetMostRecentGestureEvent().details.bounding_box()); | 455 GetMostRecentGestureEvent().details.bounding_box()); |
455 } | 456 } |
456 | 457 |
457 // Verify that a DOWN followed shortly by an UP will trigger | 458 // Verify that a DOWN followed shortly by an UP will trigger |
458 // a ET_GESTURE_TAP_UNCONFIRMED event if double-tap is enabled. | 459 // a ET_GESTURE_TAP_UNCONFIRMED event if double-tap is enabled. |
459 TEST_F(GestureProviderTest, GestureTapWithDelay) { | 460 TEST_F(GestureProviderTest, GestureTapWithDelay) { |
460 base::TimeTicks event_time = base::TimeTicks::Now(); | 461 base::TimeTicks event_time = base::TimeTicks::Now(); |
461 int motion_event_id = 0; | 462 int motion_event_id = 6; |
462 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN | EF_CAPS_LOCK_DOWN; | 463 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN | EF_CAPS_LOCK_DOWN; |
463 | 464 |
464 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); | 465 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); |
465 | 466 |
466 MockMotionEvent event = | 467 MockMotionEvent event = |
467 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 468 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
468 event.set_id(++motion_event_id); | 469 event.SetPrimaryPointerId(motion_event_id); |
469 event.set_flags(motion_event_flags); | 470 event.set_flags(motion_event_flags); |
470 | 471 |
471 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 472 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
472 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 473 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
473 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 474 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
474 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 475 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
475 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 476 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
476 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), | 477 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), |
477 GetMostRecentGestureEvent().details.bounding_box()); | 478 GetMostRecentGestureEvent().details.bounding_box()); |
478 | 479 |
479 event = ObtainMotionEvent(event_time + kOneMicrosecond, | 480 event = ObtainMotionEvent(event_time + kOneMicrosecond, |
480 MotionEvent::ACTION_UP); | 481 MotionEvent::ACTION_UP); |
481 event.set_id(++motion_event_id); | 482 event.SetPrimaryPointerId(motion_event_id); |
482 event.set_flags(motion_event_flags); | 483 event.set_flags(motion_event_flags); |
483 | 484 |
484 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 485 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
485 EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType()); | 486 EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType()); |
486 // Ensure tap details have been set. | 487 // Ensure tap details have been set. |
487 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 488 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
488 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 489 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
489 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 490 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
490 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 491 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
491 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), | 492 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), |
492 GetMostRecentGestureEvent().details.bounding_box()); | 493 GetMostRecentGestureEvent().details.bounding_box()); |
| 494 EXPECT_EQ(event.GetEventTime(), GetMostRecentGestureEvent().time); |
493 | 495 |
494 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_TAP)); | 496 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_TAP)); |
495 RunTasksAndWait(GetDoubleTapTimeout()); | 497 RunTasksAndWait(GetDoubleTapTimeout()); |
496 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP)); | 498 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP)); |
| 499 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
| 500 EXPECT_EQ(event.GetEventTime(), GetMostRecentGestureEvent().time); |
497 } | 501 } |
498 | 502 |
499 // Verify that a DOWN followed by a MOVE will trigger fling (but not LONG). | 503 // Verify that a DOWN followed by a MOVE will trigger fling (but not LONG). |
500 TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) { | 504 TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) { |
501 base::TimeTicks event_time = TimeTicks::Now(); | 505 base::TimeTicks event_time = TimeTicks::Now(); |
502 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; | 506 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; |
503 int motion_event_id = 0; | 507 int motion_event_id = 6; |
504 int motion_event_flags = EF_ALT_DOWN; | 508 int motion_event_flags = EF_ALT_DOWN; |
505 | 509 |
506 MockMotionEvent event = | 510 MockMotionEvent event = |
507 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 511 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
508 event.set_id(++motion_event_id); | 512 event.SetPrimaryPointerId(motion_event_id); |
509 event.set_flags(motion_event_flags); | 513 event.set_flags(motion_event_flags); |
510 | 514 |
511 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 515 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
512 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 516 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
513 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 517 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
514 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 518 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
515 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 519 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
516 | 520 |
517 event = ObtainMotionEvent(event_time + delta_time, | 521 event = ObtainMotionEvent(event_time + delta_time, |
518 MotionEvent::ACTION_MOVE, | 522 MotionEvent::ACTION_MOVE, |
519 kFakeCoordX * 10, | 523 kFakeCoordX * 10, |
520 kFakeCoordY * 10); | 524 kFakeCoordY * 10); |
521 event.set_id(++motion_event_id); | 525 event.SetPrimaryPointerId(motion_event_id); |
522 event.set_flags(motion_event_flags); | 526 event.set_flags(motion_event_flags); |
523 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 527 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
524 | 528 |
525 event = ObtainMotionEvent(event_time + delta_time * 2, | 529 event = ObtainMotionEvent(event_time + delta_time * 2, |
526 MotionEvent::ACTION_UP, | 530 MotionEvent::ACTION_UP, |
527 kFakeCoordX * 10, | 531 kFakeCoordX * 10, |
528 kFakeCoordY * 10); | 532 kFakeCoordY * 10); |
529 event.set_id(++motion_event_id); | 533 event.SetPrimaryPointerId(motion_event_id); |
530 event.set_flags(motion_event_flags); | 534 event.set_flags(motion_event_flags); |
531 | 535 |
532 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 536 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
533 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); | 537 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); |
534 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 538 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
535 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); | 539 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); |
536 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 540 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
537 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); | 541 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); |
538 EXPECT_EQ( | 542 EXPECT_EQ( |
539 BoundsForSingleMockTouchAtLocation(kFakeCoordX * 10, kFakeCoordY * 10), | 543 BoundsForSingleMockTouchAtLocation(kFakeCoordX * 10, kFakeCoordY * 10), |
(...skipping 16 matching lines...) Expand all Loading... |
556 CheckScrollEventSequenceForEndActionType(MotionEvent::ACTION_CANCEL); | 560 CheckScrollEventSequenceForEndActionType(MotionEvent::ACTION_CANCEL); |
557 } | 561 } |
558 | 562 |
559 // Verify that for a normal fling (fling after scroll) the following events are | 563 // Verify that for a normal fling (fling after scroll) the following events are |
560 // sent: | 564 // sent: |
561 // - ET_GESTURE_SCROLL_BEGIN | 565 // - ET_GESTURE_SCROLL_BEGIN |
562 // - ET_SCROLL_FLING_START | 566 // - ET_SCROLL_FLING_START |
563 TEST_F(GestureProviderTest, FlingEventSequence) { | 567 TEST_F(GestureProviderTest, FlingEventSequence) { |
564 base::TimeTicks event_time = base::TimeTicks::Now(); | 568 base::TimeTicks event_time = base::TimeTicks::Now(); |
565 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; | 569 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; |
566 int motion_event_id = 0; | 570 int motion_event_id = 6; |
567 | 571 |
568 MockMotionEvent event = | 572 MockMotionEvent event = |
569 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 573 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
570 event.set_id(++motion_event_id); | 574 event.SetPrimaryPointerId(motion_event_id); |
571 | 575 |
572 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 576 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
573 | 577 |
574 event = ObtainMotionEvent(event_time + delta_time, | 578 event = ObtainMotionEvent(event_time + delta_time, |
575 MotionEvent::ACTION_MOVE, | 579 MotionEvent::ACTION_MOVE, |
576 kFakeCoordX * 5, | 580 kFakeCoordX * 5, |
577 kFakeCoordY * 5); | 581 kFakeCoordY * 5); |
578 event.set_id(++motion_event_id); | 582 event.SetPrimaryPointerId(motion_event_id); |
579 | 583 |
580 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 584 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
581 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); | 585 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); |
582 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); | 586 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
583 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); | 587 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); |
584 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 588 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
585 ASSERT_EQ(3U, GetReceivedGestureCount()); | 589 ASSERT_EQ(3U, GetReceivedGestureCount()); |
586 ASSERT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); | 590 ASSERT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); |
587 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); | 591 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); |
588 | 592 |
589 // We don't want to take a dependency here on exactly how hints are calculated | 593 // We don't want to take a dependency here on exactly how hints are calculated |
590 // for a fling (eg. may depend on velocity), so just validate the direction. | 594 // for a fling (eg. may depend on velocity), so just validate the direction. |
591 int hint_x = GetReceivedGesture(1).details.scroll_x_hint(); | 595 int hint_x = GetReceivedGesture(1).details.scroll_x_hint(); |
592 int hint_y = GetReceivedGesture(1).details.scroll_y_hint(); | 596 int hint_y = GetReceivedGesture(1).details.scroll_y_hint(); |
593 EXPECT_TRUE(hint_x > 0 && hint_y > 0 && hint_x > hint_y) | 597 EXPECT_TRUE(hint_x > 0 && hint_y > 0 && hint_x > hint_y) |
594 << "ScrollBegin hint should be in positive X axis"; | 598 << "ScrollBegin hint should be in positive X axis"; |
595 | 599 |
596 event = ObtainMotionEvent(event_time + delta_time * 2, | 600 event = ObtainMotionEvent(event_time + delta_time * 2, |
597 MotionEvent::ACTION_UP, | 601 MotionEvent::ACTION_UP, |
598 kFakeCoordX * 10, | 602 kFakeCoordX * 10, |
599 kFakeCoordY * 10); | 603 kFakeCoordY * 10); |
600 event.set_id(++motion_event_id); | 604 event.SetPrimaryPointerId(motion_event_id); |
601 | 605 |
602 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 606 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
603 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); | 607 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); |
604 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); | 608 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); |
605 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 609 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
606 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 610 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
607 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); | 611 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); |
608 EXPECT_EQ(event_time + delta_time * 2, GetMostRecentGestureEvent().time) | 612 EXPECT_EQ(event_time + delta_time * 2, GetMostRecentGestureEvent().time) |
609 << "FlingStart should have the time of the ACTION_UP"; | 613 << "FlingStart should have the time of the ACTION_UP"; |
610 } | 614 } |
611 | 615 |
612 TEST_F(GestureProviderTest, GestureCancelledWhenWindowFocusLost) { | 616 TEST_F(GestureProviderTest, GestureCancelledOnCancelEvent) { |
613 const base::TimeTicks event_time = TimeTicks::Now(); | 617 const base::TimeTicks event_time = TimeTicks::Now(); |
614 | 618 |
615 MockMotionEvent event = | 619 MockMotionEvent event = |
616 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 620 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
617 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 621 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
618 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 622 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
619 | 623 |
620 RunTasksAndWait(GetLongPressTimeout() + GetShowPressTimeout() + | 624 RunTasksAndWait(GetLongPressTimeout() + GetShowPressTimeout() + |
621 kOneMicrosecond); | 625 kOneMicrosecond); |
622 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SHOW_PRESS)); | 626 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SHOW_PRESS)); |
623 EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType()); | 627 EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType()); |
624 | 628 |
625 // The long press triggers window focus loss by opening a context menu. | 629 // A cancellation event may be triggered for a number of reasons, e.g., |
| 630 // from a context-menu-triggering long press resulting in loss of focus. |
626 EXPECT_TRUE(CancelActiveTouchSequence()); | 631 EXPECT_TRUE(CancelActiveTouchSequence()); |
627 EXPECT_FALSE(HasDownEvent()); | 632 EXPECT_FALSE(HasDownEvent()); |
628 | 633 |
629 // A final ACTION_UP should have no effect. | 634 // A final ACTION_UP should have no effect. |
630 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, | 635 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
631 MotionEvent::ACTION_UP); | 636 MotionEvent::ACTION_UP); |
632 EXPECT_FALSE(gesture_provider_->OnTouchEvent(event)); | 637 EXPECT_FALSE(gesture_provider_->OnTouchEvent(event)); |
633 } | 638 } |
634 | 639 |
| 640 TEST_F(GestureProviderTest, GestureCancelledOnDetectionReset) { |
| 641 const base::TimeTicks event_time = TimeTicks::Now(); |
| 642 |
| 643 MockMotionEvent event = |
| 644 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
| 645 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 646 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
| 647 |
| 648 RunTasksAndWait(GetLongPressTimeout() + GetShowPressTimeout() + |
| 649 kOneMicrosecond); |
| 650 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SHOW_PRESS)); |
| 651 EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType()); |
| 652 |
| 653 ResetGestureDetection(); |
| 654 EXPECT_FALSE(HasDownEvent()); |
| 655 |
| 656 // A final ACTION_UP should have no effect. |
| 657 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
| 658 MotionEvent::ACTION_UP); |
| 659 EXPECT_FALSE(gesture_provider_->OnTouchEvent(event)); |
| 660 } |
| 661 |
635 TEST_F(GestureProviderTest, NoTapAfterScrollBegins) { | 662 TEST_F(GestureProviderTest, NoTapAfterScrollBegins) { |
636 base::TimeTicks event_time = base::TimeTicks::Now(); | 663 base::TimeTicks event_time = base::TimeTicks::Now(); |
637 | 664 |
638 MockMotionEvent event = | 665 MockMotionEvent event = |
639 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 666 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
640 | 667 |
641 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 668 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
642 | 669 |
643 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 670 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
644 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 671 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 MotionEvent::ACTION_MOVE, | 861 MotionEvent::ACTION_MOVE, |
835 kFakeCoordX, | 862 kFakeCoordX, |
836 kFakeCoordY + 100); | 863 kFakeCoordY + 100); |
837 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 864 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
838 event = ObtainMotionEvent(event_time, | 865 event = ObtainMotionEvent(event_time, |
839 MotionEvent::ACTION_MOVE); | 866 MotionEvent::ACTION_MOVE); |
840 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 867 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
841 | 868 |
842 // Now move up slowly, mostly vertically but with a (fractional) bit of | 869 // Now move up slowly, mostly vertically but with a (fractional) bit of |
843 // horizontal motion. | 870 // horizontal motion. |
844 for(int i = 1; i <= 10; i++) { | 871 for (int i = 1; i <= 10; i++) { |
845 event = ObtainMotionEvent(event_time + kOneMicrosecond * i, | 872 event = ObtainMotionEvent(event_time + kOneMicrosecond * i, |
846 MotionEvent::ACTION_MOVE, | 873 MotionEvent::ACTION_MOVE, |
847 kFakeCoordX + delta_x * i, | 874 kFakeCoordX + delta_x * i, |
848 kFakeCoordY + delta_y * i); | 875 kFakeCoordY + delta_y * i); |
849 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 876 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
850 | 877 |
851 ASSERT_LT(0U, GetReceivedGestureCount()); | 878 ASSERT_LT(0U, GetReceivedGestureCount()); |
852 GestureEventData gesture = GetMostRecentGestureEvent(); | 879 GestureEventData gesture = GetMostRecentGestureEvent(); |
853 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type()); | 880 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type()); |
854 EXPECT_EQ(event_time + kOneMicrosecond * i, gesture.time); | 881 EXPECT_EQ(event_time + kOneMicrosecond * i, gesture.time); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); | 918 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); |
892 | 919 |
893 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, | 920 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, |
894 MotionEvent::ACTION_MOVE, | 921 MotionEvent::ACTION_MOVE, |
895 kFakeCoordX + delta_x, | 922 kFakeCoordX + delta_x, |
896 kFakeCoordY + delta_y); | 923 kFakeCoordY + delta_y); |
897 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 924 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
898 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); | 925 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); |
899 | 926 |
900 const GestureEventData* scroll_begin_gesture = GetActiveScrollBeginEvent(); | 927 const GestureEventData* scroll_begin_gesture = GetActiveScrollBeginEvent(); |
901 ASSERT_TRUE(!!scroll_begin_gesture); | 928 ASSERT_TRUE(scroll_begin_gesture); |
902 EXPECT_EQ(delta_x, scroll_begin_gesture->details.scroll_x_hint()); | 929 EXPECT_EQ(delta_x, scroll_begin_gesture->details.scroll_x_hint()); |
903 EXPECT_EQ(delta_y, scroll_begin_gesture->details.scroll_y_hint()); | 930 EXPECT_EQ(delta_y, scroll_begin_gesture->details.scroll_y_hint()); |
904 } | 931 } |
905 | 932 |
906 TEST_F(GestureProviderTest, LongPressAndTapCancelledWhenScrollBegins) { | 933 TEST_F(GestureProviderTest, LongPressAndTapCancelledWhenScrollBegins) { |
907 base::TimeTicks event_time = base::TimeTicks::Now(); | 934 base::TimeTicks event_time = base::TimeTicks::Now(); |
908 | 935 |
909 MockMotionEvent event = | 936 MockMotionEvent event = |
910 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 937 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
911 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 938 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); | 1005 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
979 | 1006 |
980 event = ObtainMotionEvent(event_time + long_press_timeout, | 1007 event = ObtainMotionEvent(event_time + long_press_timeout, |
981 MotionEvent::ACTION_UP); | 1008 MotionEvent::ACTION_UP); |
982 gesture_provider_->OnTouchEvent(event); | 1009 gesture_provider_->OnTouchEvent(event); |
983 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP)); | 1010 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP)); |
984 } | 1011 } |
985 | 1012 |
986 TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) { | 1013 TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) { |
987 base::TimeTicks event_time = base::TimeTicks::Now(); | 1014 base::TimeTicks event_time = base::TimeTicks::Now(); |
988 int motion_event_id = 0; | 1015 int motion_event_id = 6; |
989 | 1016 |
990 MockMotionEvent event = ObtainMotionEvent( | 1017 MockMotionEvent event = ObtainMotionEvent( |
991 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY); | 1018 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY); |
992 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1019 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
993 | 1020 |
994 event = ObtainMotionEvent(event_time + kOneMicrosecond, | 1021 event = ObtainMotionEvent(event_time + kOneMicrosecond, |
995 MotionEvent::ACTION_UP, | 1022 MotionEvent::ACTION_UP, |
996 kFakeCoordX, | 1023 kFakeCoordX, |
997 kFakeCoordY); | 1024 kFakeCoordY); |
998 gesture_provider_->OnTouchEvent(event); | 1025 gesture_provider_->OnTouchEvent(event); |
(...skipping 12 matching lines...) Expand all Loading... |
1011 | 1038 |
1012 const base::TimeDelta long_press_timeout = | 1039 const base::TimeDelta long_press_timeout = |
1013 GetLongPressTimeout() + GetShowPressTimeout() + kOneMicrosecond; | 1040 GetLongPressTimeout() + GetShowPressTimeout() + kOneMicrosecond; |
1014 RunTasksAndWait(long_press_timeout); | 1041 RunTasksAndWait(long_press_timeout); |
1015 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); | 1042 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); |
1016 | 1043 |
1017 event = ObtainMotionEvent(event_time + long_press_timeout, | 1044 event = ObtainMotionEvent(event_time + long_press_timeout, |
1018 MotionEvent::ACTION_MOVE, | 1045 MotionEvent::ACTION_MOVE, |
1019 kFakeCoordX + 20, | 1046 kFakeCoordX + 20, |
1020 kFakeCoordY + 20); | 1047 kFakeCoordY + 20); |
1021 event.set_id(++motion_event_id); | 1048 event.SetPrimaryPointerId(motion_event_id); |
1022 | 1049 |
1023 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1050 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1024 EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType()); | 1051 EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType()); |
1025 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1052 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
1026 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1053 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
1027 EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress()); | 1054 EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress()); |
1028 | 1055 |
1029 event = ObtainMotionEvent(event_time + long_press_timeout + kOneMicrosecond, | 1056 event = ObtainMotionEvent(event_time + long_press_timeout + kOneMicrosecond, |
1030 MotionEvent::ACTION_UP, | 1057 MotionEvent::ACTION_UP, |
1031 kFakeCoordX, | 1058 kFakeCoordX, |
1032 kFakeCoordY + 1); | 1059 kFakeCoordY + 1); |
1033 event.set_id(++motion_event_id); | 1060 event.SetPrimaryPointerId(motion_event_id); |
1034 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1061 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1035 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); | 1062 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); |
1036 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1063 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
1037 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1064 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
1038 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress()); | 1065 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress()); |
1039 } | 1066 } |
1040 | 1067 |
1041 // Verify that the touch slop region is removed from the first scroll delta to | 1068 // Verify that the touch slop region is removed from the first scroll delta to |
1042 // avoid a jump when starting to scroll. | 1069 // avoid a jump when starting to scroll. |
1043 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) { | 1070 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1484 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1458 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_PINCH_END)); | 1485 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_PINCH_END)); |
1459 } | 1486 } |
1460 | 1487 |
1461 // Verify that pinch zoom sends the proper event sequence. | 1488 // Verify that pinch zoom sends the proper event sequence. |
1462 TEST_F(GestureProviderTest, PinchZoom) { | 1489 TEST_F(GestureProviderTest, PinchZoom) { |
1463 base::TimeTicks event_time = base::TimeTicks::Now(); | 1490 base::TimeTicks event_time = base::TimeTicks::Now(); |
1464 const float touch_slop = GetTouchSlop(); | 1491 const float touch_slop = GetTouchSlop(); |
1465 const float raw_offset_x = 3.2f; | 1492 const float raw_offset_x = 3.2f; |
1466 const float raw_offset_y = 4.3f; | 1493 const float raw_offset_y = 4.3f; |
1467 int motion_event_id = 0; | 1494 int motion_event_id = 6; |
1468 | 1495 |
1469 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); | 1496 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); |
1470 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); | 1497 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); |
1471 gesture_provider_->SetMultiTouchZoomSupportEnabled(true); | 1498 gesture_provider_->SetMultiTouchZoomSupportEnabled(true); |
1472 | 1499 |
1473 int secondary_coord_x = kFakeCoordX + 20 * touch_slop; | 1500 int secondary_coord_x = kFakeCoordX + 20 * touch_slop; |
1474 int secondary_coord_y = kFakeCoordY + 20 * touch_slop; | 1501 int secondary_coord_y = kFakeCoordY + 20 * touch_slop; |
1475 | 1502 |
1476 MockMotionEvent event = | 1503 MockMotionEvent event = |
1477 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 1504 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
1478 event.set_id(++motion_event_id); | 1505 event.SetPrimaryPointerId(motion_event_id); |
1479 event.SetRawOffset(raw_offset_x, raw_offset_y); | 1506 event.SetRawOffset(raw_offset_x, raw_offset_y); |
1480 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1507 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1481 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 1508 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
1482 EXPECT_EQ(kFakeCoordX, GetMostRecentGestureEvent().x); | 1509 EXPECT_EQ(kFakeCoordX, GetMostRecentGestureEvent().x); |
1483 EXPECT_EQ(kFakeCoordY, GetMostRecentGestureEvent().y); | 1510 EXPECT_EQ(kFakeCoordY, GetMostRecentGestureEvent().y); |
1484 EXPECT_EQ(kFakeCoordX + raw_offset_x, GetMostRecentGestureEvent().raw_x); | 1511 EXPECT_EQ(kFakeCoordX + raw_offset_x, GetMostRecentGestureEvent().raw_x); |
1485 EXPECT_EQ(kFakeCoordY + raw_offset_y, GetMostRecentGestureEvent().raw_y); | 1512 EXPECT_EQ(kFakeCoordY + raw_offset_y, GetMostRecentGestureEvent().raw_y); |
1486 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1513 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
1487 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), | 1514 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), |
1488 GetMostRecentGestureEvent().details.bounding_box()); | 1515 GetMostRecentGestureEvent().details.bounding_box()); |
1489 | 1516 |
1490 // Toggling double-tap support should not take effect until the next sequence. | 1517 // Toggling double-tap support should not take effect until the next sequence. |
1491 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); | 1518 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); |
1492 | 1519 |
1493 event = ObtainMotionEvent(event_time, | 1520 event = ObtainMotionEvent(event_time, |
1494 MotionEvent::ACTION_POINTER_DOWN, | 1521 MotionEvent::ACTION_POINTER_DOWN, |
1495 kFakeCoordX, | 1522 kFakeCoordX, |
1496 kFakeCoordY, | 1523 kFakeCoordY, |
1497 secondary_coord_x, | 1524 secondary_coord_x, |
1498 secondary_coord_y); | 1525 secondary_coord_y); |
1499 event.set_id(++motion_event_id); | 1526 event.SetPrimaryPointerId(motion_event_id); |
1500 event.SetRawOffset(raw_offset_x, raw_offset_y); | 1527 event.SetRawOffset(raw_offset_x, raw_offset_y); |
1501 | 1528 |
1502 gesture_provider_->OnTouchEvent(event); | 1529 gesture_provider_->OnTouchEvent(event); |
1503 EXPECT_EQ(1U, GetReceivedGestureCount()); | 1530 EXPECT_EQ(1U, GetReceivedGestureCount()); |
1504 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1531 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
1505 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), | 1532 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), |
1506 GetMostRecentGestureEvent().details.bounding_box()); | 1533 GetMostRecentGestureEvent().details.bounding_box()); |
1507 | 1534 |
1508 secondary_coord_x += 5 * touch_slop; | 1535 secondary_coord_x += 5 * touch_slop; |
1509 secondary_coord_y += 5 * touch_slop; | 1536 secondary_coord_y += 5 * touch_slop; |
1510 event = ObtainMotionEvent(event_time, | 1537 event = ObtainMotionEvent(event_time, |
1511 MotionEvent::ACTION_MOVE, | 1538 MotionEvent::ACTION_MOVE, |
1512 kFakeCoordX, | 1539 kFakeCoordX, |
1513 kFakeCoordY, | 1540 kFakeCoordY, |
1514 secondary_coord_x, | 1541 secondary_coord_x, |
1515 secondary_coord_y); | 1542 secondary_coord_y); |
1516 event.set_id(++motion_event_id); | 1543 event.SetPrimaryPointerId(motion_event_id); |
1517 event.SetRawOffset(raw_offset_x, raw_offset_y); | 1544 event.SetRawOffset(raw_offset_x, raw_offset_y); |
1518 | 1545 |
1519 // Toggling double-tap support should not take effect until the next sequence. | 1546 // Toggling double-tap support should not take effect until the next sequence. |
1520 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); | 1547 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); |
1521 | 1548 |
1522 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1549 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1523 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1550 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
1524 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1551 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
1525 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); | 1552 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); |
1526 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); | 1553 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
(...skipping 14 matching lines...) Expand all Loading... |
1541 GetMostRecentGestureEvent().details.bounding_box()); | 1568 GetMostRecentGestureEvent().details.bounding_box()); |
1542 | 1569 |
1543 secondary_coord_x += 2 * touch_slop; | 1570 secondary_coord_x += 2 * touch_slop; |
1544 secondary_coord_y += 2 * touch_slop; | 1571 secondary_coord_y += 2 * touch_slop; |
1545 event = ObtainMotionEvent(event_time, | 1572 event = ObtainMotionEvent(event_time, |
1546 MotionEvent::ACTION_MOVE, | 1573 MotionEvent::ACTION_MOVE, |
1547 kFakeCoordX, | 1574 kFakeCoordX, |
1548 kFakeCoordY, | 1575 kFakeCoordY, |
1549 secondary_coord_x, | 1576 secondary_coord_x, |
1550 secondary_coord_y); | 1577 secondary_coord_y); |
1551 event.set_id(++motion_event_id); | 1578 event.SetPrimaryPointerId(motion_event_id); |
1552 | 1579 |
1553 // Toggling double-tap support should not take effect until the next sequence. | 1580 // Toggling double-tap support should not take effect until the next sequence. |
1554 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); | 1581 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); |
1555 | 1582 |
1556 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1583 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1557 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1584 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
1558 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); | 1585 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); |
1559 EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType()); | 1586 EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType()); |
1560 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1587 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
1561 EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale()); | 1588 EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale()); |
1562 EXPECT_EQ( | 1589 EXPECT_EQ( |
1563 gfx::RectF(kFakeCoordX - kMockTouchRadius, | 1590 gfx::RectF(kFakeCoordX - kMockTouchRadius, |
1564 kFakeCoordY - kMockTouchRadius, | 1591 kFakeCoordY - kMockTouchRadius, |
1565 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, | 1592 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, |
1566 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2), | 1593 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2), |
1567 GetMostRecentGestureEvent().details.bounding_box()); | 1594 GetMostRecentGestureEvent().details.bounding_box()); |
1568 | 1595 |
1569 event = ObtainMotionEvent(event_time, | 1596 event = ObtainMotionEvent(event_time, |
1570 MotionEvent::ACTION_POINTER_UP, | 1597 MotionEvent::ACTION_POINTER_UP, |
1571 kFakeCoordX, | 1598 kFakeCoordX, |
1572 kFakeCoordY, | 1599 kFakeCoordY, |
1573 secondary_coord_x, | 1600 secondary_coord_x, |
1574 secondary_coord_y); | 1601 secondary_coord_y); |
1575 event.set_id(++motion_event_id); | 1602 event.SetPrimaryPointerId(motion_event_id); |
1576 | 1603 |
1577 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1604 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1578 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1605 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
1579 EXPECT_EQ(ET_GESTURE_PINCH_END, GetMostRecentGestureEventType()); | 1606 EXPECT_EQ(ET_GESTURE_PINCH_END, GetMostRecentGestureEventType()); |
1580 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1607 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
1581 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); | 1608 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); |
1582 EXPECT_EQ( | 1609 EXPECT_EQ( |
1583 gfx::RectF(kFakeCoordX - kMockTouchRadius, | 1610 gfx::RectF(kFakeCoordX - kMockTouchRadius, |
1584 kFakeCoordY - kMockTouchRadius, | 1611 kFakeCoordY - kMockTouchRadius, |
1585 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, | 1612 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 event = ObtainMotionEvent(event_time + long_press_timeout, | 1831 event = ObtainMotionEvent(event_time + long_press_timeout, |
1805 MotionEvent::ACTION_UP); | 1832 MotionEvent::ACTION_UP); |
1806 gesture_provider_->OnTouchEvent(event); | 1833 gesture_provider_->OnTouchEvent(event); |
1807 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP)); | 1834 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP)); |
1808 } | 1835 } |
1809 | 1836 |
1810 // Verify that inserting a touch cancel event will trigger proper touch and | 1837 // Verify that inserting a touch cancel event will trigger proper touch and |
1811 // gesture sequence cancellation. | 1838 // gesture sequence cancellation. |
1812 TEST_F(GestureProviderTest, CancelActiveTouchSequence) { | 1839 TEST_F(GestureProviderTest, CancelActiveTouchSequence) { |
1813 base::TimeTicks event_time = base::TimeTicks::Now(); | 1840 base::TimeTicks event_time = base::TimeTicks::Now(); |
1814 int motion_event_id = 0; | 1841 int motion_event_id = 6; |
1815 | 1842 |
1816 EXPECT_FALSE(CancelActiveTouchSequence()); | 1843 EXPECT_FALSE(CancelActiveTouchSequence()); |
1817 EXPECT_EQ(0U, GetReceivedGestureCount()); | 1844 EXPECT_EQ(0U, GetReceivedGestureCount()); |
1818 | 1845 |
1819 MockMotionEvent event = | 1846 MockMotionEvent event = |
1820 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 1847 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); |
1821 event.set_id(++motion_event_id); | 1848 event.SetPrimaryPointerId(motion_event_id); |
1822 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1849 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
1823 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 1850 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
1824 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1851 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
1825 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1852 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
1826 | 1853 |
1827 ASSERT_TRUE(CancelActiveTouchSequence()); | 1854 ASSERT_TRUE(CancelActiveTouchSequence()); |
1828 EXPECT_FALSE(HasDownEvent()); | 1855 EXPECT_FALSE(HasDownEvent()); |
1829 | 1856 |
1830 // Subsequent MotionEvent's are dropped until ACTION_DOWN. | 1857 // Subsequent MotionEvent's are dropped until ACTION_DOWN. |
1831 event = ObtainMotionEvent(event_time + kOneMicrosecond, | 1858 event = ObtainMotionEvent(event_time + kOneMicrosecond, |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 event = ObtainMotionEvent(event_time, | 2146 event = ObtainMotionEvent(event_time, |
2120 MotionEvent::ACTION_POINTER_UP, | 2147 MotionEvent::ACTION_POINTER_UP, |
2121 0, | 2148 0, |
2122 0, | 2149 0, |
2123 kMaxTwoFingerTapSeparation, | 2150 kMaxTwoFingerTapSeparation, |
2124 0); | 2151 0); |
2125 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2152 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
2126 | 2153 |
2127 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); | 2154 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); |
2128 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); | 2155 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); |
2129 EXPECT_EQ(ET_GESTURE_TWO_FINGER_TAP, GetReceivedGesture(2).type()); | 2156 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(2).type()); |
2130 EXPECT_EQ(3U, GetReceivedGestureCount()); | 2157 EXPECT_EQ(ET_GESTURE_TWO_FINGER_TAP, GetReceivedGesture(3).type()); |
| 2158 EXPECT_EQ(4U, GetReceivedGestureCount()); |
2131 | 2159 |
2132 EXPECT_EQ(kMockTouchRadius * 2, | 2160 EXPECT_EQ(kMockTouchRadius * 2, |
2133 GetReceivedGesture(2).details.first_finger_width()); | 2161 GetReceivedGesture(3).details.first_finger_width()); |
2134 EXPECT_EQ(kMockTouchRadius * 2, | 2162 EXPECT_EQ(kMockTouchRadius * 2, |
2135 GetReceivedGesture(2).details.first_finger_height()); | 2163 GetReceivedGesture(3).details.first_finger_height()); |
2136 } | 2164 } |
2137 | 2165 |
2138 // Test preventing a two finger tap via finger movement. | 2166 // Test preventing a two finger tap via finger movement. |
2139 TEST_F(GestureProviderTest, TwoFingerTapCancelledByFingerMovement) { | 2167 TEST_F(GestureProviderTest, TwoFingerTapCancelledByFingerMovement) { |
2140 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); | 2168 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); |
2141 const float scaled_touch_slop = GetTouchSlop(); | 2169 const float scaled_touch_slop = GetTouchSlop(); |
2142 base::TimeTicks event_time = base::TimeTicks::Now(); | 2170 base::TimeTicks event_time = base::TimeTicks::Now(); |
2143 | 2171 |
2144 MockMotionEvent event = ObtainMotionEvent( | 2172 MockMotionEvent event = ObtainMotionEvent( |
2145 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY); | 2173 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY); |
(...skipping 18 matching lines...) Expand all Loading... |
2164 event = ObtainMotionEvent(event_time, | 2192 event = ObtainMotionEvent(event_time, |
2165 MotionEvent::ACTION_POINTER_UP, | 2193 MotionEvent::ACTION_POINTER_UP, |
2166 kFakeCoordX, | 2194 kFakeCoordX, |
2167 kFakeCoordY, | 2195 kFakeCoordY, |
2168 kFakeCoordX, | 2196 kFakeCoordX, |
2169 kFakeCoordY); | 2197 kFakeCoordY); |
2170 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2198 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
2171 | 2199 |
2172 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); | 2200 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetReceivedGesture(0).type()); |
2173 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); | 2201 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); |
2174 EXPECT_EQ(2U, GetReceivedGestureCount()); | 2202 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetReceivedGesture(2).type()); |
| 2203 EXPECT_FLOAT_EQ((scaled_touch_slop + 0.1) / 2, |
| 2204 GetReceivedGesture(2).details.scroll_x()); |
| 2205 EXPECT_EQ(0, GetReceivedGesture(2).details.scroll_y()); |
| 2206 EXPECT_EQ(3U, GetReceivedGestureCount()); |
2175 } | 2207 } |
2176 | 2208 |
2177 // Test preventing a two finger tap by waiting too long before releasing the | 2209 // Test preventing a two finger tap by waiting too long before releasing the |
2178 // secondary pointer. | 2210 // secondary pointer. |
2179 TEST_F(GestureProviderTest, TwoFingerTapCancelledByDelay) { | 2211 TEST_F(GestureProviderTest, TwoFingerTapCancelledByDelay) { |
2180 base::TimeDelta two_finger_tap_timeout = kOneSecond; | 2212 base::TimeDelta two_finger_tap_timeout = kOneSecond; |
2181 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, two_finger_tap_timeout); | 2213 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, two_finger_tap_timeout); |
2182 base::TimeTicks event_time = base::TimeTicks::Now(); | 2214 base::TimeTicks event_time = base::TimeTicks::Now(); |
2183 | 2215 |
2184 MockMotionEvent event = ObtainMotionEvent( | 2216 MockMotionEvent event = ObtainMotionEvent( |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2525 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
2494 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 2526 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
2495 | 2527 |
2496 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 2528 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
2497 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 2529 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
2498 EXPECT_EQ(gfx::RectF(0, 0, 20, 20), | 2530 EXPECT_EQ(gfx::RectF(0, 0, 20, 20), |
2499 GetMostRecentGestureEvent().details.bounding_box()); | 2531 GetMostRecentGestureEvent().details.bounding_box()); |
2500 } | 2532 } |
2501 | 2533 |
2502 } // namespace ui | 2534 } // namespace ui |
OLD | NEW |