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

Side by Side Diff: content/browser/renderer_host/input/touch_action_browsertest.cc

Issue 183013010: Don't send touchcancel on touch scroll start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a couple tests Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture.h"
11 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" 11 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
12 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 12 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
13 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h" 13 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
14 #include "content/browser/renderer_host/input/touch_event_queue.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h" 15 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "content/browser/web_contents/web_contents_impl.h" 16 #include "content/browser/web_contents/web_contents_impl.h"
16 #include "content/common/input/synthetic_gesture_params.h" 17 #include "content/common/input/synthetic_gesture_params.h"
17 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 18 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
18 #include "content/common/input_messages.h" 19 #include "content/common/input_messages.h"
19 #include "content/port/browser/render_widget_host_view_port.h" 20 #include "content/port/browser/render_widget_host_view_port.h"
20 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/render_widget_host_view.h" 22 #include "content/public/browser/render_widget_host_view.h"
22 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
23 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Verify the test infrastructure works - we can touch-scroll the page and get a 175 // Verify the test infrastructure works - we can touch-scroll the page and get a
175 // touchcancel as expected. 176 // touchcancel as expected.
176 IN_PROC_BROWSER_TEST_F(TouchActionBrowserTest, MAYBE_DefaultAuto) { 177 IN_PROC_BROWSER_TEST_F(TouchActionBrowserTest, MAYBE_DefaultAuto) {
177 LoadURL(); 178 LoadURL();
178 179
179 bool scrolled = DoTouchScroll(gfx::Point(50, 50), gfx::Vector2d(0, 45)); 180 bool scrolled = DoTouchScroll(gfx::Point(50, 50), gfx::Vector2d(0, 45));
180 EXPECT_TRUE(scrolled); 181 EXPECT_TRUE(scrolled);
181 182
182 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart")); 183 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart"));
183 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchmove")); 184 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchmove"));
184 // Note, if we ship touch-absorption (crbug.com/346693) this will change to 185 if (TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT ==
185 // 1 end event and 0 cancel events. 186 TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL) {
186 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchend")); 187 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchend"));
187 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchcancel")); 188 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchcancel"));
189 } else {
190 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend"));
191 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel"));
192 }
188 } 193 }
189 194
190 // Verify that touching a touch-action: none region disables scrolling and 195 // Verify that touching a touch-action: none region disables scrolling and
191 // enables all touch events to be sent. 196 // enables all touch events to be sent.
192 IN_PROC_BROWSER_TEST_F(TouchActionBrowserTest, TouchActionNone) { 197 IN_PROC_BROWSER_TEST_F(TouchActionBrowserTest, TouchActionNone) {
193 LoadURL(); 198 LoadURL();
194 199
195 bool scrolled = DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45)); 200 bool scrolled = DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45));
196 EXPECT_FALSE(scrolled); 201 EXPECT_FALSE(scrolled);
197 202
198 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart")); 203 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart"));
199 EXPECT_GT(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1); 204 EXPECT_GT(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1);
200 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend")); 205 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend"));
201 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel")); 206 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel"));
202 } 207 }
203 208
204 } // namespace content 209 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698