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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); | 85 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); |
86 runner_->Quit(); | 86 runner_->Quit(); |
87 } | 87 } |
88 | 88 |
89 protected: | 89 protected: |
90 void LoadURL() { | 90 void LoadURL() { |
91 const GURL data_url(kTouchActionDataURL); | 91 const GURL data_url(kTouchActionDataURL); |
92 NavigateToURL(shell(), data_url); | 92 NavigateToURL(shell(), data_url); |
93 | 93 |
94 RenderWidgetHostImpl* host = GetWidgetHost(); | 94 RenderWidgetHostImpl* host = GetWidgetHost(); |
95 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); | 95 FrameWatcher frame_watcher(shell()->web_contents()); |
96 frame_watcher->AttachTo(shell()->web_contents()); | |
97 host->GetView()->SetSize(gfx::Size(400, 400)); | 96 host->GetView()->SetSize(gfx::Size(400, 400)); |
98 | 97 |
99 base::string16 ready_title(base::ASCIIToUTF16("ready")); | 98 base::string16 ready_title(base::ASCIIToUTF16("ready")); |
100 TitleWatcher watcher(shell()->web_contents(), ready_title); | 99 TitleWatcher watcher(shell()->web_contents(), ready_title); |
101 ignore_result(watcher.WaitAndGetTitle()); | 100 ignore_result(watcher.WaitAndGetTitle()); |
102 | 101 |
103 // We need to wait until at least one frame has been composited | 102 // We need to wait until at least one frame has been composited |
104 // otherwise the injection of the synthetic gestures may get | 103 // otherwise the injection of the synthetic gestures may get |
105 // dropped because of MainThread/Impl thread sync of touch event | 104 // dropped because of MainThread/Impl thread sync of touch event |
106 // regions. | 105 // regions. |
107 frame_watcher->WaitFrames(1); | 106 frame_watcher.WaitFrames(1); |
108 } | 107 } |
109 | 108 |
110 // ContentBrowserTest: | 109 // ContentBrowserTest: |
111 void SetUpCommandLine(base::CommandLine* cmd) override { | 110 void SetUpCommandLine(base::CommandLine* cmd) override { |
112 cmd->AppendSwitchASCII(switches::kTouchEventFeatureDetection, | 111 cmd->AppendSwitchASCII(switches::kTouchEventFeatureDetection, |
113 switches::kTouchEventFeatureDetectionEnabled); | 112 switches::kTouchEventFeatureDetectionEnabled); |
114 // TODO(rbyers): Remove this switch once touch-action ships. | 113 // TODO(rbyers): Remove this switch once touch-action ships. |
115 // http://crbug.com/241964 | 114 // http://crbug.com/241964 |
116 cmd->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); | 115 cmd->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); |
117 } | 116 } |
(...skipping 14 matching lines...) Expand all Loading... |
132 // it didn't scroll at all. | 131 // it didn't scroll at all. |
133 bool DoTouchScroll(const gfx::Point& point, | 132 bool DoTouchScroll(const gfx::Point& point, |
134 const gfx::Vector2d& distance, | 133 const gfx::Vector2d& distance, |
135 bool wait_until_scrolled) { | 134 bool wait_until_scrolled) { |
136 EXPECT_EQ(0, GetScrollTop()); | 135 EXPECT_EQ(0, GetScrollTop()); |
137 | 136 |
138 int scrollHeight = ExecuteScriptAndExtractInt( | 137 int scrollHeight = ExecuteScriptAndExtractInt( |
139 "document.documentElement.scrollHeight"); | 138 "document.documentElement.scrollHeight"); |
140 EXPECT_EQ(10200, scrollHeight); | 139 EXPECT_EQ(10200, scrollHeight); |
141 | 140 |
142 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); | 141 FrameWatcher frame_watcher(shell()->web_contents()); |
143 frame_watcher->AttachTo(shell()->web_contents()); | |
144 | 142 |
145 SyntheticSmoothScrollGestureParams params; | 143 SyntheticSmoothScrollGestureParams params; |
146 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 144 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
147 params.anchor = gfx::PointF(point); | 145 params.anchor = gfx::PointF(point); |
148 params.distances.push_back(-distance); | 146 params.distances.push_back(-distance); |
149 | 147 |
150 runner_ = new MessageLoopRunner(); | 148 runner_ = new MessageLoopRunner(); |
151 | 149 |
152 std::unique_ptr<SyntheticSmoothScrollGesture> gesture( | 150 std::unique_ptr<SyntheticSmoothScrollGesture> gesture( |
153 new SyntheticSmoothScrollGesture(params)); | 151 new SyntheticSmoothScrollGesture(params)); |
154 GetWidgetHost()->QueueSyntheticGesture( | 152 GetWidgetHost()->QueueSyntheticGesture( |
155 std::move(gesture), | 153 std::move(gesture), |
156 base::Bind(&TouchActionBrowserTest::OnSyntheticGestureCompleted, | 154 base::Bind(&TouchActionBrowserTest::OnSyntheticGestureCompleted, |
157 base::Unretained(this))); | 155 base::Unretained(this))); |
158 | 156 |
159 // Runs until we get the OnSyntheticGestureCompleted callback | 157 // Runs until we get the OnSyntheticGestureCompleted callback |
160 runner_->Run(); | 158 runner_->Run(); |
161 runner_ = NULL; | 159 runner_ = NULL; |
162 | 160 |
163 // Expect that the compositor scrolled at least one pixel while the | 161 // Expect that the compositor scrolled at least one pixel while the |
164 // main thread was in a busy loop. | 162 // main thread was in a busy loop. |
165 while (wait_until_scrolled && | 163 while (wait_until_scrolled && |
166 frame_watcher->LastMetadata().root_scroll_offset.y() < | 164 frame_watcher.LastMetadata().root_scroll_offset.y() < |
167 (distance.y() / 2)) { | 165 (distance.y() / 2)) { |
168 frame_watcher->WaitFrames(1); | 166 frame_watcher.WaitFrames(1); |
169 } | 167 } |
170 | 168 |
171 // Check the scroll offset | 169 // Check the scroll offset |
172 int scrollTop = GetScrollTop(); | 170 int scrollTop = GetScrollTop(); |
173 if (scrollTop == 0) | 171 if (scrollTop == 0) |
174 return false; | 172 return false; |
175 | 173 |
176 // Allow for 1px rounding inaccuracies for some screen sizes. | 174 // Allow for 1px rounding inaccuracies for some screen sizes. |
177 EXPECT_LT(distance.y() / 2, scrollTop); | 175 EXPECT_LT(distance.y() / 2, scrollTop); |
178 return true; | 176 return true; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45), false); | 216 DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45), false); |
219 EXPECT_FALSE(scrolled); | 217 EXPECT_FALSE(scrolled); |
220 | 218 |
221 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart")); | 219 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart")); |
222 EXPECT_GE(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1); | 220 EXPECT_GE(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1); |
223 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend")); | 221 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend")); |
224 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel")); | 222 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel")); |
225 } | 223 } |
226 | 224 |
227 } // namespace content | 225 } // namespace content |
OLD | NEW |