OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "base/timer.h" | 7 #include "base/timer.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 EXPECT_FALSE(delegate->begin()); | 709 EXPECT_FALSE(delegate->begin()); |
710 EXPECT_FALSE(delegate->double_tap()); | 710 EXPECT_FALSE(delegate->double_tap()); |
711 EXPECT_TRUE(delegate->scroll_begin()); | 711 EXPECT_TRUE(delegate->scroll_begin()); |
712 EXPECT_TRUE(delegate->scroll_update()); | 712 EXPECT_TRUE(delegate->scroll_update()); |
713 EXPECT_FALSE(delegate->scroll_end()); | 713 EXPECT_FALSE(delegate->scroll_end()); |
714 EXPECT_EQ(29, delegate->scroll_x()); | 714 EXPECT_EQ(29, delegate->scroll_x()); |
715 EXPECT_EQ(29, delegate->scroll_y()); | 715 EXPECT_EQ(29, delegate->scroll_y()); |
716 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 716 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
717 delegate->scroll_begin_position().ToString()); | 717 delegate->scroll_begin_position().ToString()); |
718 | 718 |
| 719 // When scrolling with a single finger, the bounding box of the gesture should |
| 720 // be empty, since it's a single point and the radius for testing is zero. |
| 721 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 722 |
719 // Move some more to generate a few more scroll updates. | 723 // Move some more to generate a few more scroll updates. |
720 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); | 724 SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get()); |
721 EXPECT_FALSE(delegate->tap()); | 725 EXPECT_FALSE(delegate->tap()); |
722 EXPECT_FALSE(delegate->tap_down()); | 726 EXPECT_FALSE(delegate->tap_down()); |
723 EXPECT_FALSE(delegate->begin()); | 727 EXPECT_FALSE(delegate->begin()); |
724 EXPECT_FALSE(delegate->double_tap()); | 728 EXPECT_FALSE(delegate->double_tap()); |
725 EXPECT_FALSE(delegate->scroll_begin()); | 729 EXPECT_FALSE(delegate->scroll_begin()); |
726 EXPECT_TRUE(delegate->scroll_update()); | 730 EXPECT_TRUE(delegate->scroll_update()); |
727 EXPECT_FALSE(delegate->scroll_end()); | 731 EXPECT_FALSE(delegate->scroll_end()); |
728 EXPECT_EQ(-20, delegate->scroll_x()); | 732 EXPECT_EQ(-20, delegate->scroll_x()); |
729 EXPECT_EQ(-19, delegate->scroll_y()); | 733 EXPECT_EQ(-19, delegate->scroll_y()); |
| 734 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
730 | 735 |
731 SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get()); | 736 SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get()); |
732 EXPECT_FALSE(delegate->tap()); | 737 EXPECT_FALSE(delegate->tap()); |
733 EXPECT_FALSE(delegate->tap_down()); | 738 EXPECT_FALSE(delegate->tap_down()); |
734 EXPECT_FALSE(delegate->begin()); | 739 EXPECT_FALSE(delegate->begin()); |
735 EXPECT_FALSE(delegate->double_tap()); | 740 EXPECT_FALSE(delegate->double_tap()); |
736 EXPECT_FALSE(delegate->scroll_begin()); | 741 EXPECT_FALSE(delegate->scroll_begin()); |
737 EXPECT_TRUE(delegate->scroll_update()); | 742 EXPECT_TRUE(delegate->scroll_update()); |
738 EXPECT_FALSE(delegate->scroll_end()); | 743 EXPECT_FALSE(delegate->scroll_end()); |
739 EXPECT_EQ(30, delegate->scroll_x()); | 744 EXPECT_EQ(30, delegate->scroll_x()); |
740 EXPECT_EQ(4, delegate->scroll_y()); | 745 EXPECT_EQ(4, delegate->scroll_y()); |
| 746 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
741 | 747 |
742 // Release the touch. This should end the scroll. | 748 // Release the touch. This should end the scroll. |
743 delegate->Reset(); | 749 delegate->Reset(); |
744 TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 750 TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
745 kTouchId, press.time_stamp() + | 751 kTouchId, press.time_stamp() + |
746 base::TimeDelta::FromMilliseconds(50)); | 752 base::TimeDelta::FromMilliseconds(50)); |
747 root_window()->DispatchTouchEvent(&release); | 753 root_window()->DispatchTouchEvent(&release); |
748 EXPECT_FALSE(delegate->tap()); | 754 EXPECT_FALSE(delegate->tap()); |
749 EXPECT_FALSE(delegate->tap_down()); | 755 EXPECT_FALSE(delegate->tap_down()); |
750 EXPECT_FALSE(delegate->begin()); | 756 EXPECT_FALSE(delegate->begin()); |
751 EXPECT_TRUE(delegate->end()); | 757 EXPECT_TRUE(delegate->end()); |
752 EXPECT_FALSE(delegate->double_tap()); | 758 EXPECT_FALSE(delegate->double_tap()); |
753 EXPECT_FALSE(delegate->scroll_begin()); | 759 EXPECT_FALSE(delegate->scroll_begin()); |
754 EXPECT_FALSE(delegate->scroll_update()); | 760 EXPECT_FALSE(delegate->scroll_update()); |
755 EXPECT_TRUE(delegate->scroll_end()); | 761 EXPECT_TRUE(delegate->scroll_end()); |
| 762 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 763 } |
| 764 |
| 765 // Check that the bounding box during a scroll event is correct. |
| 766 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { |
| 767 for (int radius = 1; radius <= 10; ++radius) { |
| 768 ui::GestureConfiguration::set_default_radius(radius); |
| 769 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 770 new GestureEventConsumeDelegate()); |
| 771 const int kWindowWidth = 123; |
| 772 const int kWindowHeight = 45; |
| 773 const int kTouchId = 5; |
| 774 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 775 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 776 delegate.get(), -1234, bounds, NULL)); |
| 777 |
| 778 const int kPositionX = 101; |
| 779 const int kPositionY = 201; |
| 780 delegate->Reset(); |
| 781 TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(kPositionX, kPositionY), |
| 782 kTouchId, GetTime()); |
| 783 root_window()->DispatchTouchEvent(&press); |
| 784 EXPECT_EQ(gfx::Rect(kPositionX - radius, |
| 785 kPositionY - radius, |
| 786 radius * 2, |
| 787 radius * 2).ToString(), |
| 788 delegate->bounding_box().ToString()); |
| 789 |
| 790 const int kScrollAmount = 50; |
| 791 SendScrollEvents(root_window(), kPositionX, kPositionY, GetTime(), |
| 792 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); |
| 793 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 794 delegate->scroll_begin_position().ToString()); |
| 795 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, |
| 796 kPositionY + kScrollAmount - radius, |
| 797 radius * 2, |
| 798 radius * 2).ToString(), |
| 799 delegate->bounding_box().ToString()); |
| 800 |
| 801 // Release the touch. This should end the scroll. |
| 802 delegate->Reset(); |
| 803 TouchEvent release(ui::ET_TOUCH_RELEASED, |
| 804 gfx::Point(kPositionX, kPositionY), |
| 805 kTouchId, press.time_stamp() + |
| 806 base::TimeDelta::FromMilliseconds(50)); |
| 807 root_window()->DispatchTouchEvent(&release); |
| 808 EXPECT_EQ(gfx::Rect(kPositionX - radius, |
| 809 kPositionY - radius, |
| 810 radius * 2, |
| 811 radius * 2).ToString(), |
| 812 delegate->bounding_box().ToString()); |
| 813 } |
| 814 ui::GestureConfiguration::set_default_radius(0); |
756 } | 815 } |
757 | 816 |
758 // Check Scroll End Events report correct velocities | 817 // Check Scroll End Events report correct velocities |
759 // if the user was on a horizontal rail | 818 // if the user was on a horizontal rail |
760 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { | 819 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { |
761 scoped_ptr<GestureEventConsumeDelegate> delegate( | 820 scoped_ptr<GestureEventConsumeDelegate> delegate( |
762 new GestureEventConsumeDelegate()); | 821 new GestureEventConsumeDelegate()); |
763 const int kTouchId = 7; | 822 const int kTouchId = 7; |
764 gfx::Rect bounds(0, 0, 1000, 1000); | 823 gfx::Rect bounds(0, 0, 1000, 1000); |
765 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 824 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 1482 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
1424 kTouchId2, GetTime()); | 1483 kTouchId2, GetTime()); |
1425 root->DispatchTouchEvent(&press2); | 1484 root->DispatchTouchEvent(&press2); |
1426 EXPECT_FALSE(delegate->tap()); | 1485 EXPECT_FALSE(delegate->tap()); |
1427 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 1486 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
1428 EXPECT_FALSE(delegate->double_tap()); | 1487 EXPECT_FALSE(delegate->double_tap()); |
1429 EXPECT_FALSE(delegate->scroll_begin()); | 1488 EXPECT_FALSE(delegate->scroll_begin()); |
1430 EXPECT_FALSE(delegate->scroll_update()); | 1489 EXPECT_FALSE(delegate->scroll_update()); |
1431 EXPECT_FALSE(delegate->scroll_end()); | 1490 EXPECT_FALSE(delegate->scroll_end()); |
1432 EXPECT_TRUE(delegate->pinch_begin()); | 1491 EXPECT_TRUE(delegate->pinch_begin()); |
| 1492 EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(), |
| 1493 delegate->bounding_box().ToString()); |
1433 | 1494 |
1434 // Move the first finger. | 1495 // Move the first finger. |
1435 delegate->Reset(); | 1496 delegate->Reset(); |
1436 TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), | 1497 TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), |
1437 kTouchId1, GetTime()); | 1498 kTouchId1, GetTime()); |
1438 root->DispatchTouchEvent(&move3); | 1499 root->DispatchTouchEvent(&move3); |
1439 EXPECT_FALSE(delegate->tap()); | 1500 EXPECT_FALSE(delegate->tap()); |
1440 EXPECT_FALSE(delegate->tap_down()); | 1501 EXPECT_FALSE(delegate->tap_down()); |
1441 EXPECT_FALSE(delegate->double_tap()); | 1502 EXPECT_FALSE(delegate->double_tap()); |
1442 EXPECT_FALSE(delegate->scroll_begin()); | 1503 EXPECT_FALSE(delegate->scroll_begin()); |
1443 EXPECT_FALSE(delegate->scroll_update()); | 1504 EXPECT_FALSE(delegate->scroll_update()); |
1444 EXPECT_FALSE(delegate->scroll_end()); | 1505 EXPECT_FALSE(delegate->scroll_end()); |
1445 EXPECT_FALSE(delegate->pinch_begin()); | 1506 EXPECT_FALSE(delegate->pinch_begin()); |
1446 EXPECT_TRUE(delegate->pinch_update()); | 1507 EXPECT_TRUE(delegate->pinch_update()); |
| 1508 EXPECT_EQ(gfx::Rect(10, 10, 85, 191).ToString(), |
| 1509 delegate->bounding_box().ToString()); |
1447 | 1510 |
1448 // Now move the second finger. | 1511 // Now move the second finger. |
1449 delegate->Reset(); | 1512 delegate->Reset(); |
1450 TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), | 1513 TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), |
1451 kTouchId2, GetTime()); | 1514 kTouchId2, GetTime()); |
1452 root->DispatchTouchEvent(&move4); | 1515 root->DispatchTouchEvent(&move4); |
1453 EXPECT_FALSE(delegate->tap()); | 1516 EXPECT_FALSE(delegate->tap()); |
1454 EXPECT_FALSE(delegate->tap_down()); | 1517 EXPECT_FALSE(delegate->tap_down()); |
1455 EXPECT_FALSE(delegate->double_tap()); | 1518 EXPECT_FALSE(delegate->double_tap()); |
1456 EXPECT_FALSE(delegate->scroll_begin()); | 1519 EXPECT_FALSE(delegate->scroll_begin()); |
1457 EXPECT_FALSE(delegate->scroll_update()); | 1520 EXPECT_FALSE(delegate->scroll_update()); |
1458 EXPECT_FALSE(delegate->scroll_end()); | 1521 EXPECT_FALSE(delegate->scroll_end()); |
1459 EXPECT_FALSE(delegate->pinch_begin()); | 1522 EXPECT_FALSE(delegate->pinch_begin()); |
1460 EXPECT_TRUE(delegate->pinch_update()); | 1523 EXPECT_TRUE(delegate->pinch_update()); |
| 1524 EXPECT_EQ(gfx::Rect(55, 15, 40, 186).ToString(), |
| 1525 delegate->bounding_box().ToString()); |
1461 | 1526 |
1462 // Release the first finger. This should end pinch. | 1527 // Release the first finger. This should end pinch. |
1463 delegate->Reset(); | 1528 delegate->Reset(); |
1464 TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1529 TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
1465 kTouchId1, press.time_stamp() + | 1530 kTouchId1, press.time_stamp() + |
1466 base::TimeDelta::FromMilliseconds(50)); | 1531 base::TimeDelta::FromMilliseconds(50)); |
1467 root->DispatchTouchEvent(&release); | 1532 root->DispatchTouchEvent(&release); |
1468 EXPECT_FALSE(delegate->tap()); | 1533 EXPECT_FALSE(delegate->tap()); |
1469 EXPECT_FALSE(delegate->tap_down()); | 1534 EXPECT_FALSE(delegate->tap_down()); |
1470 EXPECT_FALSE(delegate->double_tap()); | 1535 EXPECT_FALSE(delegate->double_tap()); |
1471 EXPECT_FALSE(delegate->scroll_begin()); | 1536 EXPECT_FALSE(delegate->scroll_begin()); |
1472 EXPECT_FALSE(delegate->scroll_update()); | 1537 EXPECT_FALSE(delegate->scroll_update()); |
1473 EXPECT_FALSE(delegate->scroll_end()); | 1538 EXPECT_FALSE(delegate->scroll_end()); |
1474 EXPECT_TRUE(delegate->pinch_end()); | 1539 EXPECT_TRUE(delegate->pinch_end()); |
| 1540 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), |
| 1541 delegate->bounding_box().ToString()); |
1475 | 1542 |
1476 // Move the second finger. This should still generate a scroll. | 1543 // Move the second finger. This should still generate a scroll. |
1477 delegate->Reset(); | 1544 delegate->Reset(); |
1478 TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 1545 TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
1479 kTouchId2, GetTime()); | 1546 kTouchId2, GetTime()); |
1480 root->DispatchTouchEvent(&move5); | 1547 root->DispatchTouchEvent(&move5); |
1481 EXPECT_FALSE(delegate->tap()); | 1548 EXPECT_FALSE(delegate->tap()); |
1482 EXPECT_FALSE(delegate->tap_down()); | 1549 EXPECT_FALSE(delegate->tap_down()); |
1483 EXPECT_FALSE(delegate->double_tap()); | 1550 EXPECT_FALSE(delegate->double_tap()); |
1484 EXPECT_FALSE(delegate->scroll_begin()); | 1551 EXPECT_FALSE(delegate->scroll_begin()); |
1485 EXPECT_TRUE(delegate->scroll_update()); | 1552 EXPECT_TRUE(delegate->scroll_update()); |
1486 EXPECT_FALSE(delegate->scroll_end()); | 1553 EXPECT_FALSE(delegate->scroll_end()); |
1487 EXPECT_FALSE(delegate->pinch_begin()); | 1554 EXPECT_FALSE(delegate->pinch_begin()); |
1488 EXPECT_FALSE(delegate->pinch_update()); | 1555 EXPECT_FALSE(delegate->pinch_update()); |
| 1556 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
1489 } | 1557 } |
1490 | 1558 |
1491 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { | 1559 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { |
1492 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1560 scoped_ptr<GestureEventConsumeDelegate> delegate( |
1493 new GestureEventConsumeDelegate()); | 1561 new GestureEventConsumeDelegate()); |
1494 const int kWindowWidth = 300; | 1562 const int kWindowWidth = 300; |
1495 const int kWindowHeight = 400; | 1563 const int kWindowHeight = 400; |
1496 const int kTouchId1 = 5; | 1564 const int kTouchId1 = 5; |
1497 const int kTouchId2 = 3; | 1565 const int kTouchId2 = 3; |
1498 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 1566 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 delegate->Reset(); | 1623 delegate->Reset(); |
1556 TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), | 1624 TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), |
1557 kTouchId1, GetTime()); | 1625 kTouchId1, GetTime()); |
1558 root->DispatchTouchEvent(&press); | 1626 root->DispatchTouchEvent(&press); |
1559 EXPECT_FALSE(delegate->tap()); | 1627 EXPECT_FALSE(delegate->tap()); |
1560 EXPECT_TRUE(delegate->tap_down()); | 1628 EXPECT_TRUE(delegate->tap_down()); |
1561 EXPECT_FALSE(delegate->double_tap()); | 1629 EXPECT_FALSE(delegate->double_tap()); |
1562 EXPECT_FALSE(delegate->scroll_begin()); | 1630 EXPECT_FALSE(delegate->scroll_begin()); |
1563 EXPECT_FALSE(delegate->scroll_update()); | 1631 EXPECT_FALSE(delegate->scroll_update()); |
1564 EXPECT_FALSE(delegate->scroll_end()); | 1632 EXPECT_FALSE(delegate->scroll_end()); |
| 1633 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
1565 | 1634 |
1566 // Press the second finger far enough to break two finger tap. It should | 1635 // Press the second finger far enough to break two finger tap. It should |
1567 // instead cause a scroll-begin and pinch-begin. | 1636 // instead cause a scroll-begin and pinch-begin. |
1568 delegate->Reset(); | 1637 delegate->Reset(); |
1569 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 1638 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
1570 kTouchId2, GetTime()); | 1639 kTouchId2, GetTime()); |
1571 root->DispatchTouchEvent(&press2); | 1640 root->DispatchTouchEvent(&press2); |
1572 EXPECT_FALSE(delegate->tap()); | 1641 EXPECT_FALSE(delegate->tap()); |
1573 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. | 1642 EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap. |
1574 EXPECT_FALSE(delegate->double_tap()); | 1643 EXPECT_FALSE(delegate->double_tap()); |
1575 EXPECT_TRUE(delegate->scroll_begin()); | 1644 EXPECT_TRUE(delegate->scroll_begin()); |
1576 EXPECT_FALSE(delegate->scroll_update()); | 1645 EXPECT_FALSE(delegate->scroll_update()); |
1577 EXPECT_FALSE(delegate->scroll_end()); | 1646 EXPECT_FALSE(delegate->scroll_end()); |
1578 EXPECT_TRUE(delegate->pinch_begin()); | 1647 EXPECT_TRUE(delegate->pinch_begin()); |
| 1648 EXPECT_EQ(gfx::Rect(10, 10, 91, 291).ToString(), |
| 1649 delegate->bounding_box().ToString()); |
1579 | 1650 |
1580 // Move the first finger. | 1651 // Move the first finger. |
1581 delegate->Reset(); | 1652 delegate->Reset(); |
1582 TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), | 1653 TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), |
1583 kTouchId1, GetTime()); | 1654 kTouchId1, GetTime()); |
1584 root->DispatchTouchEvent(&move3); | 1655 root->DispatchTouchEvent(&move3); |
1585 EXPECT_FALSE(delegate->tap()); | 1656 EXPECT_FALSE(delegate->tap()); |
1586 EXPECT_FALSE(delegate->tap_down()); | 1657 EXPECT_FALSE(delegate->tap_down()); |
1587 EXPECT_FALSE(delegate->double_tap()); | 1658 EXPECT_FALSE(delegate->double_tap()); |
1588 EXPECT_FALSE(delegate->scroll_begin()); | 1659 EXPECT_FALSE(delegate->scroll_begin()); |
1589 EXPECT_FALSE(delegate->scroll_update()); | 1660 EXPECT_FALSE(delegate->scroll_update()); |
1590 EXPECT_FALSE(delegate->scroll_end()); | 1661 EXPECT_FALSE(delegate->scroll_end()); |
1591 EXPECT_FALSE(delegate->pinch_begin()); | 1662 EXPECT_FALSE(delegate->pinch_begin()); |
1592 EXPECT_TRUE(delegate->pinch_update()); | 1663 EXPECT_TRUE(delegate->pinch_update()); |
| 1664 EXPECT_EQ(gfx::Rect(10, 10, 55, 191).ToString(), |
| 1665 delegate->bounding_box().ToString()); |
1593 | 1666 |
1594 // Now move the second finger. | 1667 // Now move the second finger. |
1595 delegate->Reset(); | 1668 delegate->Reset(); |
1596 TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), | 1669 TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), |
1597 kTouchId2, GetTime()); | 1670 kTouchId2, GetTime()); |
1598 root->DispatchTouchEvent(&move4); | 1671 root->DispatchTouchEvent(&move4); |
1599 EXPECT_FALSE(delegate->tap()); | 1672 EXPECT_FALSE(delegate->tap()); |
1600 EXPECT_FALSE(delegate->tap_down()); | 1673 EXPECT_FALSE(delegate->tap_down()); |
1601 EXPECT_FALSE(delegate->double_tap()); | 1674 EXPECT_FALSE(delegate->double_tap()); |
1602 EXPECT_FALSE(delegate->scroll_begin()); | 1675 EXPECT_FALSE(delegate->scroll_begin()); |
1603 EXPECT_FALSE(delegate->scroll_update()); | 1676 EXPECT_FALSE(delegate->scroll_update()); |
1604 EXPECT_FALSE(delegate->scroll_end()); | 1677 EXPECT_FALSE(delegate->scroll_end()); |
1605 EXPECT_FALSE(delegate->pinch_begin()); | 1678 EXPECT_FALSE(delegate->pinch_begin()); |
1606 EXPECT_TRUE(delegate->pinch_update()); | 1679 EXPECT_TRUE(delegate->pinch_update()); |
| 1680 EXPECT_EQ(gfx::Rect(55, 15, 10, 186).ToString(), |
| 1681 delegate->bounding_box().ToString()); |
1607 | 1682 |
1608 // Release the first finger. This should end pinch. | 1683 // Release the first finger. This should end pinch. |
1609 delegate->Reset(); | 1684 delegate->Reset(); |
1610 TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1685 TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
1611 kTouchId1, press.time_stamp() + | 1686 kTouchId1, press.time_stamp() + |
1612 base::TimeDelta::FromMilliseconds(50)); | 1687 base::TimeDelta::FromMilliseconds(50)); |
1613 root->DispatchTouchEvent(&release); | 1688 root->DispatchTouchEvent(&release); |
1614 EXPECT_FALSE(delegate->tap()); | 1689 EXPECT_FALSE(delegate->tap()); |
1615 EXPECT_FALSE(delegate->tap_down()); | 1690 EXPECT_FALSE(delegate->tap_down()); |
1616 EXPECT_FALSE(delegate->double_tap()); | 1691 EXPECT_FALSE(delegate->double_tap()); |
1617 EXPECT_FALSE(delegate->scroll_begin()); | 1692 EXPECT_FALSE(delegate->scroll_begin()); |
1618 EXPECT_FALSE(delegate->scroll_update()); | 1693 EXPECT_FALSE(delegate->scroll_update()); |
1619 EXPECT_FALSE(delegate->scroll_end()); | 1694 EXPECT_FALSE(delegate->scroll_end()); |
1620 EXPECT_TRUE(delegate->pinch_end()); | 1695 EXPECT_TRUE(delegate->pinch_end()); |
| 1696 EXPECT_EQ(gfx::Rect(55, 15, 46, 186).ToString(), |
| 1697 delegate->bounding_box().ToString()); |
1621 | 1698 |
1622 // Move the second finger. This should still generate a scroll. | 1699 // Move the second finger. This should still generate a scroll. |
1623 delegate->Reset(); | 1700 delegate->Reset(); |
1624 TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 1701 TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
1625 kTouchId2, GetTime()); | 1702 kTouchId2, GetTime()); |
1626 root->DispatchTouchEvent(&move5); | 1703 root->DispatchTouchEvent(&move5); |
1627 EXPECT_FALSE(delegate->tap()); | 1704 EXPECT_FALSE(delegate->tap()); |
1628 EXPECT_FALSE(delegate->tap_down()); | 1705 EXPECT_FALSE(delegate->tap_down()); |
1629 EXPECT_FALSE(delegate->double_tap()); | 1706 EXPECT_FALSE(delegate->double_tap()); |
1630 EXPECT_FALSE(delegate->scroll_begin()); | 1707 EXPECT_FALSE(delegate->scroll_begin()); |
1631 EXPECT_TRUE(delegate->scroll_update()); | 1708 EXPECT_TRUE(delegate->scroll_update()); |
1632 EXPECT_FALSE(delegate->scroll_end()); | 1709 EXPECT_FALSE(delegate->scroll_end()); |
1633 EXPECT_FALSE(delegate->pinch_begin()); | 1710 EXPECT_FALSE(delegate->pinch_begin()); |
1634 EXPECT_FALSE(delegate->pinch_update()); | 1711 EXPECT_FALSE(delegate->pinch_update()); |
| 1712 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
1635 } | 1713 } |
1636 | 1714 |
1637 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { | 1715 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { |
1638 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1716 scoped_ptr<GestureEventConsumeDelegate> delegate( |
1639 new GestureEventConsumeDelegate()); | 1717 new GestureEventConsumeDelegate()); |
1640 | 1718 |
1641 TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1719 TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
1642 6, GetTime()); | 1720 6, GetTime()); |
1643 root_window()->DispatchTouchEvent(&release1); | 1721 root_window()->DispatchTouchEvent(&release1); |
1644 EXPECT_FALSE(delegate->tap()); | 1722 EXPECT_FALSE(delegate->tap()); |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 EXPECT_FALSE(delegate->begin()); | 2370 EXPECT_FALSE(delegate->begin()); |
2293 EXPECT_TRUE(delegate->end()); | 2371 EXPECT_TRUE(delegate->end()); |
2294 EXPECT_FALSE(delegate->double_tap()); | 2372 EXPECT_FALSE(delegate->double_tap()); |
2295 EXPECT_FALSE(delegate->scroll_begin()); | 2373 EXPECT_FALSE(delegate->scroll_begin()); |
2296 EXPECT_FALSE(delegate->scroll_update()); | 2374 EXPECT_FALSE(delegate->scroll_update()); |
2297 EXPECT_TRUE(delegate->scroll_end()); | 2375 EXPECT_TRUE(delegate->scroll_end()); |
2298 } | 2376 } |
2299 | 2377 |
2300 } // namespace test | 2378 } // namespace test |
2301 } // namespace aura | 2379 } // namespace aura |
OLD | NEW |