| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |