Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 bool HasDownEvent() const { return gesture_provider_->current_down_event(); } 269 bool HasDownEvent() const { return gesture_provider_->current_down_event(); }
270 270
271 protected: 271 protected:
272 void CheckScrollEventSequenceForEndActionType( 272 void CheckScrollEventSequenceForEndActionType(
273 MotionEvent::Action end_action_type) { 273 MotionEvent::Action end_action_type) {
274 base::TimeTicks event_time = base::TimeTicks::Now(); 274 base::TimeTicks event_time = base::TimeTicks::Now();
275 const float scroll_to_x = kFakeCoordX + 100; 275 const float scroll_to_x = kFakeCoordX + 100;
276 const float scroll_to_y = kFakeCoordY + 100; 276 const float scroll_to_y = kFakeCoordY + 100;
277 int motion_event_id = 0; 277 int motion_event_id = 3;
278 int motion_event_flags = EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN; 278 int motion_event_flags = EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN;
279 279
280 MockMotionEvent event = 280 MockMotionEvent event =
281 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 281 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
282 event.set_id(++motion_event_id); 282 event.SetPrimaryPointerId(motion_event_id);
283 event.set_flags(motion_event_flags); 283 event.set_flags(motion_event_flags);
284 284
285 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 285 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
286 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 286 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
287 287
288 event = ObtainMotionEvent(event_time + kOneSecond, 288 event = ObtainMotionEvent(event_time + kOneSecond,
289 MotionEvent::ACTION_MOVE, 289 MotionEvent::ACTION_MOVE,
290 scroll_to_x, 290 scroll_to_x,
291 scroll_to_y); 291 scroll_to_y);
292 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); 292 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER);
293 event.set_id(++motion_event_id); 293 event.SetPrimaryPointerId(motion_event_id);
294 event.set_flags(motion_event_flags); 294 event.set_flags(motion_event_flags);
295 295
296 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 296 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
297 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); 297 EXPECT_TRUE(gesture_provider_->IsScrollInProgress());
298 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); 298 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
299 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 299 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
300 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 300 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
301 EXPECT_EQ(event.GetToolType(0), 301 EXPECT_EQ(event.GetToolType(0),
302 GetMostRecentGestureEvent().primary_tool_type); 302 GetMostRecentGestureEvent().primary_tool_type);
303 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); 303 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
304 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y), 304 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(scroll_to_x, scroll_to_y),
305 GetMostRecentGestureEvent().details.bounding_box()); 305 GetMostRecentGestureEvent().details.bounding_box());
306 ASSERT_EQ(3U, GetReceivedGestureCount()) << "Only TapDown, " 306 ASSERT_EQ(3U, GetReceivedGestureCount()) << "Only TapDown, "
307 "ScrollBegin and ScrollBy " 307 "ScrollBegin and ScrollBy "
308 "should have been sent"; 308 "should have been sent";
309 309
310 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); 310 EXPECT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type());
311 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); 311 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id);
312 EXPECT_EQ(event_time + kOneSecond, GetReceivedGesture(1).time) 312 EXPECT_EQ(event_time + kOneSecond, GetReceivedGesture(1).time)
313 << "ScrollBegin should have the time of the ACTION_MOVE"; 313 << "ScrollBegin should have the time of the ACTION_MOVE";
314 314
315 event = ObtainMotionEvent( 315 event = ObtainMotionEvent(
316 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);
317 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); 317 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER);
318 event.set_id(++motion_event_id); 318 event.SetPrimaryPointerId(motion_event_id);
319 319
320 gesture_provider_->OnTouchEvent(event); 320 gesture_provider_->OnTouchEvent(event);
321 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); 321 EXPECT_FALSE(gesture_provider_->IsScrollInProgress());
322 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); 322 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
323 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); 323 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
324 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 324 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
325 EXPECT_EQ(event.GetToolType(0), 325 EXPECT_EQ(event.GetToolType(0),
326 GetMostRecentGestureEvent().primary_tool_type); 326 GetMostRecentGestureEvent().primary_tool_type);
327 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 327 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
328 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
409 409
410 std::vector<GestureEventData> gestures_; 410 std::vector<GestureEventData> gestures_;
411 scoped_ptr<GestureProvider> gesture_provider_; 411 scoped_ptr<GestureProvider> gesture_provider_;
412 scoped_ptr<GestureEventData> active_scroll_begin_event_; 412 scoped_ptr<GestureEventData> active_scroll_begin_event_;
413 base::MessageLoopForUI message_loop_; 413 base::MessageLoopForUI message_loop_;
414 }; 414 };
415 415
416 // 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.
417 TEST_F(GestureProviderTest, GestureTap) { 417 TEST_F(GestureProviderTest, GestureTap) {
418 base::TimeTicks event_time = base::TimeTicks::Now(); 418 base::TimeTicks event_time = base::TimeTicks::Now();
419 int motion_event_id = 0; 419 int motion_event_id = 6;
420 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN; 420 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN;
421 421
422 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); 422 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
423 423
424 MockMotionEvent event = 424 MockMotionEvent event =
425 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 425 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
426 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); 426 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER);
427 event.set_id(++motion_event_id); 427 event.SetPrimaryPointerId(motion_event_id);
428 event.set_flags(motion_event_flags); 428 event.set_flags(motion_event_flags);
429 429
430 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 430 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
431 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 431 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
432 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 432 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
433 EXPECT_EQ(event.GetToolType(0), 433 EXPECT_EQ(event.GetToolType(0),
434 GetMostRecentGestureEvent().primary_tool_type); 434 GetMostRecentGestureEvent().primary_tool_type);
435 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 435 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
436 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 436 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
437 GetMostRecentGestureEvent().details.bounding_box()); 437 GetMostRecentGestureEvent().details.bounding_box());
438 438
439 event = ObtainMotionEvent(event_time + kOneMicrosecond, 439 event = ObtainMotionEvent(event_time + kOneMicrosecond,
440 MotionEvent::ACTION_UP); 440 MotionEvent::ACTION_UP);
441 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER); 441 event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER);
442 event.set_id(++motion_event_id); 442 event.SetPrimaryPointerId(motion_event_id);
443 event.set_flags(motion_event_flags); 443 event.set_flags(motion_event_flags);
444 444
445 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 445 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
446 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); 446 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
447 // Ensure tap details have been set. 447 // Ensure tap details have been set.
448 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); 448 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
449 EXPECT_EQ(event.GetToolType(0), 449 EXPECT_EQ(event.GetToolType(0),
450 GetMostRecentGestureEvent().primary_tool_type); 450 GetMostRecentGestureEvent().primary_tool_type);
451 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 451 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
452 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 452 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
453 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 453 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
454 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 454 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
455 GetMostRecentGestureEvent().details.bounding_box()); 455 GetMostRecentGestureEvent().details.bounding_box());
456 } 456 }
457 457
458 // Verify that a DOWN followed shortly by an UP will trigger 458 // Verify that a DOWN followed shortly by an UP will trigger
459 // a ET_GESTURE_TAP_UNCONFIRMED event if double-tap is enabled. 459 // a ET_GESTURE_TAP_UNCONFIRMED event if double-tap is enabled.
460 TEST_F(GestureProviderTest, GestureTapWithDelay) { 460 TEST_F(GestureProviderTest, GestureTapWithDelay) {
461 base::TimeTicks event_time = base::TimeTicks::Now(); 461 base::TimeTicks event_time = base::TimeTicks::Now();
462 int motion_event_id = 0; 462 int motion_event_id = 6;
463 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;
464 464
465 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); 465 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true);
466 466
467 MockMotionEvent event = 467 MockMotionEvent event =
468 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 468 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
469 event.set_id(++motion_event_id); 469 event.SetPrimaryPointerId(motion_event_id);
470 event.set_flags(motion_event_flags); 470 event.set_flags(motion_event_flags);
471 471
472 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 472 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
473 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 473 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
474 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 474 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
475 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 475 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
476 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 476 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
477 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 477 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
478 GetMostRecentGestureEvent().details.bounding_box()); 478 GetMostRecentGestureEvent().details.bounding_box());
479 479
480 event = ObtainMotionEvent(event_time + kOneMicrosecond, 480 event = ObtainMotionEvent(event_time + kOneMicrosecond,
481 MotionEvent::ACTION_UP); 481 MotionEvent::ACTION_UP);
482 event.set_id(++motion_event_id); 482 event.SetPrimaryPointerId(motion_event_id);
483 event.set_flags(motion_event_flags); 483 event.set_flags(motion_event_flags);
484 484
485 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 485 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
486 EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType()); 486 EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType());
487 // Ensure tap details have been set. 487 // Ensure tap details have been set.
488 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); 488 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
489 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 489 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
490 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 490 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
491 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 491 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
492 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 492 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
493 GetMostRecentGestureEvent().details.bounding_box()); 493 GetMostRecentGestureEvent().details.bounding_box());
494 EXPECT_EQ(event.GetEventTime(), GetMostRecentGestureEvent().time); 494 EXPECT_EQ(event.GetEventTime(), GetMostRecentGestureEvent().time);
495 495
496 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_TAP)); 496 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_TAP));
497 RunTasksAndWait(GetDoubleTapTimeout()); 497 RunTasksAndWait(GetDoubleTapTimeout());
498 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP)); 498 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP));
499 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 499 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
500 EXPECT_EQ(event.GetEventTime(), GetMostRecentGestureEvent().time); 500 EXPECT_EQ(event.GetEventTime(), GetMostRecentGestureEvent().time);
501 } 501 }
502 502
503 // 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).
504 TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) { 504 TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {
505 base::TimeTicks event_time = TimeTicks::Now(); 505 base::TimeTicks event_time = TimeTicks::Now();
506 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; 506 base::TimeDelta delta_time = kDeltaTimeForFlingSequences;
507 int motion_event_id = 0; 507 int motion_event_id = 6;
508 int motion_event_flags = EF_ALT_DOWN; 508 int motion_event_flags = EF_ALT_DOWN;
509 509
510 MockMotionEvent event = 510 MockMotionEvent event =
511 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 511 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
512 event.set_id(++motion_event_id); 512 event.SetPrimaryPointerId(motion_event_id);
513 event.set_flags(motion_event_flags); 513 event.set_flags(motion_event_flags);
514 514
515 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 515 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
516 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 516 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
517 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 517 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
518 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 518 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
519 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 519 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
520 520
521 event = ObtainMotionEvent(event_time + delta_time, 521 event = ObtainMotionEvent(event_time + delta_time,
522 MotionEvent::ACTION_MOVE, 522 MotionEvent::ACTION_MOVE,
523 kFakeCoordX * 10, 523 kFakeCoordX * 10,
524 kFakeCoordY * 10); 524 kFakeCoordY * 10);
525 event.set_id(++motion_event_id); 525 event.SetPrimaryPointerId(motion_event_id);
526 event.set_flags(motion_event_flags); 526 event.set_flags(motion_event_flags);
527 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 527 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
528 528
529 event = ObtainMotionEvent(event_time + delta_time * 2, 529 event = ObtainMotionEvent(event_time + delta_time * 2,
530 MotionEvent::ACTION_UP, 530 MotionEvent::ACTION_UP,
531 kFakeCoordX * 10, 531 kFakeCoordX * 10,
532 kFakeCoordY * 10); 532 kFakeCoordY * 10);
533 event.set_id(++motion_event_id); 533 event.SetPrimaryPointerId(motion_event_id);
534 event.set_flags(motion_event_flags); 534 event.set_flags(motion_event_flags);
535 535
536 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 536 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
537 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); 537 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType());
538 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 538 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
539 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags); 539 EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
540 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 540 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
541 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); 541 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS));
542 EXPECT_EQ( 542 EXPECT_EQ(
543 BoundsForSingleMockTouchAtLocation(kFakeCoordX * 10, kFakeCoordY * 10), 543 BoundsForSingleMockTouchAtLocation(kFakeCoordX * 10, kFakeCoordY * 10),
(...skipping 16 matching lines...) Expand all
560 CheckScrollEventSequenceForEndActionType(MotionEvent::ACTION_CANCEL); 560 CheckScrollEventSequenceForEndActionType(MotionEvent::ACTION_CANCEL);
561 } 561 }
562 562
563 // 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
564 // sent: 564 // sent:
565 // - ET_GESTURE_SCROLL_BEGIN 565 // - ET_GESTURE_SCROLL_BEGIN
566 // - ET_SCROLL_FLING_START 566 // - ET_SCROLL_FLING_START
567 TEST_F(GestureProviderTest, FlingEventSequence) { 567 TEST_F(GestureProviderTest, FlingEventSequence) {
568 base::TimeTicks event_time = base::TimeTicks::Now(); 568 base::TimeTicks event_time = base::TimeTicks::Now();
569 base::TimeDelta delta_time = kDeltaTimeForFlingSequences; 569 base::TimeDelta delta_time = kDeltaTimeForFlingSequences;
570 int motion_event_id = 0; 570 int motion_event_id = 6;
571 571
572 MockMotionEvent event = 572 MockMotionEvent event =
573 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 573 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
574 event.set_id(++motion_event_id); 574 event.SetPrimaryPointerId(motion_event_id);
575 575
576 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 576 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
577 577
578 event = ObtainMotionEvent(event_time + delta_time, 578 event = ObtainMotionEvent(event_time + delta_time,
579 MotionEvent::ACTION_MOVE, 579 MotionEvent::ACTION_MOVE,
580 kFakeCoordX * 5, 580 kFakeCoordX * 5,
581 kFakeCoordY * 5); 581 kFakeCoordY * 5);
582 event.set_id(++motion_event_id); 582 event.SetPrimaryPointerId(motion_event_id);
583 583
584 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 584 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
585 EXPECT_TRUE(gesture_provider_->IsScrollInProgress()); 585 EXPECT_TRUE(gesture_provider_->IsScrollInProgress());
586 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); 586 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
587 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType()); 587 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
588 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 588 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
589 ASSERT_EQ(3U, GetReceivedGestureCount()); 589 ASSERT_EQ(3U, GetReceivedGestureCount());
590 ASSERT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type()); 590 ASSERT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(1).type());
591 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id); 591 EXPECT_EQ(motion_event_id, GetReceivedGesture(1).motion_event_id);
592 592
593 // 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
594 // 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.
595 int hint_x = GetReceivedGesture(1).details.scroll_x_hint(); 595 int hint_x = GetReceivedGesture(1).details.scroll_x_hint();
596 int hint_y = GetReceivedGesture(1).details.scroll_y_hint(); 596 int hint_y = GetReceivedGesture(1).details.scroll_y_hint();
597 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)
598 << "ScrollBegin hint should be in positive X axis"; 598 << "ScrollBegin hint should be in positive X axis";
599 599
600 event = ObtainMotionEvent(event_time + delta_time * 2, 600 event = ObtainMotionEvent(event_time + delta_time * 2,
601 MotionEvent::ACTION_UP, 601 MotionEvent::ACTION_UP,
602 kFakeCoordX * 10, 602 kFakeCoordX * 10,
603 kFakeCoordY * 10); 603 kFakeCoordY * 10);
604 event.set_id(++motion_event_id); 604 event.SetPrimaryPointerId(motion_event_id);
605 605
606 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 606 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
607 EXPECT_FALSE(gesture_provider_->IsScrollInProgress()); 607 EXPECT_FALSE(gesture_provider_->IsScrollInProgress());
608 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType()); 608 EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType());
609 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 609 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
610 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 610 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
611 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); 611 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
612 EXPECT_EQ(event_time + delta_time * 2, GetMostRecentGestureEvent().time) 612 EXPECT_EQ(event_time + delta_time * 2, GetMostRecentGestureEvent().time)
613 << "FlingStart should have the time of the ACTION_UP"; 613 << "FlingStart should have the time of the ACTION_UP";
614 } 614 }
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); 1005 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
1006 1006
1007 event = ObtainMotionEvent(event_time + long_press_timeout, 1007 event = ObtainMotionEvent(event_time + long_press_timeout,
1008 MotionEvent::ACTION_UP); 1008 MotionEvent::ACTION_UP);
1009 gesture_provider_->OnTouchEvent(event); 1009 gesture_provider_->OnTouchEvent(event);
1010 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP)); 1010 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP));
1011 } 1011 }
1012 1012
1013 TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) { 1013 TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {
1014 base::TimeTicks event_time = base::TimeTicks::Now(); 1014 base::TimeTicks event_time = base::TimeTicks::Now();
1015 int motion_event_id = 0; 1015 int motion_event_id = 6;
1016 1016
1017 MockMotionEvent event = ObtainMotionEvent( 1017 MockMotionEvent event = ObtainMotionEvent(
1018 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY); 1018 event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY);
1019 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1019 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1020 1020
1021 event = ObtainMotionEvent(event_time + kOneMicrosecond, 1021 event = ObtainMotionEvent(event_time + kOneMicrosecond,
1022 MotionEvent::ACTION_UP, 1022 MotionEvent::ACTION_UP,
1023 kFakeCoordX, 1023 kFakeCoordX,
1024 kFakeCoordY); 1024 kFakeCoordY);
1025 gesture_provider_->OnTouchEvent(event); 1025 gesture_provider_->OnTouchEvent(event);
(...skipping 12 matching lines...) Expand all
1038 1038
1039 const base::TimeDelta long_press_timeout = 1039 const base::TimeDelta long_press_timeout =
1040 GetLongPressTimeout() + GetShowPressTimeout() + kOneMicrosecond; 1040 GetLongPressTimeout() + GetShowPressTimeout() + kOneMicrosecond;
1041 RunTasksAndWait(long_press_timeout); 1041 RunTasksAndWait(long_press_timeout);
1042 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS)); 1042 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS));
1043 1043
1044 event = ObtainMotionEvent(event_time + long_press_timeout, 1044 event = ObtainMotionEvent(event_time + long_press_timeout,
1045 MotionEvent::ACTION_MOVE, 1045 MotionEvent::ACTION_MOVE,
1046 kFakeCoordX + 20, 1046 kFakeCoordX + 20,
1047 kFakeCoordY + 20); 1047 kFakeCoordY + 20);
1048 event.set_id(++motion_event_id); 1048 event.SetPrimaryPointerId(motion_event_id);
1049 1049
1050 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1050 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1051 EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType()); 1051 EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType());
1052 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1052 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1053 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1053 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1054 EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress()); 1054 EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress());
1055 1055
1056 event = ObtainMotionEvent(event_time + long_press_timeout + kOneMicrosecond, 1056 event = ObtainMotionEvent(event_time + long_press_timeout + kOneMicrosecond,
1057 MotionEvent::ACTION_UP, 1057 MotionEvent::ACTION_UP,
1058 kFakeCoordX, 1058 kFakeCoordX,
1059 kFakeCoordY + 1); 1059 kFakeCoordY + 1);
1060 event.set_id(++motion_event_id); 1060 event.SetPrimaryPointerId(motion_event_id);
1061 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1061 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1062 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType()); 1062 EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
1063 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1063 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1064 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1064 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1065 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress()); 1065 EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress());
1066 } 1066 }
1067 1067
1068 // 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
1069 // avoid a jump when starting to scroll. 1069 // avoid a jump when starting to scroll.
1070 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) { 1070 TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1484 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1485 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_PINCH_END)); 1485 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_PINCH_END));
1486 } 1486 }
1487 1487
1488 // Verify that pinch zoom sends the proper event sequence. 1488 // Verify that pinch zoom sends the proper event sequence.
1489 TEST_F(GestureProviderTest, PinchZoom) { 1489 TEST_F(GestureProviderTest, PinchZoom) {
1490 base::TimeTicks event_time = base::TimeTicks::Now(); 1490 base::TimeTicks event_time = base::TimeTicks::Now();
1491 const float touch_slop = GetTouchSlop(); 1491 const float touch_slop = GetTouchSlop();
1492 const float raw_offset_x = 3.2f; 1492 const float raw_offset_x = 3.2f;
1493 const float raw_offset_y = 4.3f; 1493 const float raw_offset_y = 4.3f;
1494 int motion_event_id = 0; 1494 int motion_event_id = 6;
1495 1495
1496 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); 1496 gesture_provider_->SetDoubleTapSupportForPageEnabled(false);
1497 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true); 1497 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true);
1498 gesture_provider_->SetMultiTouchZoomSupportEnabled(true); 1498 gesture_provider_->SetMultiTouchZoomSupportEnabled(true);
1499 1499
1500 int secondary_coord_x = kFakeCoordX + 20 * touch_slop; 1500 int secondary_coord_x = kFakeCoordX + 20 * touch_slop;
1501 int secondary_coord_y = kFakeCoordY + 20 * touch_slop; 1501 int secondary_coord_y = kFakeCoordY + 20 * touch_slop;
1502 1502
1503 MockMotionEvent event = 1503 MockMotionEvent event =
1504 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 1504 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
1505 event.set_id(++motion_event_id); 1505 event.SetPrimaryPointerId(motion_event_id);
1506 event.SetRawOffset(raw_offset_x, raw_offset_y); 1506 event.SetRawOffset(raw_offset_x, raw_offset_y);
1507 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1507 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1508 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1508 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1509 EXPECT_EQ(kFakeCoordX, GetMostRecentGestureEvent().x); 1509 EXPECT_EQ(kFakeCoordX, GetMostRecentGestureEvent().x);
1510 EXPECT_EQ(kFakeCoordY, GetMostRecentGestureEvent().y); 1510 EXPECT_EQ(kFakeCoordY, GetMostRecentGestureEvent().y);
1511 EXPECT_EQ(kFakeCoordX + raw_offset_x, GetMostRecentGestureEvent().raw_x); 1511 EXPECT_EQ(kFakeCoordX + raw_offset_x, GetMostRecentGestureEvent().raw_x);
1512 EXPECT_EQ(kFakeCoordY + raw_offset_y, GetMostRecentGestureEvent().raw_y); 1512 EXPECT_EQ(kFakeCoordY + raw_offset_y, GetMostRecentGestureEvent().raw_y);
1513 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1513 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1514 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 1514 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
1515 GetMostRecentGestureEvent().details.bounding_box()); 1515 GetMostRecentGestureEvent().details.bounding_box());
1516 1516
1517 // 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.
1518 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); 1518 gesture_provider_->SetDoubleTapSupportForPageEnabled(true);
1519 1519
1520 event = ObtainMotionEvent(event_time, 1520 event = ObtainMotionEvent(event_time,
1521 MotionEvent::ACTION_POINTER_DOWN, 1521 MotionEvent::ACTION_POINTER_DOWN,
1522 kFakeCoordX, 1522 kFakeCoordX,
1523 kFakeCoordY, 1523 kFakeCoordY,
1524 secondary_coord_x, 1524 secondary_coord_x,
1525 secondary_coord_y); 1525 secondary_coord_y);
1526 event.set_id(++motion_event_id); 1526 event.SetPrimaryPointerId(motion_event_id);
1527 event.SetRawOffset(raw_offset_x, raw_offset_y); 1527 event.SetRawOffset(raw_offset_x, raw_offset_y);
1528 1528
1529 gesture_provider_->OnTouchEvent(event); 1529 gesture_provider_->OnTouchEvent(event);
1530 EXPECT_EQ(1U, GetReceivedGestureCount()); 1530 EXPECT_EQ(1U, GetReceivedGestureCount());
1531 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1531 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1532 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY), 1532 EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
1533 GetMostRecentGestureEvent().details.bounding_box()); 1533 GetMostRecentGestureEvent().details.bounding_box());
1534 1534
1535 secondary_coord_x += 5 * touch_slop; 1535 secondary_coord_x += 5 * touch_slop;
1536 secondary_coord_y += 5 * touch_slop; 1536 secondary_coord_y += 5 * touch_slop;
1537 event = ObtainMotionEvent(event_time, 1537 event = ObtainMotionEvent(event_time,
1538 MotionEvent::ACTION_MOVE, 1538 MotionEvent::ACTION_MOVE,
1539 kFakeCoordX, 1539 kFakeCoordX,
1540 kFakeCoordY, 1540 kFakeCoordY,
1541 secondary_coord_x, 1541 secondary_coord_x,
1542 secondary_coord_y); 1542 secondary_coord_y);
1543 event.set_id(++motion_event_id); 1543 event.SetPrimaryPointerId(motion_event_id);
1544 event.SetRawOffset(raw_offset_x, raw_offset_y); 1544 event.SetRawOffset(raw_offset_x, raw_offset_y);
1545 1545
1546 // 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.
1547 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); 1547 gesture_provider_->SetDoubleTapSupportForPageEnabled(false);
1548 1548
1549 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1549 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1550 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1550 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1551 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1551 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1552 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); 1552 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN));
1553 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); 1553 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
(...skipping 14 matching lines...) Expand all
1568 GetMostRecentGestureEvent().details.bounding_box()); 1568 GetMostRecentGestureEvent().details.bounding_box());
1569 1569
1570 secondary_coord_x += 2 * touch_slop; 1570 secondary_coord_x += 2 * touch_slop;
1571 secondary_coord_y += 2 * touch_slop; 1571 secondary_coord_y += 2 * touch_slop;
1572 event = ObtainMotionEvent(event_time, 1572 event = ObtainMotionEvent(event_time,
1573 MotionEvent::ACTION_MOVE, 1573 MotionEvent::ACTION_MOVE,
1574 kFakeCoordX, 1574 kFakeCoordX,
1575 kFakeCoordY, 1575 kFakeCoordY,
1576 secondary_coord_x, 1576 secondary_coord_x,
1577 secondary_coord_y); 1577 secondary_coord_y);
1578 event.set_id(++motion_event_id); 1578 event.SetPrimaryPointerId(motion_event_id);
1579 1579
1580 // 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.
1581 gesture_provider_->SetDoubleTapSupportForPageEnabled(true); 1581 gesture_provider_->SetDoubleTapSupportForPageEnabled(true);
1582 1582
1583 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1583 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1584 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1584 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1585 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); 1585 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE));
1586 EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType()); 1586 EXPECT_EQ(ET_GESTURE_PINCH_UPDATE, GetMostRecentGestureEventType());
1587 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1587 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1588 EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale()); 1588 EXPECT_LT(1.f, GetMostRecentGestureEvent().details.scale());
1589 EXPECT_EQ( 1589 EXPECT_EQ(
1590 gfx::RectF(kFakeCoordX - kMockTouchRadius, 1590 gfx::RectF(kFakeCoordX - kMockTouchRadius,
1591 kFakeCoordY - kMockTouchRadius, 1591 kFakeCoordY - kMockTouchRadius,
1592 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, 1592 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2,
1593 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2), 1593 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2),
1594 GetMostRecentGestureEvent().details.bounding_box()); 1594 GetMostRecentGestureEvent().details.bounding_box());
1595 1595
1596 event = ObtainMotionEvent(event_time, 1596 event = ObtainMotionEvent(event_time,
1597 MotionEvent::ACTION_POINTER_UP, 1597 MotionEvent::ACTION_POINTER_UP,
1598 kFakeCoordX, 1598 kFakeCoordX,
1599 kFakeCoordY, 1599 kFakeCoordY,
1600 secondary_coord_x, 1600 secondary_coord_x,
1601 secondary_coord_y); 1601 secondary_coord_y);
1602 event.set_id(++motion_event_id); 1602 event.SetPrimaryPointerId(motion_event_id);
1603 1603
1604 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1604 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1605 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1605 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1606 EXPECT_EQ(ET_GESTURE_PINCH_END, GetMostRecentGestureEventType()); 1606 EXPECT_EQ(ET_GESTURE_PINCH_END, GetMostRecentGestureEventType());
1607 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); 1607 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
1608 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END)); 1608 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
1609 EXPECT_EQ( 1609 EXPECT_EQ(
1610 gfx::RectF(kFakeCoordX - kMockTouchRadius, 1610 gfx::RectF(kFakeCoordX - kMockTouchRadius,
1611 kFakeCoordY - kMockTouchRadius, 1611 kFakeCoordY - kMockTouchRadius,
1612 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
1831 event = ObtainMotionEvent(event_time + long_press_timeout, 1831 event = ObtainMotionEvent(event_time + long_press_timeout,
1832 MotionEvent::ACTION_UP); 1832 MotionEvent::ACTION_UP);
1833 gesture_provider_->OnTouchEvent(event); 1833 gesture_provider_->OnTouchEvent(event);
1834 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP)); 1834 EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP));
1835 } 1835 }
1836 1836
1837 // 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
1838 // gesture sequence cancellation. 1838 // gesture sequence cancellation.
1839 TEST_F(GestureProviderTest, CancelActiveTouchSequence) { 1839 TEST_F(GestureProviderTest, CancelActiveTouchSequence) {
1840 base::TimeTicks event_time = base::TimeTicks::Now(); 1840 base::TimeTicks event_time = base::TimeTicks::Now();
1841 int motion_event_id = 0; 1841 int motion_event_id = 6;
1842 1842
1843 EXPECT_FALSE(CancelActiveTouchSequence()); 1843 EXPECT_FALSE(CancelActiveTouchSequence());
1844 EXPECT_EQ(0U, GetReceivedGestureCount()); 1844 EXPECT_EQ(0U, GetReceivedGestureCount());
1845 1845
1846 MockMotionEvent event = 1846 MockMotionEvent event =
1847 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 1847 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
1848 event.set_id(++motion_event_id); 1848 event.SetPrimaryPointerId(motion_event_id);
1849 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1849 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1850 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1850 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1851 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); 1851 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
1852 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 1852 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
1853 1853
1854 ASSERT_TRUE(CancelActiveTouchSequence()); 1854 ASSERT_TRUE(CancelActiveTouchSequence());
1855 EXPECT_FALSE(HasDownEvent()); 1855 EXPECT_FALSE(HasDownEvent());
1856 1856
1857 // Subsequent MotionEvent's are dropped until ACTION_DOWN. 1857 // Subsequent MotionEvent's are dropped until ACTION_DOWN.
1858 event = ObtainMotionEvent(event_time + kOneMicrosecond, 1858 event = ObtainMotionEvent(event_time + kOneMicrosecond,
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2520 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2521 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); 2521 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
2522 2522
2523 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); 2523 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
2524 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 2524 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
2525 EXPECT_EQ(gfx::RectF(0, 0, 20, 20), 2525 EXPECT_EQ(gfx::RectF(0, 0, 20, 20),
2526 GetMostRecentGestureEvent().details.bounding_box()); 2526 GetMostRecentGestureEvent().details.bounding_box());
2527 } 2527 }
2528 2528
2529 } // namespace ui 2529 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | ui/events/gesture_detection/motion_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698