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

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewGestureHandlerTest.java

Issue 18850005: Disable double tap zoom on mobile sites, to remove 300ms click delay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 // If events are delivered at vsync, multiple SCROLL_BY and PINCH_BY eve nts should still 1799 // If events are delivered at vsync, multiple SCROLL_BY and PINCH_BY eve nts should still
1800 // trigger only a single vsync from any given call to confirmTouchEvent( ). 1800 // trigger only a single vsync from any given call to confirmTouchEvent( ).
1801 if (inputEventsDeliveredAtVSync) { 1801 if (inputEventsDeliveredAtVSync) {
1802 assertEquals(1, mMockMotionEventDelegate.mTotalSentLastGestureForVSy ncCount); 1802 assertEquals(1, mMockMotionEventDelegate.mTotalSentLastGestureForVSy ncCount);
1803 } else { 1803 } else {
1804 assertEquals(0, mMockMotionEventDelegate.mTotalSentLastGestureForVSy ncCount); 1804 assertEquals(0, mMockMotionEventDelegate.mTotalSentLastGestureForVSy ncCount);
1805 } 1805 }
1806 } 1806 }
1807 1807
1808 /** 1808 /**
1809 * Verify that no double tap gestures are created if the page has a fixed 1809 * Verify that no double tap gestures are created if the gesture handler is
1810 * page scale. 1810 * told to disable double tap gesture detection (according to the logic in
1811 * ContentViewCore.onRenderCoordinatesUpdated).
1811 * @throws Exception 1812 * @throws Exception
1812 */ 1813 */
1813 @SmallTest 1814 @SmallTest
1814 @Feature({"Gestures"}) 1815 @Feature({"Gestures"})
1815 public void testNoDoubleTapWhenPageScaleFixed() throws Exception { 1816 public void testNoDoubleTapWhenDoubleTapDisabled() throws Exception {
1816 final long downTime = SystemClock.uptimeMillis(); 1817 final long downTime = SystemClock.uptimeMillis();
1817 final long eventTime = SystemClock.uptimeMillis(); 1818 final long eventTime = SystemClock.uptimeMillis();
1818 1819
1819 GestureRecordingMotionEventDelegate mockDelegate = 1820 GestureRecordingMotionEventDelegate mockDelegate =
1820 new GestureRecordingMotionEventDelegate(); 1821 new GestureRecordingMotionEventDelegate();
1821 mGestureHandler = new ContentViewGestureHandler( 1822 mGestureHandler = new ContentViewGestureHandler(
1822 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom Manager, 1823 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom Manager,
1823 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC); 1824 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC);
1824 mGestureHandler.updateHasFixedPageScale(true); 1825 mGestureHandler.updateShouldDisableDoubleTap(true);
1825 1826
1826 MotionEvent event = MotionEvent.obtain( 1827 MotionEvent event = MotionEvent.obtain(
1827 downTime, downTime, MotionEvent.ACTION_DOWN, 1828 downTime, downTime, MotionEvent.ACTION_DOWN,
1828 FAKE_COORD_X, FAKE_COORD_Y, 0); 1829 FAKE_COORD_X, FAKE_COORD_Y, 0);
1829 assertTrue(mGestureHandler.onTouchEvent(event)); 1830 assertTrue(mGestureHandler.onTouchEvent(event));
1830 assertEquals("Only GESTURE_TAP_DOWN should have been sent", 1831 assertEquals("Only GESTURE_TAP_DOWN should have been sent",
1831 1, mockDelegate.mGestureTypeList.size()); 1832 1, mockDelegate.mGestureTypeList.size());
1832 1833
1833 event = MotionEvent.obtain( 1834 event = MotionEvent.obtain(
1834 downTime, eventTime + 5, MotionEvent.ACTION_UP, 1835 downTime, eventTime + 5, MotionEvent.ACTION_UP,
(...skipping 23 matching lines...) Expand all
1858 ContentViewGestureHandler.GESTURE_SINGLE_TAP_CONFIRMED, 1859 ContentViewGestureHandler.GESTURE_SINGLE_TAP_CONFIRMED,
1859 mockDelegate.mMostRecentGestureEvent.mType); 1860 mockDelegate.mMostRecentGestureEvent.mType);
1860 assertEquals("Only GESTURE_TAP_DOWN, " + 1861 assertEquals("Only GESTURE_TAP_DOWN, " +
1861 "GESTURE_SINGLE_TAP_CONFIRMED, " + 1862 "GESTURE_SINGLE_TAP_CONFIRMED, " +
1862 "GESTURE_TAP_DOWN and " + 1863 "GESTURE_TAP_DOWN and " +
1863 "GESTURE_SINGLE_TAP_CONFIRMED should have been sent", 1864 "GESTURE_SINGLE_TAP_CONFIRMED should have been sent",
1864 4, mockDelegate.mGestureTypeList.size()); 1865 4, mockDelegate.mGestureTypeList.size());
1865 } 1866 }
1866 1867
1867 /** 1868 /**
1868 * Verify that double tap drag zoom feature is not invoked 1869 * Verify that double tap drag zoom feature is not invoked when the gesture
1869 * when the page scale is fixed. The second tap sequence should be 1870 * handler is told to disable double tap gesture detection (according to the
1870 * treated just as the first would be. 1871 * logic in ContentViewCore.onRenderCoordinatesUpdated).
1872 * The second tap sequence should be treated just as the first would be.
1871 * @throws Exception 1873 * @throws Exception
1872 */ 1874 */
1873 @SmallTest 1875 @SmallTest
1874 @Feature({"Gestures"}) 1876 @Feature({"Gestures"})
1875 public void testNoDoubleTapDragZoomWhenPageScaleFixed() throws Exception { 1877 public void testNoDoubleTapDragZoomWhenDoubleTapDisabled() throws Exception {
1876 final long downTime1 = SystemClock.uptimeMillis(); 1878 final long downTime1 = SystemClock.uptimeMillis();
1877 final long downTime2 = downTime1 + 100; 1879 final long downTime2 = downTime1 + 100;
1878 1880
1879 GestureRecordingMotionEventDelegate mockDelegate = 1881 GestureRecordingMotionEventDelegate mockDelegate =
1880 new GestureRecordingMotionEventDelegate(); 1882 new GestureRecordingMotionEventDelegate();
1881 mGestureHandler = new ContentViewGestureHandler( 1883 mGestureHandler = new ContentViewGestureHandler(
1882 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom Manager, 1884 getInstrumentation().getTargetContext(), mockDelegate, mMockZoom Manager,
1883 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC); 1885 ContentViewCore.INPUT_EVENTS_DELIVERED_AT_VSYNC);
1884 mGestureHandler.updateHasFixedPageScale(true); 1886 mGestureHandler.updateShouldDisableDoubleTap(true);
1885 1887
1886 MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, downTime1, down Time1); 1888 MotionEvent event = motionEvent(MotionEvent.ACTION_DOWN, downTime1, down Time1);
1887 assertTrue(mGestureHandler.onTouchEvent(event)); 1889 assertTrue(mGestureHandler.onTouchEvent(event));
1888 1890
1889 event = MotionEvent.obtain( 1891 event = MotionEvent.obtain(
1890 downTime1, downTime1 + 5, MotionEvent.ACTION_UP, 1892 downTime1, downTime1 + 5, MotionEvent.ACTION_UP,
1891 FAKE_COORD_X, FAKE_COORD_Y, 0); 1893 FAKE_COORD_X, FAKE_COORD_Y, 0);
1892 mGestureHandler.onTouchEvent(event); 1894 mGestureHandler.onTouchEvent(event);
1893 1895
1894 event = MotionEvent.obtain( 1896 event = MotionEvent.obtain(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 event = MotionEvent.obtain( 1929 event = MotionEvent.obtain(
1928 downTime2, downTime2 + 15, MotionEvent.ACTION_UP, 1930 downTime2, downTime2 + 15, MotionEvent.ACTION_UP,
1929 FAKE_COORD_X, FAKE_COORD_Y + 200, 0); 1931 FAKE_COORD_X, FAKE_COORD_Y + 200, 0);
1930 assertTrue(mGestureHandler.onTouchEvent(event)); 1932 assertTrue(mGestureHandler.onTouchEvent(event));
1931 assertFalse("No GESTURE_PINCH_END should have been sent", 1933 assertFalse("No GESTURE_PINCH_END should have been sent",
1932 mockDelegate.mGestureTypeList.contains( 1934 mockDelegate.mGestureTypeList.contains(
1933 ContentViewGestureHandler.GESTURE_PINCH_END)); 1935 ContentViewGestureHandler.GESTURE_PINCH_END));
1934 } 1936 }
1935 1937
1936 /** 1938 /**
1937 * Verify that setting a fixed page scale during a double tap drag zoom disa bles 1939 * Verify that setting a fixed page scale (or a mobile viewport) during a do uble
1938 * double tap detection after the gesture has ended. 1940 * tap drag zoom disables double tap detection after the gesture has ended.
1939 * @throws Exception 1941 * @throws Exception
1940 */ 1942 */
1941 @SmallTest 1943 @SmallTest
1942 @Feature({"Gestures"}) 1944 @Feature({"Gestures"})
1943 public void testFixedPageScaleDuringDoubleTapDragZoom() throws Exception { 1945 public void testFixedPageScaleDuringDoubleTapDragZoom() throws Exception {
1944 long downTime1 = SystemClock.uptimeMillis(); 1946 long downTime1 = SystemClock.uptimeMillis();
1945 long downTime2 = downTime1 + 100; 1947 long downTime2 = downTime1 + 100;
1946 1948
1947 GestureRecordingMotionEventDelegate mockDelegate = 1949 GestureRecordingMotionEventDelegate mockDelegate =
1948 new GestureRecordingMotionEventDelegate(); 1950 new GestureRecordingMotionEventDelegate();
(...skipping 19 matching lines...) Expand all
1968 downTime2, downTime2 + 5, MotionEvent.ACTION_MOVE, 1970 downTime2, downTime2 + 5, MotionEvent.ACTION_MOVE,
1969 FAKE_COORD_X, FAKE_COORD_Y + 100, 0); 1971 FAKE_COORD_X, FAKE_COORD_Y + 100, 0);
1970 assertTrue(mGestureHandler.onTouchEvent(event)); 1972 assertTrue(mGestureHandler.onTouchEvent(event));
1971 assertTrue("GESTURE_SCROLL_START should have been sent", 1973 assertTrue("GESTURE_SCROLL_START should have been sent",
1972 mockDelegate.mGestureTypeList.contains( 1974 mockDelegate.mGestureTypeList.contains(
1973 ContentViewGestureHandler.GESTURE_SCROLL_START)); 1975 ContentViewGestureHandler.GESTURE_SCROLL_START));
1974 assertEquals("GESTURE_PINCH_BEGIN should have been sent", 1976 assertEquals("GESTURE_PINCH_BEGIN should have been sent",
1975 ContentViewGestureHandler.GESTURE_PINCH_BEGIN, 1977 ContentViewGestureHandler.GESTURE_PINCH_BEGIN,
1976 mockDelegate.mMostRecentGestureEvent.mType); 1978 mockDelegate.mMostRecentGestureEvent.mType);
1977 1979
1978 // Set a fixed page scale; this should not disrupt the current double-ta p gesture. 1980 // Simulate setting a fixed page scale (or a mobile viewport);
1979 mGestureHandler.updateHasFixedPageScale(true); 1981 // this should not disrupt the current double-tap gesture.
1982 mGestureHandler.updateShouldDisableDoubleTap(true);
1980 1983
1981 // Double tap zoom updates should continue. 1984 // Double tap zoom updates should continue.
1982 event = MotionEvent.obtain( 1985 event = MotionEvent.obtain(
1983 downTime2, downTime2 + 10, MotionEvent.ACTION_MOVE, 1986 downTime2, downTime2 + 10, MotionEvent.ACTION_MOVE,
1984 FAKE_COORD_X, FAKE_COORD_Y + 200, 0); 1987 FAKE_COORD_X, FAKE_COORD_Y + 200, 0);
1985 assertTrue(mGestureHandler.onTouchEvent(event)); 1988 assertTrue(mGestureHandler.onTouchEvent(event));
1986 assertTrue("GESTURE_SCROLL_BY should have been sent", 1989 assertTrue("GESTURE_SCROLL_BY should have been sent",
1987 mockDelegate.mGestureTypeList.contains( 1990 mockDelegate.mGestureTypeList.contains(
1988 ContentViewGestureHandler.GESTURE_SCROLL_BY)); 1991 ContentViewGestureHandler.GESTURE_SCROLL_BY));
1989 assertEquals("GESTURE_PINCH_BY should have been sent", 1992 assertEquals("GESTURE_PINCH_BY should have been sent",
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 event = MotionEvent.obtain( 2046 event = MotionEvent.obtain(
2044 downTime2, downTime2 + 15, MotionEvent.ACTION_UP, 2047 downTime2, downTime2 + 15, MotionEvent.ACTION_UP,
2045 FAKE_COORD_X, FAKE_COORD_Y + 200, 0); 2048 FAKE_COORD_X, FAKE_COORD_Y + 200, 0);
2046 assertTrue(mGestureHandler.onTouchEvent(event)); 2049 assertTrue(mGestureHandler.onTouchEvent(event));
2047 assertFalse("GESTURE_PINCH_END should not have been sent", 2050 assertFalse("GESTURE_PINCH_END should not have been sent",
2048 mockDelegate.mGestureTypeList.contains( 2051 mockDelegate.mGestureTypeList.contains(
2049 ContentViewGestureHandler.GESTURE_PINCH_END)); 2052 ContentViewGestureHandler.GESTURE_PINCH_END));
2050 } 2053 }
2051 2054
2052 } 2055 }
OLDNEW
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/RenderCoordinates.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698