| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 "<meta name='viewport' content='width=device-width'/>" | 44 "<meta name='viewport' content='width=device-width'/>" |
| 45 "<style>" | 45 "<style>" |
| 46 "html, body {" | 46 "html, body {" |
| 47 " margin: 0;" | 47 " margin: 0;" |
| 48 "}" | 48 "}" |
| 49 ".box {" | 49 ".box {" |
| 50 " height: 96px;" | 50 " height: 96px;" |
| 51 " width: 96px;" | 51 " width: 96px;" |
| 52 " border: 2px solid blue;" | 52 " border: 2px solid blue;" |
| 53 "}" | 53 "}" |
| 54 ".spacer { height: 1000px; }" | 54 ".spacer { height: 10000px; }" |
| 55 ".ta-none { touch-action: none; }" | 55 ".ta-none { touch-action: none; }" |
| 56 "</style>" | 56 "</style>" |
| 57 "<div class=box></div>" | 57 "<div class=box></div>" |
| 58 "<div class='box ta-none'></div>" | 58 "<div class='box ta-none'></div>" |
| 59 "<div class=spacer></div>" | 59 "<div class=spacer></div>" |
| 60 "<script>" | 60 "<script>" |
| 61 " window.eventCounts = " | 61 " window.eventCounts = " |
| 62 " {touchstart:0, touchmove:0, touchend: 0, touchcancel:0};" | 62 " {touchstart:0, touchmove:0, touchend: 0, touchcancel:0};" |
| 63 " function countEvent(e) { eventCounts[e.type]++; }" | 63 " function countEvent(e) { eventCounts[e.type]++; }" |
| 64 " for (var evt in eventCounts) { " | 64 " for (var evt in eventCounts) { " |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // Generate touch events for a synthetic scroll from |point| for |distance|. | 131 // Generate touch events for a synthetic scroll from |point| for |distance|. |
| 132 // Returns true if the page scrolled by the desired amount, and false if | 132 // Returns true if the page scrolled by the desired amount, and false if |
| 133 // it didn't scroll at all. | 133 // it didn't scroll at all. |
| 134 bool DoTouchScroll(const gfx::Point& point, | 134 bool DoTouchScroll(const gfx::Point& point, |
| 135 const gfx::Vector2d& distance, | 135 const gfx::Vector2d& distance, |
| 136 bool wait_until_scrolled) { | 136 bool wait_until_scrolled) { |
| 137 EXPECT_EQ(0, GetScrollTop()); | 137 EXPECT_EQ(0, GetScrollTop()); |
| 138 | 138 |
| 139 int scrollHeight = ExecuteScriptAndExtractInt( | 139 int scrollHeight = ExecuteScriptAndExtractInt( |
| 140 "document.documentElement.scrollHeight"); | 140 "document.documentElement.scrollHeight"); |
| 141 EXPECT_EQ(1200, scrollHeight); | 141 EXPECT_EQ(10200, scrollHeight); |
| 142 | 142 |
| 143 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); | 143 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); |
| 144 frame_watcher->AttachTo(shell()->web_contents()); | 144 frame_watcher->AttachTo(shell()->web_contents()); |
| 145 | 145 |
| 146 SyntheticSmoothScrollGestureParams params; | 146 SyntheticSmoothScrollGestureParams params; |
| 147 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 147 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 148 params.anchor = gfx::PointF(point); | 148 params.anchor = gfx::PointF(point); |
| 149 params.distances.push_back(-distance); | 149 params.distances.push_back(-distance); |
| 150 | 150 |
| 151 runner_ = new MessageLoopRunner(); | 151 runner_ = new MessageLoopRunner(); |
| (...skipping 71 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 |