Changeset 96365 in webkit
- Timestamp:
- Sep 29, 2011 3:16:56 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96364 r96365 1 2011-09-29 Varun Jain <varunjain@google.com> 2 3 Implement flick gesture in Chromium Gesture Recognizer 4 https://bugs.webkit.org/show_bug.cgi?id=67930 5 6 Reviewed by Dimitri Glazkov. 7 8 Test: Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp 9 10 * platform/chromium/GestureRecognizerChromium.cpp: 11 (WebCore::GestureRecognizerChromium::isOverMinFlickSpeed): 12 (WebCore::GestureRecognizerChromium::appendScrollGestureEnd): 13 (WebCore::GestureRecognizerChromium::updateValues): 14 (WebCore::GestureRecognizerChromium::scrollEnd): 15 * platform/chromium/GestureRecognizerChromium.h: 16 1 17 2011-09-29 Noel Gordon <noel.gordon@gmail.com> 2 18 -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp
r95901 r96365 39 39 static const double maximumSecondsBetweenDoubleClick = 0.7; 40 40 static const int maximumTouchMoveInPixelsForClick = 20; 41 static const float minFlickSpeedSquared = 550.f * 550.f; 41 42 42 43 GestureRecognizerChromium::GestureRecognizerChromium() … … 44 45 , m_state(GestureRecognizerChromium::NoGesture) 45 46 , m_lastTouchTime(0.0) 47 , m_lastClickTime(0.0) 48 , m_lastTouchPosition() 49 , m_lastTouchScreenPosition() 50 , m_xVelocity(0.0) 51 , m_yVelocity(0.0) 46 52 , m_ctrlKey(false) 47 53 , m_altKey(false) … … 71 77 m_state = GestureRecognizerChromium::NoGesture; 72 78 m_lastTouchTime = 0.0; 79 m_lastTouchPosition.setX(0); 80 m_lastTouchPosition.setY(0); 81 m_lastTouchScreenPosition.setX(0); 82 m_lastTouchScreenPosition.setY(0); 83 m_xVelocity = 0.0; 84 m_yVelocity = 0.0; 73 85 } 74 86 … … 98 110 int manhattanDistance = abs(point.pos().x() - m_firstTouchPosition.x()) + abs(point.pos().y() - m_firstTouchPosition.y()); 99 111 return manhattanDistance < maximumTouchMoveInPixelsForClick; 112 } 113 114 bool GestureRecognizerChromium::isOverMinFlickSpeed() 115 { 116 return (m_xVelocity * m_xVelocity + m_yVelocity * m_yVelocity) > minFlickSpeedSquared; 100 117 } 101 118 … … 139 156 } 140 157 141 void GestureRecognizerChromium::appendScrollGestureEnd(const PlatformTouchPoint& touchPoint, Gestures gestures )142 { 143 gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollEndType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, 0.f, 0.f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));158 void GestureRecognizerChromium::appendScrollGestureEnd(const PlatformTouchPoint& touchPoint, Gestures gestures, float xVelocity, float yVelocity) 159 { 160 gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollEndType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, xVelocity, yVelocity, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey)); 144 161 } 145 162 … … 155 172 void GestureRecognizerChromium::updateValues(const double touchTime, const PlatformTouchPoint& touchPoint) 156 173 { 174 if (m_state != NoGesture && touchPoint.state() == PlatformTouchPoint::TouchMoved) { 175 double interval(touchTime - m_lastTouchTime); 176 m_xVelocity = (touchPoint.pos().x() - m_lastTouchPosition.x()) / interval; 177 m_yVelocity = (touchPoint.pos().y() - m_lastTouchPosition.y()) / interval; 178 m_lastTouchPosition = touchPoint.pos(); 179 m_lastTouchScreenPosition = touchPoint.screenPos(); 180 } 157 181 m_lastTouchTime = touchTime; 158 182 if (state() == NoGesture) { … … 160 184 m_firstTouchPosition = touchPoint.pos(); 161 185 m_firstTouchScreenPosition = touchPoint.screenPos(); 186 m_xVelocity = 0.0; 187 m_yVelocity = 0.0; 162 188 } 163 189 } … … 184 210 bool GestureRecognizerChromium::scrollEnd(const PlatformTouchPoint& point, Gestures gestures) 185 211 { 186 appendScrollGestureEnd(point, gestures); 212 if (isOverMinFlickSpeed() && point.state() != PlatformTouchPoint::TouchCancelled) 213 appendScrollGestureEnd(point, gestures, m_xVelocity, m_yVelocity); 214 else 215 appendScrollGestureEnd(point, gestures, 0.f, 0.f); 187 216 setState(NoGesture); 188 217 reset(); -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h
r95901 r96365 71 71 void appendDoubleClickGestureEvent(const PlatformTouchPoint&, Gestures); 72 72 void appendScrollGestureBegin(const PlatformTouchPoint&, Gestures); 73 void appendScrollGestureEnd(const PlatformTouchPoint&, Gestures );73 void appendScrollGestureEnd(const PlatformTouchPoint&, Gestures, float, float); 74 74 void appendScrollGestureUpdate(const PlatformTouchPoint&, Gestures); 75 75 bool isInClickTimeWindow(); 76 76 bool isInSecondClickTimeWindow(); 77 77 bool isInsideManhattanSquare(const PlatformTouchPoint&); 78 bool isOverMinFlickSpeed(); 78 79 void setState(State value) { m_state = value; } 79 80 void updateValues(double touchTime, const PlatformTouchPoint&); … … 93 94 double m_lastTouchTime; 94 95 double m_lastClickTime; 96 IntPoint m_lastTouchPosition; 97 IntPoint m_lastTouchScreenPosition; 98 float m_xVelocity; 99 float m_yVelocity; 95 100 96 101 bool m_ctrlKey; -
trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
r96010 r96365 34 34 35 35 #include <gtest/gtest.h> 36 #include <stdarg.h> 36 37 37 38 using namespace WebCore; … … 494 495 BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved); 495 496 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move); 497 gm.setLastTouchTime(gm.lastTouchTime() - 0.2); 496 498 Gestures gestureStart(gm.processTouchEventForGestures(moveEvent, false)); 497 499 bool scrollStarted = false, scrollUpdated = false; … … 515 517 BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased); 516 518 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release); 519 gm.setLastTouchTime(gm.lastTouchTime() - 0.2); 517 520 bool scrollEnd = false; 518 521 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); … … 521 524 case PlatformGestureEvent::ScrollEndType: 522 525 scrollEnd = true; 526 ASSERT_EQ((*gestureEnd)[i].deltaX(), 0); 527 ASSERT_EQ((*gestureEnd)[i].deltaY(), 0); 523 528 break; 524 529 default: … … 529 534 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 530 535 } 536 537 TEST_F(GestureRecognizerTest, flickGestureTest) 538 { 539 InspectableGestureRecognizerChromium gm; 540 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 541 542 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 543 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press); 544 Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false)); 545 ASSERT_EQ((unsigned int)1, gestureStart->size()); 546 ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type()); 547 ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()); 548 549 BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved); 550 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move); 551 Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false)); 552 bool scrollStarted = false, scrollUpdated = false; 553 for (unsigned int i = 0; i < gestureMove->size(); i++) { 554 switch ((*gestureMove)[i].type()) { 555 case PlatformGestureEvent::ScrollBeginType: 556 scrollStarted = true; 557 break; 558 case PlatformGestureEvent::ScrollUpdateType: 559 scrollUpdated = true; 560 break; 561 default: 562 ASSERT_TRUE(false); 563 } 564 } 565 566 ASSERT_TRUE(scrollStarted); 567 ASSERT_TRUE(scrollUpdated); 568 ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state()); 569 570 BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased); 571 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release); 572 Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 573 ASSERT_EQ((unsigned int) 1, gestureEnd->size()); 574 ASSERT_EQ(PlatformGestureEvent::ScrollEndType, (*gestureEnd)[0].type()); 575 ASSERT_GT((*gestureEnd)[0].deltaX(), 0); 576 ASSERT_GT((*gestureEnd)[0].deltaY(), 0); 577 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 578 } 579 580 struct TouchPointAndEvent { 581 public: 582 TouchPointAndEvent(int x, int y, double timestamp, PlatformTouchPoint::State state, WebCore::TouchEventType type) 583 : m_point(x, y, state) 584 , m_event(type, m_point, timestamp) 585 { } 586 BuildablePlatformTouchPoint m_point; 587 BuildablePlatformTouchEvent m_event; 588 }; 589 590 class TouchSequence { 591 public: 592 TouchSequence(int n, ...) : m_n(n) 593 { 594 va_list args; 595 va_start(args, n); 596 ASSERT(n > 0); 597 m_data = new TouchPointAndEvent*[n]; 598 for (int i = 0; i < n; ++i) 599 m_data[i] = va_arg(args, TouchPointAndEvent*); 600 va_end(args); 601 } 602 ~TouchSequence() 603 { 604 for (int i = 0; i < m_n; ++i) 605 delete m_data[i]; 606 delete m_data; 607 } 608 int m_n; 609 TouchPointAndEvent** m_data; 610 }; 611 612 const int numberOfFlickSamples = 11; 613 TouchSequence sampleFlickSequence[numberOfFlickSamples] = 614 { 615 TouchSequence(8, 616 new TouchPointAndEvent(256, 348, 1308336245.407, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 617 new TouchPointAndEvent(254, 345, 1308336245.470, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 618 new TouchPointAndEvent(252, 336, 1308336245.488, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 619 new TouchPointAndEvent(242, 261, 1308336245.505, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 620 new TouchPointAndEvent(242, 179, 1308336245.521, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 621 new TouchPointAndEvent(255, 100, 1308336245.533, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 622 new TouchPointAndEvent(262, 74, 1308336245.549, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 623 new TouchPointAndEvent(262, 74, 1308336245.566, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 624 ), 625 TouchSequence(8, 626 new TouchPointAndEvent(178, 339, 1308336266.180, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 627 new TouchPointAndEvent(177, 335, 1308336266.212, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 628 new TouchPointAndEvent(172, 314, 1308336266.226, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 629 new TouchPointAndEvent(160, 248, 1308336266.240, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 630 new TouchPointAndEvent(156, 198, 1308336266.251, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 631 new TouchPointAndEvent(166, 99, 1308336266.266, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 632 new TouchPointAndEvent(179, 41, 1308336266.280, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 633 new TouchPointAndEvent(179, 41, 1308336266.291, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 634 ), 635 TouchSequence(7, 636 new TouchPointAndEvent(238, 386, 1308336272.068, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 637 new TouchPointAndEvent(237, 383, 1308336272.121, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 638 new TouchPointAndEvent(236, 374, 1308336272.138, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 639 new TouchPointAndEvent(223, 264, 1308336272.155, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 640 new TouchPointAndEvent(231, 166, 1308336272.173, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 641 new TouchPointAndEvent(243, 107, 1308336272.190, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 642 new TouchPointAndEvent(243, 107, 1308336272.202, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 643 ), 644 TouchSequence(10, 645 new TouchPointAndEvent(334, 351, 1308336313.581, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 646 new TouchPointAndEvent(334, 348, 1308336313.694, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 647 new TouchPointAndEvent(335, 346, 1308336313.714, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 648 new TouchPointAndEvent(334, 343, 1308336313.727, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 649 new TouchPointAndEvent(332, 336, 1308336313.738, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 650 new TouchPointAndEvent(328, 316, 1308336313.753, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 651 new TouchPointAndEvent(317, 277, 1308336313.770, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 652 new TouchPointAndEvent(306, 243, 1308336313.784, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 653 new TouchPointAndEvent(292, 192, 1308336313.799, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 654 new TouchPointAndEvent(292, 192, 1308336313.815, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 655 ), 656 TouchSequence(14, 657 new TouchPointAndEvent(92, 112, 1308336323.955, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 658 new TouchPointAndEvent(92, 115, 1308336324.056, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 659 new TouchPointAndEvent(91, 116, 1308336324.066, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 660 new TouchPointAndEvent(91, 117, 1308336324.074, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 661 new TouchPointAndEvent(90, 122, 1308336324.089, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 662 new TouchPointAndEvent(90, 129, 1308336324.102, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 663 new TouchPointAndEvent(89, 147, 1308336324.120, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 664 new TouchPointAndEvent(89, 163, 1308336324.135, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 665 new TouchPointAndEvent(89, 188, 1308336324.151, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 666 new TouchPointAndEvent(89, 213, 1308336324.169, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 667 new TouchPointAndEvent(89, 252, 1308336324.189, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 668 new TouchPointAndEvent(90, 283, 1308336324.204, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 669 new TouchPointAndEvent(91, 308, 1308336324.218, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 670 new TouchPointAndEvent(91, 308, 1308336324.230, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 671 ), 672 TouchSequence(5, 673 new TouchPointAndEvent(55, 249, 1308336349.093, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 674 new TouchPointAndEvent(59, 249, 1308336349.179, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 675 new TouchPointAndEvent(66, 248, 1308336349.191, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 676 new TouchPointAndEvent(128, 253, 1308336349.208, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 677 new TouchPointAndEvent(128, 253, 1308336349.258, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 678 ), 679 TouchSequence(9, 680 new TouchPointAndEvent(376, 290, 1308336353.071, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 681 new TouchPointAndEvent(373, 288, 1308336353.127, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 682 new TouchPointAndEvent(372, 287, 1308336353.140, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 683 new TouchPointAndEvent(353, 280, 1308336353.156, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 684 new TouchPointAndEvent(319, 271, 1308336353.171, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 685 new TouchPointAndEvent(264, 258, 1308336353.188, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 686 new TouchPointAndEvent(215, 251, 1308336353.200, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 687 new TouchPointAndEvent(151, 246, 1308336353.217, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 688 new TouchPointAndEvent(151, 246, 1308336353.231, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 689 ), 690 TouchSequence(5, 691 new TouchPointAndEvent(60, 166, 1308336358.898, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 692 new TouchPointAndEvent(63, 166, 1308336358.944, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 693 new TouchPointAndEvent(68, 167, 1308336358.958, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 694 new TouchPointAndEvent(118, 179, 1308336358.971, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 695 new TouchPointAndEvent(118, 179, 1308336358.984, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 696 ), 697 TouchSequence(5, 698 new TouchPointAndEvent(66, 318, 1308336362.996, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 699 new TouchPointAndEvent(70, 316, 1308336363.046, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 700 new TouchPointAndEvent(77, 314, 1308336363.058, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 701 new TouchPointAndEvent(179, 295, 1308336363.082, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 702 new TouchPointAndEvent(179, 295, 1308336363.096, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 703 ), 704 TouchSequence(11, 705 new TouchPointAndEvent(345, 333, 1308336366.618, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 706 new TouchPointAndEvent(344, 330, 1308336366.664, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 707 new TouchPointAndEvent(343, 329, 1308336366.681, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 708 new TouchPointAndEvent(339, 324, 1308336366.694, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 709 new TouchPointAndEvent(332, 317, 1308336366.709, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 710 new TouchPointAndEvent(312, 300, 1308336366.728, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 711 new TouchPointAndEvent(279, 275, 1308336366.741, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 712 new TouchPointAndEvent(246, 251, 1308336366.752, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 713 new TouchPointAndEvent(198, 219, 1308336366.769, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 714 new TouchPointAndEvent(155, 196, 1308336366.783, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 715 new TouchPointAndEvent(155, 196, 1308336366.794, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 716 ), 717 TouchSequence(7, 718 new TouchPointAndEvent(333, 360, 1308336369.547, PlatformTouchPoint::TouchPressed, WebCore::TouchStart), 719 new TouchPointAndEvent(332, 357, 1308336369.596, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 720 new TouchPointAndEvent(331, 353, 1308336369.661, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 721 new TouchPointAndEvent(326, 345, 1308336369.713, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 722 new TouchPointAndEvent(310, 323, 1308336369.748, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 723 new TouchPointAndEvent(250, 272, 1308336369.801, PlatformTouchPoint::TouchMoved, WebCore::TouchMove), 724 new TouchPointAndEvent(250, 272, 1308336369.840, PlatformTouchPoint::TouchReleased, WebCore::TouchEnd) 725 ) 726 }; 727 728 TEST_F(GestureRecognizerTest, sampleFlickSequenceGestureTest) 729 { 730 InspectableGestureRecognizerChromium gm; 731 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()); 732 733 for (int i = 0; i < numberOfFlickSamples; ++i) { 734 std::ostringstream failureMessageBuilder; 735 failureMessageBuilder << "Failed on sample sequence " << i; 736 std::string failureMessage = failureMessageBuilder.str(); 737 738 // There should be at least 3 events (TouchStart, TouchMove, TouchEnd) in every sequence 739 ASSERT_GT(sampleFlickSequence[i].m_n, 3) << failureMessage; 740 741 // First event (TouchStart) should produce a TouchDown gesture 742 Gestures gestureStart(gm.processTouchEventForGestures(sampleFlickSequence[i].m_data[0]->m_event, false)); 743 ASSERT_EQ((unsigned int)1, gestureStart->size()) << failureMessage; 744 ASSERT_EQ(PlatformGestureEvent::TapDownType, (*gestureStart)[0].type()) << failureMessage; 745 ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()) << failureMessage; 746 747 // Then we have a bunch of TouchMove events 748 for (int j = 1; j < sampleFlickSequence[i].m_n - 1; ++j) 749 gm.processTouchEventForGestures(sampleFlickSequence[i].m_data[j]->m_event, false); 750 751 // Last event (TouchEnd) should generate a Flick gesture 752 Gestures gestureEnd(gm.processTouchEventForGestures(sampleFlickSequence[i].m_data[sampleFlickSequence[i].m_n - 1]->m_event, false)); 753 ASSERT_EQ((unsigned int) 1, gestureEnd->size()) << failureMessage; 754 ASSERT_EQ(PlatformGestureEvent::ScrollEndType, (*gestureEnd)[0].type()) << failureMessage; 755 double xVelocity = (*gestureEnd)[0].deltaX(); 756 double yVelocity = (*gestureEnd)[0].deltaY(); 757 double velocity = sqrt(xVelocity * xVelocity + yVelocity * yVelocity); 758 ASSERT_GT(velocity, 550) << failureMessage; 759 ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()) << failureMessage; 760 } 761 }
Note: See TracChangeset
for help on using the changeset viewer.