| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return ExecuteScriptAndExtractInt("document.scrollingElement.scrollTop"); | 120 return ExecuteScriptAndExtractInt("document.scrollingElement.scrollTop"); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void DoWheelScroll() { | 123 void DoWheelScroll() { |
| 124 EXPECT_EQ(0, GetScrollTop()); | 124 EXPECT_EQ(0, GetScrollTop()); |
| 125 | 125 |
| 126 int scrollHeight = | 126 int scrollHeight = |
| 127 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); | 127 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); |
| 128 EXPECT_EQ(kWebsiteHeight, scrollHeight); | 128 EXPECT_EQ(kWebsiteHeight, scrollHeight); |
| 129 | 129 |
| 130 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); | 130 FrameWatcher frame_watcher(shell()->web_contents()); |
| 131 frame_watcher->AttachTo(shell()->web_contents()); | |
| 132 scoped_refptr<InputMsgWatcher> input_msg_watcher( | 131 scoped_refptr<InputMsgWatcher> input_msg_watcher( |
| 133 new InputMsgWatcher(GetWidgetHost(), blink::WebInputEvent::MouseWheel)); | 132 new InputMsgWatcher(GetWidgetHost(), blink::WebInputEvent::MouseWheel)); |
| 134 | 133 |
| 135 GetWidgetHost()->ForwardWheelEvent( | 134 GetWidgetHost()->ForwardWheelEvent( |
| 136 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, -53, 0, true)); | 135 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, -53, 0, true)); |
| 137 | 136 |
| 138 // Runs until we get the InputMsgAck callback | 137 // Runs until we get the InputMsgAck callback |
| 139 EXPECT_EQ(INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING, | 138 EXPECT_EQ(INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING, |
| 140 input_msg_watcher->WaitForAck()); | 139 input_msg_watcher->WaitForAck()); |
| 141 | 140 |
| 142 // Expect that the compositor scrolled at least one pixel while the | 141 // Expect that the compositor scrolled at least one pixel while the |
| 143 // main thread was in a busy loop. | 142 // main thread was in a busy loop. |
| 144 while (frame_watcher->LastMetadata().root_scroll_offset.y() <= 0) | 143 while (frame_watcher.LastMetadata().root_scroll_offset.y() <= 0) |
| 145 frame_watcher->WaitFrames(1); | 144 frame_watcher.WaitFrames(1); |
| 146 } | 145 } |
| 147 | 146 |
| 148 void DoTouchScroll() { | 147 void DoTouchScroll() { |
| 149 EXPECT_EQ(0, GetScrollTop()); | 148 EXPECT_EQ(0, GetScrollTop()); |
| 150 | 149 |
| 151 int scrollHeight = | 150 int scrollHeight = |
| 152 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); | 151 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); |
| 153 EXPECT_EQ(kWebsiteHeight, scrollHeight); | 152 EXPECT_EQ(kWebsiteHeight, scrollHeight); |
| 154 | 153 |
| 155 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); | 154 FrameWatcher frame_watcher(shell()->web_contents()); |
| 156 frame_watcher->AttachTo(shell()->web_contents()); | |
| 157 | 155 |
| 158 SyntheticSmoothScrollGestureParams params; | 156 SyntheticSmoothScrollGestureParams params; |
| 159 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 157 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 160 params.anchor = gfx::PointF(50, 50); | 158 params.anchor = gfx::PointF(50, 50); |
| 161 params.distances.push_back(gfx::Vector2d(0, -45)); | 159 params.distances.push_back(gfx::Vector2d(0, -45)); |
| 162 | 160 |
| 163 std::unique_ptr<SyntheticSmoothScrollGesture> gesture( | 161 std::unique_ptr<SyntheticSmoothScrollGesture> gesture( |
| 164 new SyntheticSmoothScrollGesture(params)); | 162 new SyntheticSmoothScrollGesture(params)); |
| 165 GetWidgetHost()->QueueSyntheticGesture( | 163 GetWidgetHost()->QueueSyntheticGesture( |
| 166 std::move(gesture), | 164 std::move(gesture), |
| 167 base::Bind(&NonBlockingEventBrowserTest::OnSyntheticGestureCompleted, | 165 base::Bind(&NonBlockingEventBrowserTest::OnSyntheticGestureCompleted, |
| 168 base::Unretained(this))); | 166 base::Unretained(this))); |
| 169 | 167 |
| 170 // Expect that the compositor scrolled at least one pixel while the | 168 // Expect that the compositor scrolled at least one pixel while the |
| 171 // main thread was in a busy loop. | 169 // main thread was in a busy loop. |
| 172 while (frame_watcher->LastMetadata().root_scroll_offset.y() <= 0) | 170 while (frame_watcher.LastMetadata().root_scroll_offset.y() <= 0) |
| 173 frame_watcher->WaitFrames(1); | 171 frame_watcher.WaitFrames(1); |
| 174 } | 172 } |
| 175 | 173 |
| 176 private: | 174 private: |
| 177 DISALLOW_COPY_AND_ASSIGN(NonBlockingEventBrowserTest); | 175 DISALLOW_COPY_AND_ASSIGN(NonBlockingEventBrowserTest); |
| 178 }; | 176 }; |
| 179 | 177 |
| 180 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MouseWheel) { | 178 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MouseWheel) { |
| 181 LoadURL(kNonBlockingEventDataURL); | 179 LoadURL(kNonBlockingEventDataURL); |
| 182 DoWheelScroll(); | 180 DoWheelScroll(); |
| 183 } | 181 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 201 #define MAYBE_PassiveTouchStartBlockingTouchEnd \ | 199 #define MAYBE_PassiveTouchStartBlockingTouchEnd \ |
| 202 PassiveTouchStartBlockingTouchEnd | 200 PassiveTouchStartBlockingTouchEnd |
| 203 #endif | 201 #endif |
| 204 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, | 202 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, |
| 205 MAYBE_PassiveTouchStartBlockingTouchEnd) { | 203 MAYBE_PassiveTouchStartBlockingTouchEnd) { |
| 206 LoadURL(kPassiveTouchStartBlockingTouchEndDataURL); | 204 LoadURL(kPassiveTouchStartBlockingTouchEndDataURL); |
| 207 DoTouchScroll(); | 205 DoTouchScroll(); |
| 208 } | 206 } |
| 209 | 207 |
| 210 } // namespace content | 208 } // namespace content |
| OLD | NEW |