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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 void DoWheelScroll() { | 108 void DoWheelScroll() { |
109 EXPECT_EQ(0, GetScrollTop()); | 109 EXPECT_EQ(0, GetScrollTop()); |
110 | 110 |
111 int scrollHeight = | 111 int scrollHeight = |
112 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); | 112 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); |
113 EXPECT_EQ(1000, scrollHeight); | 113 EXPECT_EQ(1000, scrollHeight); |
114 | 114 |
115 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); | 115 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); |
116 GetWidgetHost()->GetProcess()->AddFilter(frame_watcher.get()); | 116 frame_watcher->AttachTo(shell()->web_contents()); |
117 scoped_refptr<InputMsgWatcher> input_msg_watcher( | 117 scoped_refptr<InputMsgWatcher> input_msg_watcher( |
118 new InputMsgWatcher(GetWidgetHost(), blink::WebInputEvent::MouseWheel)); | 118 new InputMsgWatcher(GetWidgetHost(), blink::WebInputEvent::MouseWheel)); |
119 | 119 |
120 GetWidgetHost()->ForwardWheelEvent( | 120 GetWidgetHost()->ForwardWheelEvent( |
121 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, -53, 0, true)); | 121 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, -53, 0, true)); |
122 | 122 |
123 // Runs until we get the InputMsgAck callback | 123 // Runs until we get the InputMsgAck callback |
124 EXPECT_EQ(INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING, | 124 EXPECT_EQ(INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING, |
125 input_msg_watcher->WaitForAck()); | 125 input_msg_watcher->WaitForAck()); |
126 frame_watcher->WaitFrames(1); | 126 frame_watcher->WaitFrames(1); |
127 | 127 |
128 // Expect that the compositor scrolled at least one pixel while the | 128 // Expect that the compositor scrolled at least one pixel while the |
129 // main thread was in a busy loop. | 129 // main thread was in a busy loop. |
130 EXPECT_LT(0, frame_watcher->LastMetadata().root_scroll_offset.y()); | 130 EXPECT_LT(0, frame_watcher->LastMetadata().root_scroll_offset.y()); |
131 } | 131 } |
132 | 132 |
133 void DoTouchScroll() { | 133 void DoTouchScroll() { |
134 EXPECT_EQ(0, GetScrollTop()); | 134 EXPECT_EQ(0, GetScrollTop()); |
135 | 135 |
136 int scrollHeight = | 136 int scrollHeight = |
137 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); | 137 ExecuteScriptAndExtractInt("document.documentElement.scrollHeight"); |
138 EXPECT_EQ(1000, scrollHeight); | 138 EXPECT_EQ(1000, scrollHeight); |
139 | 139 |
140 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); | 140 scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher()); |
141 GetWidgetHost()->GetProcess()->AddFilter(frame_watcher.get()); | 141 frame_watcher->AttachTo(shell()->web_contents()); |
142 | 142 |
143 SyntheticSmoothScrollGestureParams params; | 143 SyntheticSmoothScrollGestureParams params; |
144 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 144 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
145 params.anchor = gfx::PointF(50, 50); | 145 params.anchor = gfx::PointF(50, 50); |
146 params.distances.push_back(gfx::Vector2d(0, -45)); | 146 params.distances.push_back(gfx::Vector2d(0, -45)); |
147 | 147 |
148 scoped_ptr<SyntheticSmoothScrollGesture> gesture( | 148 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
149 new SyntheticSmoothScrollGesture(params)); | 149 new SyntheticSmoothScrollGesture(params)); |
150 GetWidgetHost()->QueueSyntheticGesture( | 150 GetWidgetHost()->QueueSyntheticGesture( |
151 std::move(gesture), | 151 std::move(gesture), |
152 base::Bind(&NonBlockingEventBrowserTest::OnSyntheticGestureCompleted, | 152 base::Bind(&NonBlockingEventBrowserTest::OnSyntheticGestureCompleted, |
153 base::Unretained(this))); | 153 base::Unretained(this))); |
154 | 154 |
155 // Expect that the compositor scrolled at least one pixel while the | 155 // Expect that the compositor scrolled at least one pixel while the |
156 // main thread was in a busy loop. | 156 // main thread was in a busy loop. |
157 while (frame_watcher->LastMetadata().root_scroll_offset.y() <= 0) | 157 while (frame_watcher->LastMetadata().root_scroll_offset.y() <= 0) |
158 frame_watcher->WaitFrames(1); | 158 frame_watcher->WaitFrames(1); |
159 } | 159 } |
160 | 160 |
161 private: | 161 private: |
162 DISALLOW_COPY_AND_ASSIGN(NonBlockingEventBrowserTest); | 162 DISALLOW_COPY_AND_ASSIGN(NonBlockingEventBrowserTest); |
163 }; | 163 }; |
164 | 164 |
165 // Disabled on MacOS because it doesn't support wheel gestures | |
166 // just yet. | |
167 #if defined(OS_MACOSX) | |
168 #define MAYBE_MouseWheel DISABLED_MouseWheel | |
169 #else | |
170 // Also appears to be flaky under TSan. crbug.com/588199 | 165 // Also appears to be flaky under TSan. crbug.com/588199 |
171 #if defined(THREAD_SANITIZER) | 166 #if defined(THREAD_SANITIZER) |
172 #define MAYBE_MouseWheel DISABLED_MouseWheel | 167 #define MAYBE_MouseWheel DISABLED_MouseWheel |
173 #else | 168 #else |
174 #define MAYBE_MouseWheel MouseWheel | 169 #define MAYBE_MouseWheel MouseWheel |
175 #endif | 170 #endif |
176 #endif | |
177 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MAYBE_MouseWheel) { | 171 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MAYBE_MouseWheel) { |
178 LoadURL(); | 172 LoadURL(); |
179 DoWheelScroll(); | 173 DoWheelScroll(); |
180 } | 174 } |
181 | 175 |
182 // Disabled on MacOS because it doesn't support touch input. | 176 // Disabled on MacOS because it doesn't support touch input. |
183 #if defined(OS_MACOSX) | 177 #if defined(OS_MACOSX) |
184 #define MAYBE_TouchStart DISABLED_TouchStart | 178 #define MAYBE_TouchStart DISABLED_TouchStart |
185 #else | 179 #else |
186 #define MAYBE_TouchStart TouchStart | 180 #define MAYBE_TouchStart TouchStart |
187 #endif | 181 #endif |
188 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MAYBE_TouchStart) { | 182 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MAYBE_TouchStart) { |
189 LoadURL(); | 183 LoadURL(); |
190 DoTouchScroll(); | 184 DoTouchScroll(); |
191 } | 185 } |
192 | 186 |
193 } // namespace content | 187 } // namespace content |
OLD | NEW |