1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file.
4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/auto_reset.h"
6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/bind.h"
7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/command_line.h"
8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/run_loop.h"
9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/renderer_host/input/synthetic_gesture.h"
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/renderer_host/input/touch_event_queue.h"
15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/renderer_host/render_widget_host_impl.h"
16010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "content/browser/renderer_host/render_widget_host_view_base.h"
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/browser/web_contents/web_contents_impl.h"
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/common/input/synthetic_gesture_params.h"
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/common/input_messages.h"
21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/browser/render_view_host.h"
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/browser/render_widget_host_view.h"
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/common/content_switches.h"
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/test/browser_test_utils.h"
25effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "content/public/test/content_browser_test.h"
26effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "content/public/test/content_browser_test_utils.h"
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/test/test_utils.h"
28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/shell/browser/shell.h"
29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "third_party/WebKit/public/web/WebInputEvent.h"
30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/events/event_switches.h"
31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/events/latency_info.h"
32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using blink::WebInputEvent;
34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace {
36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const char kTouchActionDataURL[] =
38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "data:text/html;charset=utf-8,"
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "<!DOCTYPE html>"
40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "<meta name='viewport' content='width=device-width'/>"
41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "<style>"
42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "html, body {"
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  margin: 0;"
44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "}"
45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ".box {"
46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  height: 96px;"
47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  width: 96px;"
48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  border: 2px solid blue;"
49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "}"
50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ".spacer { height: 1000px; }"
51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ".ta-none { touch-action: none; }"
52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "</style>"
53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "<div class=box></div>"
54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "<div class='box ta-none'></div>"
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "<div class=spacer></div>"
56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "<script>"
57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  window.eventCounts = "
58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "    {touchstart:0, touchmove:0, touchend: 0, touchcancel:0};"
59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  function countEvent(e) { eventCounts[e.type]++; }"
60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  for (var evt in eventCounts) { "
61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "    document.addEventListener(evt, countEvent); "
62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  }"
63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "  document.title='ready';"
64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    "</script>";
65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}  // namespace
67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace content {
69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class TouchActionBrowserTest : public ContentBrowserTest {
72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public:
73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  TouchActionBrowserTest() {}
74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual ~TouchActionBrowserTest() {}
75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
76a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  RenderWidgetHostImpl* GetWidgetHost() {
77a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return RenderWidgetHostImpl::From(shell()->web_contents()->
78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          GetRenderViewHost());
79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
80a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
81a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void OnSyntheticGestureCompleted(SyntheticGesture::Result result) {
82a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
83a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    runner_->Quit();
84a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
85a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
86a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) protected:
87a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void LoadURL() {
88a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const GURL data_url(kTouchActionDataURL);
89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    NavigateToURL(shell(), data_url);
90a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    RenderWidgetHostImpl* host = GetWidgetHost();
92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    host->GetView()->SetSize(gfx::Size(400, 400));
93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    base::string16 ready_title(base::ASCIIToUTF16("ready"));
95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    TitleWatcher watcher(shell()->web_contents(), ready_title);
96a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ignore_result(watcher.WaitAndGetTitle());
97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // ContentBrowserTest:
100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual void SetUpCommandLine(CommandLine* cmd) OVERRIDE {
101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    cmd->AppendSwitchASCII(switches::kTouchEvents,
102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                           switches::kTouchEventsEnabled);
103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // TODO(rbyers): Remove this switch once touch-action ships.
104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // http://crbug.com/241964
105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    cmd->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures);
106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  int ExecuteScriptAndExtractInt(const std::string& script) {
109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    int value = 0;
110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        shell()->web_contents(),
112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        "domAutomationController.send(" + script + ")",
113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        &value));
114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return value;
115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  int GetScrollTop() {
118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return ExecuteScriptAndExtractInt("document.documentElement.scrollTop");
119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Generate touch events for a synthetic scroll from |point| for |distance|.
122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Returns true if the page scrolled by the desired amount, and false if
123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // it didn't scroll at all.
124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bool DoTouchScroll(const gfx::Point& point, const gfx::Vector2d& distance) {
125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(0, GetScrollTop());
126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    int scrollHeight = ExecuteScriptAndExtractInt(
128a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        "document.documentElement.scrollHeight");
129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(1200, scrollHeight);
130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SyntheticSmoothScrollGestureParams params;
132a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    params.anchor = point;
13423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    params.distances.push_back(-distance);
135a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
136a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    runner_ = new MessageLoopRunner();
137a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    scoped_ptr<SyntheticSmoothScrollGesture> gesture(
139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        new SyntheticSmoothScrollGesture(params));
140a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GetWidgetHost()->QueueSyntheticGesture(
141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        gesture.PassAs<SyntheticGesture>(),
142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)        base::Bind(&TouchActionBrowserTest::OnSyntheticGestureCompleted,
143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)            base::Unretained(this)));
144a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Runs until we get the OnSyntheticGestureCompleted callback
146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    runner_->Run();
147a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    runner_ = NULL;
148a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
149a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Check the scroll offset
150a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    int scrollTop = GetScrollTop();
151a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    if (scrollTop == 0)
152a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      return false;
153a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
154a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(distance.y(), scrollTop);
155a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return true;
156a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
157a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
158a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private:
159a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  scoped_refptr<MessageLoopRunner> runner_;
160a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
161a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TouchActionBrowserTest);
162a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)};
163a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
164a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// TouchActionBrowserTest.DefaultAuto fails under ThreadSanitizer v2, see
16523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// http://crbug.com/348539 and is flaky on XP, see
16623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// http://crbug.com/354763
16723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)//
1680529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// Mac doesn't yet have a gesture recognizer, so can't support turning touch
1690529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// events into scroll gestures.
170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Will be fixed with http://crbug.com/337142
17123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)//
172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Verify the test infrastructure works - we can touch-scroll the page and get a
173a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// touchcancel as expected.
17423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(TouchActionBrowserTest, DISABLED_DefaultAuto) {
175a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  LoadURL();
176a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
177a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bool scrolled = DoTouchScroll(gfx::Point(50, 50), gfx::Vector2d(0, 45));
178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_TRUE(scrolled);
179a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
180a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart"));
181a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchmove"));
182a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT ==
183a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL) {
184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchend"));
185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchcancel"));
186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  } else {
187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend"));
188a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel"));
189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
191a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Verify that touching a touch-action: none region disables scrolling and
193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// enables all touch events to be sent.
1940529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// Disabled on MacOS because it doesn't support touch input.
195116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// It's just flaky everywhere.
196116680a4aac90f2aa7413d9095a592090648e557Ben MurdochIN_PROC_BROWSER_TEST_F(TouchActionBrowserTest, DISABLED_TouchActionNone) {
197a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  LoadURL();
198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
199a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bool scrolled = DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45));
200a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_FALSE(scrolled);
201a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
202a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart"));
203a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_GT(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1);
204a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend"));
205a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel"));
206a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
207a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
208a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}  // namespace content
209