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

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

Issue 2399153002: Fix precision problem in TouchActionBrowserTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use precision for comparison in scroll test Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 base::Unretained(this))); 158 base::Unretained(this)));
159 159
160 // Runs until we get the OnSyntheticGestureCompleted callback 160 // Runs until we get the OnSyntheticGestureCompleted callback
161 runner_->Run(); 161 runner_->Run();
162 runner_ = NULL; 162 runner_ = NULL;
163 163
164 // Expect that the compositor scrolled at least one pixel while the 164 // Expect that the compositor scrolled at least one pixel while the
165 // main thread was in a busy loop. 165 // main thread was in a busy loop.
166 while (wait_until_scrolled && 166 while (wait_until_scrolled &&
167 frame_watcher->LastMetadata().root_scroll_offset.y() < 167 frame_watcher->LastMetadata().root_scroll_offset.y() <
168 distance.y()) { 168 (distance.y() / 2)) {
169 frame_watcher->WaitFrames(1); 169 frame_watcher->WaitFrames(1);
170 } 170 }
171 171
172 // Check the scroll offset 172 // Check the scroll offset
173 int scrollTop = GetScrollTop(); 173 int scrollTop = GetScrollTop();
174 if (scrollTop == 0) 174 if (scrollTop == 0)
175 return false; 175 return false;
176 176
177 // Allow for 1px rounding inaccuracies for some screen sizes. 177 // Allow for 1px rounding inaccuracies for some screen sizes.
178 EXPECT_NEAR(distance.y(), scrollTop, 1); 178 EXPECT_LT(distance.y() / 2, scrollTop);
179 return true; 179 return true;
180 } 180 }
181 181
182 private: 182 private:
183 scoped_refptr<MessageLoopRunner> runner_; 183 scoped_refptr<MessageLoopRunner> runner_;
184 184
185 DISALLOW_COPY_AND_ASSIGN(TouchActionBrowserTest); 185 DISALLOW_COPY_AND_ASSIGN(TouchActionBrowserTest);
186 }; 186 };
187 187
188 // Mac doesn't yet have a gesture recognizer, so can't support turning touch 188 // Mac doesn't yet have a gesture recognizer, so can't support turning touch
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45), false); 223 DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 45), false);
224 EXPECT_FALSE(scrolled); 224 EXPECT_FALSE(scrolled);
225 225
226 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart")); 226 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchstart"));
227 EXPECT_GE(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1); 227 EXPECT_GE(ExecuteScriptAndExtractInt("eventCounts.touchmove"), 1);
228 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend")); 228 EXPECT_EQ(1, ExecuteScriptAndExtractInt("eventCounts.touchend"));
229 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel")); 229 EXPECT_EQ(0, ExecuteScriptAndExtractInt("eventCounts.touchcancel"));
230 } 230 }
231 231
232 } // namespace content 232 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698