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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.Build; | 8 import android.os.Build; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 import android.os.SystemClock; | 10 import android.os.SystemClock; |
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 // If events are delivered at vsync, multiple SCROLL_BY and PINCH_BY eve
nts should still | 1766 // If events are delivered at vsync, multiple SCROLL_BY and PINCH_BY eve
nts should still |
1767 // trigger only a single vsync from any given call to confirmTouchEvent(
). | 1767 // trigger only a single vsync from any given call to confirmTouchEvent(
). |
1768 if (inputEventsDeliveredAtVSync) { | 1768 if (inputEventsDeliveredAtVSync) { |
1769 assertEquals(1, mMockMotionEventDelegate.mTotalSentLastGestureForVSy
ncCount); | 1769 assertEquals(1, mMockMotionEventDelegate.mTotalSentLastGestureForVSy
ncCount); |
1770 } else { | 1770 } else { |
1771 assertEquals(0, mMockMotionEventDelegate.mTotalSentLastGestureForVSy
ncCount); | 1771 assertEquals(0, mMockMotionEventDelegate.mTotalSentLastGestureForVSy
ncCount); |
1772 } | 1772 } |
1773 } | 1773 } |
1774 | 1774 |
1775 /** | 1775 /** |
1776 * Verify that no double tap gestures are created if the page has a fixed | 1776 * Verify that no double tap gestures are created if the gesture handler is |
1777 * page scale. | 1777 * told to disable double tap gesture detection (according to the logic in |
| 1778 * ContentViewCore.onRenderCoordinatesUpdated). |
1778 * @throws Exception | 1779 * @throws Exception |
1779 */ | 1780 */ |
1780 @SmallTest | 1781 @SmallTest |
1781 @Feature({"Gestures"}) | 1782 @Feature({"Gestures"}) |
1782 public void testNoDoubleTapWhenPageScaleFixed() throws Exception { | 1783 public void testNoDoubleTapWhenDoubleTapDisabled() throws Exception { |
1783 final long downTime = SystemClock.uptimeMillis(); | 1784 final long downTime = SystemClock.uptimeMillis(); |
1784 final long eventTime = SystemClock.uptimeMillis(); | 1785 final long eventTime = SystemClock.uptimeMillis(); |
1785 | 1786 |
1786 GestureRecordingMotionEventDelegate mockDelegate = | 1787 GestureRecordingMotionEventDelegate mockDelegate = |
1787 new GestureRecordingMotionEventDelegate(); | 1788 new GestureRecordingMotionEventDelegate(); |
1788 mGestureHandler = new ContentViewGestureHandler( | 1789 mGestureHandler = new ContentViewGestureHandler( |
1789 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom
Manager, | 1790 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom
Manager, |
1790 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC); | 1791 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC); |
1791 mGestureHandler.updateHasFixedPageScale(true); | 1792 mGestureHandler.updateShouldDisableDoubleTap(true); |
1792 | 1793 |
1793 MotionEvent event = MotionEvent.obtain( | 1794 MotionEvent event = MotionEvent.obtain( |
1794 downTime, downTime, MotionEvent.ACTION_DOWN, | 1795 downTime, downTime, MotionEvent.ACTION_DOWN, |
1795 FAKE_COORD_X, FAKE_COORD_Y, 0); | 1796 FAKE_COORD_X, FAKE_COORD_Y, 0); |
1796 assertTrue(mGestureHandler.onTouchEvent(event)); | 1797 assertTrue(mGestureHandler.onTouchEvent(event)); |
1797 assertEquals("No events should have been sent", | 1798 assertEquals("No events should have been sent", |
1798 0, mockDelegate.mGestureTypeList.size()); | 1799 0, mockDelegate.mGestureTypeList.size()); |
1799 | 1800 |
1800 event = MotionEvent.obtain( | 1801 event = MotionEvent.obtain( |
1801 downTime, eventTime + 5, MotionEvent.ACTION_UP, | 1802 downTime, eventTime + 5, MotionEvent.ACTION_UP, |
(...skipping 18 matching lines...) Expand all Loading... |
1820 assertTrue(mGestureHandler.onTouchEvent(event)); | 1821 assertTrue(mGestureHandler.onTouchEvent(event)); |
1821 assertEquals("A double tap should not have occurred", | 1822 assertEquals("A double tap should not have occurred", |
1822 ContentViewGestureHandler.GESTURE_SINGLE_TAP_CONFIRMED, | 1823 ContentViewGestureHandler.GESTURE_SINGLE_TAP_CONFIRMED, |
1823 mockDelegate.mMostRecentGestureEvent.mType); | 1824 mockDelegate.mMostRecentGestureEvent.mType); |
1824 assertEquals("Only GESTURE_SINGLE_TAP_CONFIRMED and " + | 1825 assertEquals("Only GESTURE_SINGLE_TAP_CONFIRMED and " + |
1825 "GESTURE_SINGLE_TAP_CONFIRMED should have been sent", | 1826 "GESTURE_SINGLE_TAP_CONFIRMED should have been sent", |
1826 2, mockDelegate.mGestureTypeList.size()); | 1827 2, mockDelegate.mGestureTypeList.size()); |
1827 } | 1828 } |
1828 | 1829 |
1829 /** | 1830 /** |
1830 * Verify that double tap drag zoom feature is not invoked | 1831 * Verify that double tap drag zoom feature is not invoked when the gesture |
1831 * when the page scale is fixed. The second tap sequence should be | 1832 * handler is told to disable double tap gesture detection (according to the |
1832 * treated just as the first would be. | 1833 * logic in ContentViewCore.onRenderCoordinatesUpdated). |
| 1834 * The second tap sequence should be treated just as the first would be. |
1833 * @throws Exception | 1835 * @throws Exception |
1834 */ | 1836 */ |
1835 @SmallTest | 1837 @SmallTest |
1836 @Feature({"Gestures"}) | 1838 @Feature({"Gestures"}) |
1837 public void testNoDoubleTapDragZoomWhenPageScaleFixed() throws Exception { | 1839 public void testNoDoubleTapDragZoomWhenDoubleTapDisabled() throws Exception
{ |
1838 final long downTime1 = SystemClock.uptimeMillis(); | 1840 final long downTime1 = SystemClock.uptimeMillis(); |
1839 final long downTime2 = downTime1 + 100; | 1841 final long downTime2 = downTime1 + 100; |
1840 | 1842 |
1841 GestureRecordingMotionEventDelegate mockDelegate = | 1843 GestureRecordingMotionEventDelegate mockDelegate = |
1842 new GestureRecordingMotionEventDelegate(); | 1844 new GestureRecordingMotionEventDelegate(); |
1843 mGestureHandler = new ContentViewGestureHandler( | 1845 mGestureHandler = new ContentViewGestureHandler( |
1844 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom
Manager, | 1846 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom
Manager, |
1845 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC); | 1847 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC); |
1846 mGestureHandler.updateHasFixedPageScale(true); | 1848 mGestureHandler.updateShouldDisableDoubleTap(true); |
1847 | 1849 |
1848 MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, downTime1, down
Time1); | 1850 MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, downTime1, down
Time1); |
1849 assertTrue(mGestureHandler.onTouchEvent(event)); | 1851 assertTrue(mGestureHandler.onTouchEvent(event)); |
1850 | 1852 |
1851 event = MotionEvent.obtain( | 1853 event = MotionEvent.obtain( |
1852 downTime1, downTime1 + 5, MotionEvent.ACTION_UP, | 1854 downTime1, downTime1 + 5, MotionEvent.ACTION_UP, |
1853 FAKE_COORD_X, FAKE_COORD_Y, 0); | 1855 FAKE_COORD_X, FAKE_COORD_Y, 0); |
1854 mGestureHandler.onTouchEvent(event); | 1856 mGestureHandler.onTouchEvent(event); |
1855 | 1857 |
1856 event = MotionEvent.obtain( | 1858 event = MotionEvent.obtain( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 | 1890 |
1889 event = MotionEvent.obtain( | 1891 event = MotionEvent.obtain( |
1890 downTime2, downTime2 + 15, MotionEvent.ACTION_UP, | 1892 downTime2, downTime2 + 15, MotionEvent.ACTION_UP, |
1891 FAKE_COORD_X, FAKE_COORD_Y + 200, 0); | 1893 FAKE_COORD_X, FAKE_COORD_Y + 200, 0); |
1892 assertTrue(mGestureHandler.onTouchEvent(event)); | 1894 assertTrue(mGestureHandler.onTouchEvent(event)); |
1893 assertFalse("No GESTURE_PINCH_END should have been sent", | 1895 assertFalse("No GESTURE_PINCH_END should have been sent", |
1894 mockDelegate.mGestureTypeList.contains( | 1896 mockDelegate.mGestureTypeList.contains( |
1895 ContentViewGestureHandler.GESTURE_PINCH_END)); | 1897 ContentViewGestureHandler.GESTURE_PINCH_END)); |
1896 } | 1898 } |
1897 } | 1899 } |
OLD | NEW |