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

Side by Side Diff: content/browser/site_per_process_mac_browsertest.mm

Issue 2866523002: Don't drop mouse wheel events with phase ending information in RWHVCF. (Closed)
Patch Set: Add test. Created 3 years, 7 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 | « content/browser/frame_host/render_widget_host_view_child_frame.cc ('k') | 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include "content/public/test/content_browser_test_utils.h" 7 #include "content/public/test/content_browser_test_utils.h"
8 #include "content/public/test/test_utils.h" 8 #include "content/public/test/test_utils.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 loop_runner_->Quit(); 51 loop_runner_->Quit();
52 } 52 }
53 53
54 std::string word_; 54 std::string word_;
55 gfx::Point point_; 55 gfx::Point point_;
56 scoped_refptr<MessageLoopRunner> loop_runner_; 56 scoped_refptr<MessageLoopRunner> loop_runner_;
57 57
58 DISALLOW_COPY_AND_ASSIGN(TextInputClientMacHelper); 58 DISALLOW_COPY_AND_ASSIGN(TextInputClientMacHelper);
59 }; 59 };
60 60
61 // Class to detect incoming gesture event acks for scrolling tests.
62 class InputEventAckWaiter
63 : public content::RenderWidgetHost::InputEventObserver {
64 public:
65 InputEventAckWaiter(blink::WebInputEvent::Type ack_type_waiting_for)
66 : message_loop_runner_(new content::MessageLoopRunner),
67 ack_type_waiting_for_(ack_type_waiting_for),
68 desired_ack_type_received_(false) {}
69 ~InputEventAckWaiter() override {}
70
71 void OnInputEventAck(const blink::WebInputEvent& event) override {
72 if (event.GetType() != ack_type_waiting_for_)
73 return;
74
75 // Ignore synthetic GestureScrollBegin/Ends.
76 if ((event.GetType() == blink::WebInputEvent::kGestureScrollBegin &&
77 static_cast<const blink::WebGestureEvent&>(event)
78 .data.scroll_begin.synthetic) ||
79 (event.GetType() == blink::WebInputEvent::kGestureScrollEnd &&
80 static_cast<const blink::WebGestureEvent&>(event)
81 .data.scroll_end.synthetic)) {
82 return;
83 }
84
85 desired_ack_type_received_ = true;
86 if (message_loop_runner_->loop_running())
87 message_loop_runner_->Quit();
88 }
89
90 void Wait() {
91 if (!desired_ack_type_received_) {
92 message_loop_runner_->Run();
93 }
94 }
95
96 void Reset() {
97 desired_ack_type_received_ = false;
98 message_loop_runner_ = new content::MessageLoopRunner;
99 }
100
101 private:
102 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
103 blink::WebInputEvent::Type ack_type_waiting_for_;
104 bool desired_ack_type_received_;
105
106 DISALLOW_COPY_AND_ASSIGN(InputEventAckWaiter);
107 };
108
61 } // namespace 109 } // namespace
62 110
63 // Site per process browser tests inside content which are specific to Mac OSX 111 // Site per process browser tests inside content which are specific to Mac OSX
64 // platform. 112 // platform.
65 class SitePerProcessMacBrowserTest : public SitePerProcessBrowserTest {}; 113 class SitePerProcessMacBrowserTest : public SitePerProcessBrowserTest {};
66 114
67 // This test will load a text only page inside a child frame and then queries 115 // This test will load a text only page inside a child frame and then queries
68 // the string range which includes the first word. Then it uses the returned 116 // the string range which includes the first word. Then it uses the returned
69 // point to query the text again and verifies that correct result is returned. 117 // point to query the text again and verifies that correct result is returned.
70 // Finally, the returned words are compared against the first word in the html 118 // Finally, the returned words are compared against the first word in the html
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Get string from range. 158 // Get string from range.
111 helper.WaitForStringFromRange(widget_host, gfx::Range(0, 4)); 159 helper.WaitForStringFromRange(widget_host, gfx::Range(0, 4));
112 gfx::Point point = helper.point(); 160 gfx::Point point = helper.point();
113 std::string word = helper.word(); 161 std::string word = helper.word();
114 162
115 // Now get it at a given point. 163 // Now get it at a given point.
116 helper.WaitForStringAtPoint(widget_host, point); 164 helper.WaitForStringAtPoint(widget_host, point);
117 EXPECT_EQ(word, helper.word()); 165 EXPECT_EQ(word, helper.word());
118 EXPECT_EQ("This", word); 166 EXPECT_EQ("This", word);
119 } 167 }
168
169 // Ensure that the RWHVCF forwards wheel events with phase ending information.
170 // RWHVCF may see wheel events with phase ending information that have deltas
171 // of 0. These should not be dropped, otherwise MouseWheelEventQueue will not
172 // be informed that the user's gesture has ended.
173 // See crbug.com/628742
174 IN_PROC_BROWSER_TEST_F(SitePerProcessMacBrowserTest,
175 ForwardWheelEventsWithPhaseEndingInformation) {
176 GURL main_url(embedded_test_server()->GetURL(
177 "a.com", "/cross_site_iframe_factory.html?a(b)"));
178 EXPECT_TRUE(NavigateToURL(shell(), main_url));
179
180 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
181 ->GetFrameTree()
182 ->root();
183 ASSERT_EQ(1U, root->child_count());
184
185 FrameTreeNode* child_iframe_node = root->child_at(0);
186 RenderWidgetHost* child_rwh =
187 child_iframe_node->current_frame_host()->GetRenderWidgetHost();
188
189 std::unique_ptr<InputEventAckWaiter> gesture_scroll_begin_ack_observer =
190 base::MakeUnique<InputEventAckWaiter>(
191 blink::WebInputEvent::kGestureScrollBegin);
192 std::unique_ptr<InputEventAckWaiter> gesture_scroll_end_ack_observer =
193 base::MakeUnique<InputEventAckWaiter>(
194 blink::WebInputEvent::kGestureScrollEnd);
195 child_rwh->AddInputEventObserver(gesture_scroll_begin_ack_observer.get());
196 child_rwh->AddInputEventObserver(gesture_scroll_end_ack_observer.get());
197
198 RenderWidgetHostViewBase* child_rwhv =
199 static_cast<RenderWidgetHostViewBase*>(child_rwh->GetView());
200
201 blink::WebMouseWheelEvent scroll_event(
202 blink::WebInputEvent::kMouseWheel, blink::WebInputEvent::kNoModifiers,
203 blink::WebInputEvent::kTimeStampForTesting);
204 scroll_event.SetPositionInWidget(1, 1);
205 scroll_event.has_precise_scrolling_deltas = true;
206 scroll_event.delta_x = 0.0f;
207
208 // Have the RWHVCF process a sequence of touchpad scroll events that contain
209 // phase informaiton. We start scrolling normally, then we fling.
210 // We wait for GestureScrollBegin/Ends that result from these wheel events.
211 // If we don't see them, this test will time out indicating failure.
212
213 // Begin scrolling.
214 scroll_event.delta_y = -1.0f;
215 scroll_event.phase = blink::WebMouseWheelEvent::kPhaseBegan;
216 scroll_event.momentum_phase = blink::WebMouseWheelEvent::kPhaseNone;
217 child_rwhv->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
218 gesture_scroll_begin_ack_observer->Wait();
219
220 scroll_event.delta_y = -2.0f;
221 scroll_event.phase = blink::WebMouseWheelEvent::kPhaseChanged;
222 scroll_event.momentum_phase = blink::WebMouseWheelEvent::kPhaseNone;
223 child_rwhv->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
224
225 // End of non-momentum scrolling.
226 scroll_event.delta_y = 0.0f;
227 scroll_event.phase = blink::WebMouseWheelEvent::kPhaseEnded;
228 scroll_event.momentum_phase = blink::WebMouseWheelEvent::kPhaseNone;
229 child_rwhv->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
230 gesture_scroll_end_ack_observer->Wait();
231
232 gesture_scroll_begin_ack_observer->Reset();
233 gesture_scroll_end_ack_observer->Reset();
234
235 // We now go into a fling.
236 scroll_event.delta_y = -2.0f;
237 scroll_event.phase = blink::WebMouseWheelEvent::kPhaseNone;
238 scroll_event.momentum_phase = blink::WebMouseWheelEvent::kPhaseBegan;
239 child_rwhv->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
240 gesture_scroll_begin_ack_observer->Wait();
241
242 scroll_event.delta_y = -2.0f;
243 scroll_event.phase = blink::WebMouseWheelEvent::kPhaseNone;
244 scroll_event.momentum_phase = blink::WebMouseWheelEvent::kPhaseChanged;
245 child_rwhv->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
246
247 // End of fling momentum.
248 scroll_event.delta_y = 0.0f;
249 scroll_event.phase = blink::WebMouseWheelEvent::kPhaseNone;
250 scroll_event.momentum_phase = blink::WebMouseWheelEvent::kPhaseEnded;
251 child_rwhv->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
252 gesture_scroll_end_ack_observer->Wait();
253 }
254
120 } // namespace content 255 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_widget_host_view_child_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698