Chromium Code Reviews| 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" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 67 |
| 68 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, | 68 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, |
| 69 MotionEvent::Action action, | 69 MotionEvent::Action action, |
| 70 float x0, | 70 float x0, |
| 71 float y0, | 71 float y0, |
| 72 float x1, | 72 float x1, |
| 73 float y1) { | 73 float y1) { |
| 74 return MockMotionEvent(action, event_time, x0, y0, x1, y1); | 74 return MockMotionEvent(action, event_time, x0, y0, x1, y1); |
| 75 } | 75 } |
| 76 | 76 |
| 77 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, | |
| 78 MotionEvent::Action action, | |
| 79 float x0, | |
| 80 float y0, | |
| 81 float x1, | |
| 82 float y1, | |
| 83 float x2, | |
| 84 float y2) { | |
| 85 return MockMotionEvent(action, event_time, x0, y0, x1, y1, x2, y2); | |
| 86 } | |
| 87 | |
| 88 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, | |
|
jdduke (slow)
2014/05/28 16:26:00
Hmm, I don't actually see where the 4 pointer case
tdresser
2014/05/29 14:26:21
Oh goodness, you're right. I was using 4 for the b
| |
| 89 MotionEvent::Action action, | |
| 90 float x0, | |
| 91 float y0, | |
| 92 float x1, | |
| 93 float y1, | |
| 94 float x2, | |
| 95 float y2, | |
| 96 float x3, | |
| 97 float y3) { | |
| 98 return MockMotionEvent(action, event_time, x0, y0, x1, y1, x2, y2, x3, y3); | |
| 99 } | |
| 100 | |
| 77 static MockMotionEvent ObtainMotionEvent( | 101 static MockMotionEvent ObtainMotionEvent( |
| 78 base::TimeTicks event_time, | 102 base::TimeTicks event_time, |
| 79 MotionEvent::Action action, | 103 MotionEvent::Action action, |
| 80 const std::vector<gfx::PointF>& positions) { | 104 const std::vector<gfx::PointF>& positions) { |
| 81 switch (positions.size()) { | 105 switch (positions.size()) { |
| 82 case 1: | 106 case 1: |
| 83 return MockMotionEvent( | 107 return MockMotionEvent( |
| 84 action, event_time, positions[0].x(), positions[0].y()); | 108 action, event_time, positions[0].x(), positions[0].y()); |
| 85 case 2: | 109 case 2: |
| 86 return MockMotionEvent(action, | 110 return MockMotionEvent(action, |
| 87 event_time, | 111 event_time, |
| 88 positions[0].x(), | 112 positions[0].x(), |
| 89 positions[0].y(), | 113 positions[0].y(), |
| 90 positions[1].x(), | 114 positions[1].x(), |
| 91 positions[1].y()); | 115 positions[1].y()); |
| 92 case 3: | 116 case 3: |
| 93 return MockMotionEvent(action, | 117 return MockMotionEvent(action, |
| 94 event_time, | 118 event_time, |
| 95 positions[0].x(), | 119 positions[0].x(), |
| 96 positions[0].y(), | 120 positions[0].y(), |
| 97 positions[1].x(), | 121 positions[1].x(), |
| 98 positions[1].y(), | 122 positions[1].y(), |
| 99 positions[2].x(), | 123 positions[2].x(), |
| 100 positions[2].y()); | 124 positions[2].y()); |
| 125 case 4: | |
| 126 return MockMotionEvent(action, | |
| 127 event_time, | |
| 128 positions[0].x(), | |
| 129 positions[0].y(), | |
| 130 positions[1].x(), | |
| 131 positions[1].y(), | |
| 132 positions[2].x(), | |
| 133 positions[2].y(), | |
| 134 positions[3].x(), | |
| 135 positions[3].y()); | |
| 136 | |
| 101 default: | 137 default: |
| 102 CHECK(false) << "MockMotionEvent only supports 1-3 pointers"; | 138 CHECK(false) << "MockMotionEvent only supports 1-4 pointers"; |
| 103 return MockMotionEvent(); | 139 return MockMotionEvent(); |
| 104 } | 140 } |
| 105 } | 141 } |
| 106 | 142 |
| 107 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, | 143 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, |
| 108 MotionEvent::Action action) { | 144 MotionEvent::Action action) { |
| 109 return ObtainMotionEvent(event_time, action, kFakeCoordX, kFakeCoordY); | 145 return ObtainMotionEvent(event_time, action, kFakeCoordX, kFakeCoordY); |
| 110 } | 146 } |
| 111 | 147 |
| 112 // Test | 148 // Test |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1382 | 1418 |
| 1383 // Toggling double-tap support should not take effect until the next sequence. | 1419 // Toggling double-tap support should not take effect until the next sequence. |
| 1384 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); | 1420 gesture_provider_->SetDoubleTapSupportForPageEnabled(false); |
| 1385 | 1421 |
| 1386 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1422 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1387 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); | 1423 EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id); |
| 1388 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1424 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
| 1389 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); | 1425 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_BEGIN)); |
| 1390 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); | 1426 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN)); |
| 1391 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); | 1427 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_UPDATE)); |
| 1428 | |
| 1429 EXPECT_EQ((kFakeCoordX + secondary_coord_x) / 2, GetReceivedGesture(3).x); | |
| 1430 EXPECT_EQ((kFakeCoordY + secondary_coord_y) / 2, GetReceivedGesture(3).y); | |
| 1431 | |
| 1392 EXPECT_EQ( | 1432 EXPECT_EQ( |
| 1393 gfx::RectF(kFakeCoordX - kMockTouchRadius, | 1433 gfx::RectF(kFakeCoordX - kMockTouchRadius, |
| 1394 kFakeCoordY - kMockTouchRadius, | 1434 kFakeCoordY - kMockTouchRadius, |
| 1395 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, | 1435 secondary_coord_x - kFakeCoordX + kMockTouchRadius * 2, |
| 1396 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2), | 1436 secondary_coord_y - kFakeCoordY + kMockTouchRadius * 2), |
| 1397 GetMostRecentGestureEvent().details.bounding_box()); | 1437 GetMostRecentGestureEvent().details.bounding_box()); |
| 1398 | 1438 |
| 1399 secondary_coord_x += 2 * touch_slop; | 1439 secondary_coord_x += 2 * touch_slop; |
| 1400 secondary_coord_y += 2 * touch_slop; | 1440 secondary_coord_y += 2 * touch_slop; |
| 1401 event = ObtainMotionEvent(event_time, | 1441 event = ObtainMotionEvent(event_time, |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1672 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1712 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1673 } | 1713 } |
| 1674 | 1714 |
| 1675 // Verify that gesture begin and gesture end events are dispatched correctly. | 1715 // Verify that gesture begin and gesture end events are dispatched correctly. |
| 1676 TEST_F(GestureProviderTest, GestureBeginAndEnd) { | 1716 TEST_F(GestureProviderTest, GestureBeginAndEnd) { |
| 1677 EnableBeginEndTypes(); | 1717 EnableBeginEndTypes(); |
| 1678 base::TimeTicks event_time = base::TimeTicks::Now(); | 1718 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 1679 | 1719 |
| 1680 EXPECT_EQ(0U, GetReceivedGestureCount()); | 1720 EXPECT_EQ(0U, GetReceivedGestureCount()); |
| 1681 MockMotionEvent event = | 1721 MockMotionEvent event = |
| 1682 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 1722 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 1, 1); |
| 1683 event.pointer_count = 1; | 1723 event.pointer_count = 1; |
| 1684 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1724 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1685 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type); | 1725 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type); |
| 1686 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 1726 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
| 1687 EXPECT_EQ(2U, GetReceivedGestureCount()); | 1727 EXPECT_EQ(2U, GetReceivedGestureCount()); |
| 1688 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1728 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1689 EXPECT_EQ(gfx::RectF(kFakeCoordX - kMockTouchRadius, | 1729 EXPECT_EQ(1, GetMostRecentGestureEvent().x); |
| 1690 kFakeCoordY - kMockTouchRadius, | 1730 EXPECT_EQ(1, GetMostRecentGestureEvent().y); |
| 1731 EXPECT_EQ(gfx::RectF(1 - kMockTouchRadius, | |
| 1732 1 - kMockTouchRadius, | |
| 1691 kMockTouchRadius * 2, | 1733 kMockTouchRadius * 2, |
| 1692 kMockTouchRadius * 2), | 1734 kMockTouchRadius * 2), |
| 1693 GetMostRecentGestureEvent().details.bounding_box()); | 1735 GetMostRecentGestureEvent().details.bounding_box()); |
| 1694 | 1736 |
| 1695 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN); | 1737 event = ObtainMotionEvent( |
| 1738 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2); | |
| 1696 event.pointer_count = 2; | 1739 event.pointer_count = 2; |
| 1697 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1740 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1698 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); | 1741 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); |
| 1699 EXPECT_EQ(3U, GetReceivedGestureCount()); | 1742 EXPECT_EQ(3U, GetReceivedGestureCount()); |
| 1700 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1743 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
| 1744 EXPECT_EQ(2, GetMostRecentGestureEvent().x); | |
| 1745 EXPECT_EQ(2, GetMostRecentGestureEvent().y); | |
| 1701 | 1746 |
| 1702 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN); | 1747 event = ObtainMotionEvent( |
| 1748 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2, 3, 3); | |
| 1703 event.pointer_count = 3; | 1749 event.pointer_count = 3; |
| 1704 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1750 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1705 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); | 1751 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); |
| 1706 EXPECT_EQ(4U, GetReceivedGestureCount()); | 1752 EXPECT_EQ(4U, GetReceivedGestureCount()); |
| 1707 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); | 1753 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); |
| 1754 EXPECT_EQ(3, GetMostRecentGestureEvent().x); | |
| 1755 EXPECT_EQ(3, GetMostRecentGestureEvent().y); | |
| 1708 | 1756 |
| 1709 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP); | 1757 event = ObtainMotionEvent( |
| 1758 event_time, MotionEvent::ACTION_POINTER_UP, 1, 1, 2, 2, 3, 3); | |
| 1710 event.pointer_count = 2; | 1759 event.pointer_count = 2; |
| 1711 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1760 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1712 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); | 1761 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); |
| 1713 EXPECT_EQ(5U, GetReceivedGestureCount()); | 1762 EXPECT_EQ(5U, GetReceivedGestureCount()); |
| 1714 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1763 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
| 1764 EXPECT_EQ(1, GetMostRecentGestureEvent().x); | |
| 1765 EXPECT_EQ(1, GetMostRecentGestureEvent().y); | |
| 1715 | 1766 |
| 1716 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN); | 1767 event = ObtainMotionEvent( |
| 1768 event_time, MotionEvent::ACTION_POINTER_DOWN, 2, 2, 3, 3, 4, 4); | |
| 1717 event.pointer_count = 3; | 1769 event.pointer_count = 3; |
| 1718 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1770 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1719 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); | 1771 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); |
| 1720 EXPECT_EQ(6U, GetReceivedGestureCount()); | 1772 EXPECT_EQ(6U, GetReceivedGestureCount()); |
| 1721 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); | 1773 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); |
| 1774 EXPECT_EQ(4, GetMostRecentGestureEvent().x); | |
| 1775 EXPECT_EQ(4, GetMostRecentGestureEvent().y); | |
| 1722 | 1776 |
| 1723 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP); | 1777 event = ObtainMotionEvent( |
| 1778 event_time, MotionEvent::ACTION_POINTER_UP, 2, 2, 3, 3, 4, 4); | |
| 1724 event.pointer_count = 2; | 1779 event.pointer_count = 2; |
| 1725 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1780 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1726 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); | 1781 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); |
| 1727 EXPECT_EQ(7U, GetReceivedGestureCount()); | 1782 EXPECT_EQ(7U, GetReceivedGestureCount()); |
| 1728 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 1783 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
| 1784 EXPECT_EQ(2, GetMostRecentGestureEvent().x); | |
| 1785 EXPECT_EQ(2, GetMostRecentGestureEvent().y); | |
| 1729 | 1786 |
| 1730 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP); | 1787 event = |
| 1788 ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP, 3, 3, 4, 4); | |
| 1731 event.pointer_count = 1; | 1789 event.pointer_count = 1; |
| 1732 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1790 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1733 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); | 1791 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); |
| 1734 EXPECT_EQ(8U, GetReceivedGestureCount()); | 1792 EXPECT_EQ(8U, GetReceivedGestureCount()); |
| 1735 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1793 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1794 EXPECT_EQ(3, GetMostRecentGestureEvent().x); | |
| 1795 EXPECT_EQ(3, GetMostRecentGestureEvent().y); | |
| 1736 | 1796 |
| 1737 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); | 1797 |
| 1798 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP, 4, 4); | |
| 1738 event.pointer_count = 1; | 1799 event.pointer_count = 1; |
| 1739 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1800 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1740 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); | 1801 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); |
| 1741 EXPECT_EQ(9U, GetReceivedGestureCount()); | 1802 EXPECT_EQ(9U, GetReceivedGestureCount()); |
| 1742 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1803 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1804 EXPECT_EQ(4, GetMostRecentGestureEvent().x); | |
| 1805 EXPECT_EQ(4, GetMostRecentGestureEvent().y); | |
| 1806 } | |
| 1743 | 1807 |
| 1744 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); | 1808 // Verify that gesture begin and gesture end events are dispatched correctly |
| 1809 // when an ACTION_CANCEL is received. | |
| 1810 TEST_F(GestureProviderTest, GestureBeginAndEndOnCancel) { | |
| 1811 EnableBeginEndTypes(); | |
| 1812 base::TimeTicks event_time = base::TimeTicks::Now(); | |
| 1813 | |
| 1814 EXPECT_EQ(0U, GetReceivedGestureCount()); | |
| 1815 MockMotionEvent event = | |
| 1816 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 1, 1); | |
| 1745 event.pointer_count = 1; | 1817 event.pointer_count = 1; |
| 1746 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1818 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1747 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(9).type); | 1819 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type); |
| 1748 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); | 1820 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); |
| 1749 EXPECT_EQ(11U, GetReceivedGestureCount()); | 1821 EXPECT_EQ(2U, GetReceivedGestureCount()); |
| 1750 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1822 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
| 1823 EXPECT_EQ(gfx::RectF(1 - kMockTouchRadius, | |
| 1824 1 - kMockTouchRadius, | |
| 1825 kMockTouchRadius * 2, | |
| 1826 kMockTouchRadius * 2), | |
| 1827 GetMostRecentGestureEvent().details.bounding_box()); | |
| 1828 EXPECT_EQ(1, GetMostRecentGestureEvent().x); | |
| 1829 EXPECT_EQ(1, GetMostRecentGestureEvent().y); | |
| 1751 | 1830 |
| 1752 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_CANCEL); | 1831 event = ObtainMotionEvent( |
| 1753 event.pointer_count = 1; | 1832 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2); |
| 1833 event.pointer_count = 2; | |
| 1754 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 1834 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1755 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType()); | 1835 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); |
| 1756 EXPECT_EQ(12U, GetReceivedGestureCount()); | 1836 EXPECT_EQ(3U, GetReceivedGestureCount()); |
| 1757 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 1837 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
| 1838 EXPECT_EQ(2, GetMostRecentGestureEvent().x); | |
| 1839 EXPECT_EQ(2, GetMostRecentGestureEvent().y); | |
| 1840 | |
| 1841 | |
| 1842 event = ObtainMotionEvent( | |
| 1843 event_time, MotionEvent::ACTION_POINTER_DOWN, 1, 1, 2, 2, 3, 3); | |
| 1844 event.pointer_count = 3; | |
| 1845 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | |
| 1846 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType()); | |
| 1847 EXPECT_EQ(4U, GetReceivedGestureCount()); | |
| 1848 EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points()); | |
| 1849 EXPECT_EQ(3, GetMostRecentGestureEvent().x); | |
| 1850 EXPECT_EQ(3, GetMostRecentGestureEvent().y); | |
| 1851 | |
| 1852 event = ObtainMotionEvent( | |
| 1853 event_time, MotionEvent::ACTION_CANCEL, 1, 1, 2, 2, 3, 3); | |
| 1854 event.pointer_count = 3; | |
| 1855 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | |
| 1856 EXPECT_EQ(7U, GetReceivedGestureCount()); | |
| 1857 EXPECT_EQ(3, GetReceivedGesture(4).details.touch_points()); | |
| 1858 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(4).details.type()); | |
| 1859 EXPECT_EQ(2, GetReceivedGesture(5).details.touch_points()); | |
| 1860 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(5).details.type()); | |
| 1861 EXPECT_EQ(1, GetReceivedGesture(6).details.touch_points()); | |
| 1862 EXPECT_EQ(ET_GESTURE_END, GetReceivedGesture(6).details.type()); | |
| 1863 EXPECT_EQ(1, GetReceivedGesture(4).x); | |
| 1864 EXPECT_EQ(1, GetReceivedGesture(4).y); | |
| 1865 EXPECT_EQ(2, GetReceivedGesture(5).x); | |
| 1866 EXPECT_EQ(2, GetReceivedGesture(5).y); | |
| 1867 EXPECT_EQ(3, GetReceivedGesture(6).x); | |
| 1868 EXPECT_EQ(3, GetReceivedGesture(6).y); | |
| 1758 } | 1869 } |
| 1759 | 1870 |
| 1760 | |
| 1761 // Test a simple two finger tap | 1871 // Test a simple two finger tap |
| 1762 TEST_F(GestureProviderTest, TwoFingerTap) { | 1872 TEST_F(GestureProviderTest, TwoFingerTap) { |
| 1763 // The time between ACTION_POINTER_DOWN and ACTION_POINTER_UP must be <= the | 1873 // The time between ACTION_POINTER_DOWN and ACTION_POINTER_UP must be <= the |
| 1764 // two finger tap delay. | 1874 // two finger tap delay. |
| 1765 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); | 1875 EnableTwoFingerTap(kMaxTwoFingerTapSeparation, base::TimeDelta()); |
| 1766 const float scaled_touch_slop = GetTouchSlop(); | 1876 const float scaled_touch_slop = GetTouchSlop(); |
| 1767 | 1877 |
| 1768 base::TimeTicks event_time = base::TimeTicks::Now(); | 1878 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 1769 | 1879 |
| 1770 MockMotionEvent event = | 1880 MockMotionEvent event = |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1992 secondary_coord_x + kMinPinchUpdateDistance + | 2102 secondary_coord_x + kMinPinchUpdateDistance + |
| 1993 kOvershootMinPinchUpdateDistance, | 2103 kOvershootMinPinchUpdateDistance, |
| 1994 secondary_coord_y); | 2104 secondary_coord_y); |
| 1995 | 2105 |
| 1996 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2106 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 1997 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_UPDATE)); | 2107 EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_PINCH_UPDATE)); |
| 1998 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); | 2108 EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points()); |
| 1999 } | 2109 } |
| 2000 | 2110 |
| 2001 } // namespace ui | 2111 } // namespace ui |
| OLD | NEW |