OLD | NEW |
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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/common/input_messages.h" | 24 #include "content/common/input_messages.h" |
25 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/render_widget_host_view.h" | 26 #include "content/public/browser/render_widget_host_view.h" |
27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
28 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
29 #include "content/public/test/content_browser_test.h" | 29 #include "content/public/test/content_browser_test.h" |
30 #include "content/public/test/content_browser_test_utils.h" | 30 #include "content/public/test/content_browser_test_utils.h" |
31 #include "content/public/test/test_utils.h" | 31 #include "content/public/test/test_utils.h" |
32 #include "content/shell/browser/shell.h" | 32 #include "content/shell/browser/shell.h" |
33 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 33 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
34 #include "ui/events/event_switches.h" | |
35 #include "ui/events/latency_info.h" | 34 #include "ui/events/latency_info.h" |
36 | 35 |
37 using blink::WebInputEvent; | 36 using blink::WebInputEvent; |
38 | 37 |
39 namespace { | 38 namespace { |
40 | 39 |
41 const char kTouchActionDataURL[] = | 40 const char kTouchActionDataURL[] = |
42 "data:text/html;charset=utf-8," | 41 "data:text/html;charset=utf-8," |
43 "<!DOCTYPE html>" | 42 "<!DOCTYPE html>" |
44 "<meta name='viewport' content='width=device-width'/>" | 43 "<meta name='viewport' content='width=device-width'/>" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 102 |
104 // We need to wait until at least one frame has been composited | 103 // We need to wait until at least one frame has been composited |
105 // otherwise the injection of the synthetic gestures may get | 104 // otherwise the injection of the synthetic gestures may get |
106 // dropped because of MainThread/Impl thread sync of touch event | 105 // dropped because of MainThread/Impl thread sync of touch event |
107 // regions. | 106 // regions. |
108 frame_watcher->WaitFrames(1); | 107 frame_watcher->WaitFrames(1); |
109 } | 108 } |
110 | 109 |
111 // ContentBrowserTest: | 110 // ContentBrowserTest: |
112 void SetUpCommandLine(base::CommandLine* cmd) override { | 111 void SetUpCommandLine(base::CommandLine* cmd) override { |
113 cmd->AppendSwitchASCII(switches::kTouchEvents, | 112 cmd->AppendSwitchASCII(switches::kTouchEventFeatureDetection, |
114 switches::kTouchEventsEnabled); | 113 switches::kTouchEventFeatureDetectionEnabled); |
115 // TODO(rbyers): Remove this switch once touch-action ships. | 114 // TODO(rbyers): Remove this switch once touch-action ships. |
116 // http://crbug.com/241964 | 115 // http://crbug.com/241964 |
117 cmd->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); | 116 cmd->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); |
118 } | 117 } |
119 | 118 |
120 int ExecuteScriptAndExtractInt(const std::string& script) { | 119 int ExecuteScriptAndExtractInt(const std::string& script) { |
121 int value = 0; | 120 int value = 0; |
122 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( | 121 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( |
123 shell(), "domAutomationController.send(" + script + ")", &value)); | 122 shell(), "domAutomationController.send(" + script + ")", &value)); |
124 return value; | 123 return value; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45), false); | 218 DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45), false); |
220 EXPECT_FALSE(scrolled); | 219 EXPECT_FALSE(scrolled); |
221 | 220 |
222 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart")); | 221 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart")); |
223 EXPECT_GE(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1); | 222 EXPECT_GE(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1); |
224 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend")); | 223 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend")); |
225 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel")); | 224 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel")); |
226 } | 225 } |
227 | 226 |
228 } // namespace content | 227 } // namespace content |
OLD | NEW |