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

Unified Diff: content/browser/renderer_host/input/touch_action_filter_unittest.cc

Issue 2126323002: Add support for touch-action: pinch-zoom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add exception for mac Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/input/touch_action_filter.cc ('k') | content/common/input_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/touch_action_filter_unittest.cc
diff --git a/content/browser/renderer_host/input/touch_action_filter_unittest.cc b/content/browser/renderer_host/input/touch_action_filter_unittest.cc
index 7bb48a02d49441fff2de39e64c6988651462b8f9..f200c4f1f5bcc525ab78633d5826052c024866a7 100644
--- a/content/browser/renderer_host/input/touch_action_filter_unittest.cc
+++ b/content/browser/renderer_host/input/touch_action_filter_unittest.cc
@@ -451,13 +451,7 @@ TEST(TouchActionFilterTest, Pinch) {
EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end));
- // Pinching can become disallowed during a single scroll gesture, but
- // can't become allowed again until the scroll terminates.
- // Note that the current TouchEventQueue design makes this scenario
- // impossible in practice (no touch events are sent to the renderer
- // while scrolling) and so no SetTouchAction can occur. But this
- // could change in the future, so it's still worth verifying in this
- // unit test.
+ // Pinching is only computed at GestureScrollBegin time.
filter.ResetTouchAction();
filter.OnSetTouchAction(TOUCH_ACTION_AUTO);
EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin));
@@ -465,17 +459,17 @@ TEST(TouchActionFilterTest, Pinch) {
EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
filter.OnSetTouchAction(TOUCH_ACTION_NONE);
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_begin));
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_update));
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_end));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
filter.OnSetTouchAction(TOUCH_ACTION_AUTO);
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_begin));
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_update));
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_end));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end));
- // Once a pinch has started, any change in state won't affect the current
- // pinch gesture, but can affect a future one within the same scroll.
+ // Once a pinch has started, any change in state won't affect the pinch
+ // gestures since it is computed in GestureScrollBegin.
filter.ResetTouchAction();
filter.OnSetTouchAction(TOUCH_ACTION_AUTO);
EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin));
@@ -483,11 +477,32 @@ TEST(TouchActionFilterTest, Pinch) {
filter.OnSetTouchAction(TOUCH_ACTION_NONE);
EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_begin));
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_update));
- EXPECT_TRUE(filter.FilterGestureEvent(&pinch_end));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end));
filter.ResetTouchAction();
+
+ scroll_begin.data.scrollBegin.pointerCount = 1;
+ // Scrolling should be disallowed for pinch zoom with only
+ // one pointer down.
+ filter.OnSetTouchAction(TOUCH_ACTION_PINCH_ZOOM);
+ EXPECT_TRUE(filter.FilterGestureEvent(&scroll_begin));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
+ EXPECT_TRUE(filter.FilterGestureEvent(&scroll_end));
+
+ scroll_begin.data.scrollBegin.pointerCount = 2;
+
+ // Scrolling is allowed when two fingers are down.
+ filter.ResetTouchAction();
+ filter.OnSetTouchAction(TOUCH_ACTION_PINCH_ZOOM);
+ EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
+ EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
+ EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end));
}
TEST(TouchActionFilterTest, DoubleTapWithTouchActionAuto) {
« no previous file with comments | « content/browser/renderer_host/input/touch_action_filter.cc ('k') | content/common/input_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698