OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
11 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
12 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 12 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
13 #include "content/browser/renderer_host/input/input_router_impl.h" | 13 #include "content/browser/renderer_host/input/input_router_impl.h" |
14 #include "content/browser/renderer_host/input/tap_suppression_controller.h" | |
15 #include "content/browser/renderer_host/input/tap_suppression_controller_client.
h" | |
16 #include "content/browser/renderer_host/input/touch_event_queue.h" | 14 #include "content/browser/renderer_host/input/touch_event_queue.h" |
17 #include "content/browser/renderer_host/overscroll_controller.h" | 15 #include "content/browser/renderer_host/overscroll_controller.h" |
18 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 16 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
19 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 17 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
20 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
21 #include "content/common/input/synthetic_web_input_event_builders.h" | 19 #include "content/common/input/synthetic_web_input_event_builders.h" |
22 #include "content/common/input_messages.h" | 20 #include "content/common/input_messages.h" |
23 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
24 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
25 #include "content/public/test/mock_render_process_host.h" | 23 #include "content/public/test/mock_render_process_host.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // MockRenderWidgetHost ---------------------------------------------------- | 190 // MockRenderWidgetHost ---------------------------------------------------- |
193 | 191 |
194 class MockRenderWidgetHost : public RenderWidgetHostImpl { | 192 class MockRenderWidgetHost : public RenderWidgetHostImpl { |
195 public: | 193 public: |
196 MockRenderWidgetHost( | 194 MockRenderWidgetHost( |
197 RenderWidgetHostDelegate* delegate, | 195 RenderWidgetHostDelegate* delegate, |
198 RenderProcessHost* process, | 196 RenderProcessHost* process, |
199 int routing_id) | 197 int routing_id) |
200 : RenderWidgetHostImpl(delegate, process, routing_id, false), | 198 : RenderWidgetHostImpl(delegate, process, routing_id, false), |
201 unresponsive_timer_fired_(false) { | 199 unresponsive_timer_fired_(false) { |
202 input_router_impl_ = static_cast<InputRouterImpl*>(input_router_.get()); | |
203 acked_touch_event_type_ = blink::WebInputEvent::Undefined; | 200 acked_touch_event_type_ = blink::WebInputEvent::Undefined; |
204 } | 201 } |
205 | 202 |
206 // Allow poking at a few private members. | 203 // Allow poking at a few private members. |
207 using RenderWidgetHostImpl::OnUpdateRect; | 204 using RenderWidgetHostImpl::OnUpdateRect; |
208 using RenderWidgetHostImpl::RendererExited; | 205 using RenderWidgetHostImpl::RendererExited; |
209 using RenderWidgetHostImpl::last_requested_size_; | 206 using RenderWidgetHostImpl::last_requested_size_; |
210 using RenderWidgetHostImpl::is_hidden_; | 207 using RenderWidgetHostImpl::is_hidden_; |
211 using RenderWidgetHostImpl::resize_ack_pending_; | 208 using RenderWidgetHostImpl::resize_ack_pending_; |
212 using RenderWidgetHostImpl::input_router_; | 209 using RenderWidgetHostImpl::input_router_; |
(...skipping 30 matching lines...) Expand all Loading... |
243 bool ScrollingInProgress() const { | 240 bool ScrollingInProgress() const { |
244 return gesture_event_queue().scrolling_in_progress_; | 241 return gesture_event_queue().scrolling_in_progress_; |
245 } | 242 } |
246 | 243 |
247 void SetupForOverscrollControllerTest() { | 244 void SetupForOverscrollControllerTest() { |
248 SetOverscrollControllerEnabled(true); | 245 SetOverscrollControllerEnabled(true); |
249 overscroll_delegate_.reset(new TestOverscrollDelegate(GetView())); | 246 overscroll_delegate_.reset(new TestOverscrollDelegate(GetView())); |
250 overscroll_controller_->set_delegate(overscroll_delegate_.get()); | 247 overscroll_controller_->set_delegate(overscroll_delegate_.get()); |
251 } | 248 } |
252 | 249 |
253 void DisableGestureDebounce() { | 250 void DisableGestureDebounce() { set_debounce_interval_time_ms(0); } |
254 gesture_event_queue().set_debounce_enabled_for_testing(false); | |
255 } | |
256 | 251 |
257 void set_debounce_interval_time_ms(int delay_ms) { | 252 void set_debounce_interval_time_ms(int delay_ms) { |
258 gesture_event_queue(). | 253 gesture_event_queue().set_debounce_interval_time_ms_for_testing(delay_ms); |
259 set_debounce_interval_time_ms_for_testing(delay_ms); | |
260 } | 254 } |
261 | 255 |
262 bool TouchEventQueueEmpty() const { | 256 bool TouchEventQueueEmpty() const { |
263 return touch_event_queue().empty(); | 257 return touch_event_queue().empty(); |
264 } | 258 } |
265 | 259 |
266 virtual void OnTouchEventAck( | 260 virtual void OnTouchEventAck( |
267 const TouchEventWithLatencyInfo& event, | 261 const TouchEventWithLatencyInfo& event, |
268 InputEventAckState ack_result) OVERRIDE { | 262 InputEventAckState ack_result) OVERRIDE { |
269 // Sniff touch acks. | 263 // Sniff touch acks. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 295 |
302 float overscroll_delta_y() const { | 296 float overscroll_delta_y() const { |
303 return overscroll_controller_->overscroll_delta_y_; | 297 return overscroll_controller_->overscroll_delta_y_; |
304 } | 298 } |
305 | 299 |
306 TestOverscrollDelegate* overscroll_delegate() { | 300 TestOverscrollDelegate* overscroll_delegate() { |
307 return overscroll_delegate_.get(); | 301 return overscroll_delegate_.get(); |
308 } | 302 } |
309 | 303 |
310 void SetupForInputRouterTest() { | 304 void SetupForInputRouterTest() { |
311 mock_input_router_ = new MockInputRouter(this); | 305 input_router_.reset(new MockInputRouter(this)); |
312 input_router_.reset(mock_input_router_); | |
313 } | 306 } |
314 | 307 |
315 MockInputRouter* mock_input_router() { | 308 MockInputRouter* mock_input_router() { |
316 return mock_input_router_; | 309 return static_cast<MockInputRouter*>(input_router_.get()); |
317 } | 310 } |
318 | 311 |
319 protected: | 312 protected: |
320 virtual void NotifyRendererUnresponsive() OVERRIDE { | 313 virtual void NotifyRendererUnresponsive() OVERRIDE { |
321 unresponsive_timer_fired_ = true; | 314 unresponsive_timer_fired_ = true; |
322 } | 315 } |
323 | 316 |
324 const TouchEventQueue& touch_event_queue() const { | 317 const TouchEventQueue& touch_event_queue() const { |
325 return input_router_impl_->touch_event_queue_; | 318 return input_router_impl()->touch_event_queue_; |
326 } | 319 } |
327 | 320 |
328 const GestureEventQueue& gesture_event_queue() const { | 321 const GestureEventQueue& gesture_event_queue() const { |
329 return input_router_impl_->gesture_event_queue_; | 322 return input_router_impl()->gesture_event_queue_; |
330 } | 323 } |
331 | 324 |
332 GestureEventQueue& gesture_event_queue() { | 325 GestureEventQueue& gesture_event_queue() { |
333 return input_router_impl_->gesture_event_queue_; | 326 return input_router_impl()->gesture_event_queue_; |
334 } | 327 } |
335 | 328 |
336 private: | 329 private: |
| 330 const InputRouterImpl* input_router_impl() const { |
| 331 return static_cast<InputRouterImpl*>(input_router_.get()); |
| 332 } |
| 333 |
| 334 InputRouterImpl* input_router_impl() { |
| 335 return static_cast<InputRouterImpl*>(input_router_.get()); |
| 336 } |
| 337 |
337 bool unresponsive_timer_fired_; | 338 bool unresponsive_timer_fired_; |
338 WebInputEvent::Type acked_touch_event_type_; | 339 WebInputEvent::Type acked_touch_event_type_; |
339 | 340 |
340 // |input_router_impl_| and |mock_input_router_| are owned by | |
341 // RenderWidgetHostImpl. The handles below are provided for convenience so | |
342 // that we don't have to reinterpret_cast it all the time. | |
343 InputRouterImpl* input_router_impl_; | |
344 MockInputRouter* mock_input_router_; | |
345 | |
346 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; | 341 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; |
347 | 342 |
348 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); | 343 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); |
349 }; | 344 }; |
350 | 345 |
351 namespace { | 346 namespace { |
352 | 347 |
353 // RenderWidgetHostProcess ----------------------------------------------------- | 348 // RenderWidgetHostProcess ----------------------------------------------------- |
354 | 349 |
355 class RenderWidgetHostProcess : public MockRenderProcessHost { | 350 class RenderWidgetHostProcess : public MockRenderProcessHost { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory)); | 604 scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory)); |
610 aura::Env::CreateInstance(); | 605 aura::Env::CreateInstance(); |
611 screen_.reset(aura::TestScreen::Create()); | 606 screen_.reset(aura::TestScreen::Create()); |
612 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 607 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
613 #endif | 608 #endif |
614 host_.reset( | 609 host_.reset( |
615 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); | 610 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); |
616 view_.reset(new TestView(host_.get())); | 611 view_.reset(new TestView(host_.get())); |
617 host_->SetView(view_.get()); | 612 host_->SetView(view_.get()); |
618 host_->Init(); | 613 host_->Init(); |
| 614 |
| 615 // Tests for debounce-related behavior will explicitly enable debouncing. |
| 616 host_->DisableGestureDebounce(); |
619 } | 617 } |
620 virtual void TearDown() { | 618 virtual void TearDown() { |
621 view_.reset(); | 619 view_.reset(); |
622 host_.reset(); | 620 host_.reset(); |
623 delegate_.reset(); | 621 delegate_.reset(); |
624 process_ = NULL; | 622 process_ = NULL; |
625 browser_context_.reset(); | 623 browser_context_.reset(); |
626 | 624 |
627 #if defined(USE_AURA) | 625 #if defined(USE_AURA) |
628 aura::Env::DeleteInstance(); | 626 aura::Env::DeleteInstance(); |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 SimulateGestureFlingStartEvent(10.f, 0.f, WebGestureEvent::Touchpad); | 1509 SimulateGestureFlingStartEvent(10.f, 0.f, WebGestureEvent::Touchpad); |
1512 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1510 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
1513 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1511 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1514 EXPECT_EQ(1U, process_->sink().message_count()); | 1512 EXPECT_EQ(1U, process_->sink().message_count()); |
1515 } | 1513 } |
1516 | 1514 |
1517 // Tests that a fling in the opposite direction of the overscroll cancels the | 1515 // Tests that a fling in the opposite direction of the overscroll cancels the |
1518 // overscroll nav instead of completing it. | 1516 // overscroll nav instead of completing it. |
1519 TEST_F(RenderWidgetHostTest, ReverseFlingCancelsOverscroll) { | 1517 TEST_F(RenderWidgetHostTest, ReverseFlingCancelsOverscroll) { |
1520 host_->SetupForOverscrollControllerTest(); | 1518 host_->SetupForOverscrollControllerTest(); |
1521 host_->DisableGestureDebounce(); | |
1522 process_->sink().ClearMessages(); | 1519 process_->sink().ClearMessages(); |
1523 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 1520 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
1524 view_->Show(); | 1521 view_->Show(); |
1525 | 1522 |
1526 { | 1523 { |
1527 // Start and end a gesture in the same direction without processing the | 1524 // Start and end a gesture in the same direction without processing the |
1528 // gesture events in the renderer. This should initiate and complete an | 1525 // gesture events in the renderer. This should initiate and complete an |
1529 // overscroll navigation. | 1526 // overscroll navigation. |
1530 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1527 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1531 WebGestureEvent::Touchscreen); | 1528 WebGestureEvent::Touchscreen); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 EXPECT_EQ(1U, process_->sink().message_count()); | 1561 EXPECT_EQ(1U, process_->sink().message_count()); |
1565 } | 1562 } |
1566 } | 1563 } |
1567 | 1564 |
1568 // Tests that touch-scroll events are handled correctly by the overscroll | 1565 // Tests that touch-scroll events are handled correctly by the overscroll |
1569 // controller. This also tests that the overscroll controller and the | 1566 // controller. This also tests that the overscroll controller and the |
1570 // gesture-event filter play nice with each other. | 1567 // gesture-event filter play nice with each other. |
1571 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) { | 1568 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) { |
1572 // Turn off debounce handling for test isolation. | 1569 // Turn off debounce handling for test isolation. |
1573 host_->SetupForOverscrollControllerTest(); | 1570 host_->SetupForOverscrollControllerTest(); |
1574 host_->DisableGestureDebounce(); | |
1575 process_->sink().ClearMessages(); | 1571 process_->sink().ClearMessages(); |
1576 | 1572 |
1577 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1573 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1578 WebGestureEvent::Touchscreen); | 1574 WebGestureEvent::Touchscreen); |
1579 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1575 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
1580 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1576 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
1581 | 1577 |
1582 // Send another gesture event and ACK as not being processed. This should | 1578 // Send another gesture event and ACK as not being processed. This should |
1583 // initiate the navigation gesture. | 1579 // initiate the navigation gesture. |
1584 SimulateGestureScrollUpdateEvent(55, -5, 0); | 1580 SimulateGestureScrollUpdateEvent(55, -5, 0); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 // router. | 1614 // router. |
1619 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1615 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1620 } | 1616 } |
1621 | 1617 |
1622 // Tests that if the page is scrolled because of a scroll-gesture, then that | 1618 // Tests that if the page is scrolled because of a scroll-gesture, then that |
1623 // particular scroll sequence never generates overscroll if the scroll direction | 1619 // particular scroll sequence never generates overscroll if the scroll direction |
1624 // is horizontal. | 1620 // is horizontal. |
1625 TEST_F(RenderWidgetHostTest, GestureScrollConsumedHorizontal) { | 1621 TEST_F(RenderWidgetHostTest, GestureScrollConsumedHorizontal) { |
1626 // Turn off debounce handling for test isolation. | 1622 // Turn off debounce handling for test isolation. |
1627 host_->SetupForOverscrollControllerTest(); | 1623 host_->SetupForOverscrollControllerTest(); |
1628 host_->DisableGestureDebounce(); | |
1629 process_->sink().ClearMessages(); | 1624 process_->sink().ClearMessages(); |
1630 | 1625 |
1631 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1626 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1632 WebGestureEvent::Touchscreen); | 1627 WebGestureEvent::Touchscreen); |
1633 SimulateGestureScrollUpdateEvent(10, 0, 0); | 1628 SimulateGestureScrollUpdateEvent(10, 0, 0); |
1634 | 1629 |
1635 // Start scrolling on content. ACK both events as being processed. | 1630 // Start scrolling on content. ACK both events as being processed. |
1636 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1631 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1637 INPUT_EVENT_ACK_STATE_CONSUMED); | 1632 INPUT_EVENT_ACK_STATE_CONSUMED); |
1638 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1633 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 // should reach the renderer. | 2068 // should reach the renderer. |
2074 SimulateGestureScrollUpdateEvent(-20, 0, 0); | 2069 SimulateGestureScrollUpdateEvent(-20, 0, 0); |
2075 EXPECT_EQ(1U, process_->sink().message_count()); | 2070 EXPECT_EQ(1U, process_->sink().message_count()); |
2076 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2071 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
2077 } | 2072 } |
2078 | 2073 |
2079 // Tests that if a mouse-move event completes the overscroll gesture, future | 2074 // Tests that if a mouse-move event completes the overscroll gesture, future |
2080 // move events do reach the renderer. | 2075 // move events do reach the renderer. |
2081 TEST_F(RenderWidgetHostTest, OverscrollMouseMoveCompletion) { | 2076 TEST_F(RenderWidgetHostTest, OverscrollMouseMoveCompletion) { |
2082 host_->SetupForOverscrollControllerTest(); | 2077 host_->SetupForOverscrollControllerTest(); |
2083 host_->DisableGestureDebounce(); | |
2084 process_->sink().ClearMessages(); | 2078 process_->sink().ClearMessages(); |
2085 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 2079 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
2086 view_->Show(); | 2080 view_->Show(); |
2087 | 2081 |
2088 SimulateWheelEvent(5, 0, 0, true); // sent directly | 2082 SimulateWheelEvent(5, 0, 0, true); // sent directly |
2089 SimulateWheelEvent(-1, 0, 0, true); // enqueued | 2083 SimulateWheelEvent(-1, 0, 0, true); // enqueued |
2090 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event | 2084 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event |
2091 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event | 2085 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event |
2092 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event | 2086 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event |
2093 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2087 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 | 2158 |
2165 SendInputEventACK(WebInputEvent::MouseMove, | 2159 SendInputEventACK(WebInputEvent::MouseMove, |
2166 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2160 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2167 process_->sink().ClearMessages(); | 2161 process_->sink().ClearMessages(); |
2168 } | 2162 } |
2169 | 2163 |
2170 // Tests that if a page scrolled, then the overscroll controller's states are | 2164 // Tests that if a page scrolled, then the overscroll controller's states are |
2171 // reset after the end of the scroll. | 2165 // reset after the end of the scroll. |
2172 TEST_F(RenderWidgetHostTest, OverscrollStateResetsAfterScroll) { | 2166 TEST_F(RenderWidgetHostTest, OverscrollStateResetsAfterScroll) { |
2173 host_->SetupForOverscrollControllerTest(); | 2167 host_->SetupForOverscrollControllerTest(); |
2174 host_->DisableGestureDebounce(); | |
2175 process_->sink().ClearMessages(); | 2168 process_->sink().ClearMessages(); |
2176 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 2169 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
2177 view_->Show(); | 2170 view_->Show(); |
2178 | 2171 |
2179 SimulateWheelEvent(0, 5, 0, true); // sent directly | 2172 SimulateWheelEvent(0, 5, 0, true); // sent directly |
2180 SimulateWheelEvent(0, 30, 0, true); // enqueued | 2173 SimulateWheelEvent(0, 30, 0, true); // enqueued |
2181 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event | 2174 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event |
2182 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event | 2175 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event |
2183 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2176 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
2184 EXPECT_EQ(1U, process_->sink().message_count()); | 2177 EXPECT_EQ(1U, process_->sink().message_count()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 | 2232 |
2240 // Start an overscroll with gesture scroll. In the middle of the scroll, blur | 2233 // Start an overscroll with gesture scroll. In the middle of the scroll, blur |
2241 // the host. | 2234 // the host. |
2242 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2235 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
2243 WebGestureEvent::Touchscreen); | 2236 WebGestureEvent::Touchscreen); |
2244 SimulateGestureScrollUpdateEvent(300, -5, 0); | 2237 SimulateGestureScrollUpdateEvent(300, -5, 0); |
2245 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2238 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2246 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2239 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2247 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 2240 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
2248 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2241 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 2242 EXPECT_EQ(2U, process_->sink().message_count()); |
2249 | 2243 |
2250 host_->Blur(); | 2244 host_->Blur(); |
2251 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2245 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
2252 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2246 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
2253 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 2247 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
2254 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_x()); | 2248 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_x()); |
2255 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); | 2249 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); |
2256 process_->sink().ClearMessages(); | 2250 process_->sink().ClearMessages(); |
2257 | 2251 |
2258 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2252 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
2259 WebGestureEvent::Touchscreen); | 2253 WebGestureEvent::Touchscreen); |
2260 EXPECT_EQ(0U, process_->sink().message_count()); | 2254 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2255 process_->sink().ClearMessages(); |
2261 | 2256 |
2262 // Start a scroll gesture again. This should correctly start the overscroll | 2257 // Start a scroll gesture again. This should correctly start the overscroll |
2263 // after the threshold. | 2258 // after the threshold. |
2264 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2259 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
2265 WebGestureEvent::Touchscreen); | 2260 WebGestureEvent::Touchscreen); |
2266 SimulateGestureScrollUpdateEvent(300, -5, 0); | 2261 SimulateGestureScrollUpdateEvent(300, -5, 0); |
2267 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2262 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2268 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2263 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2269 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 2264 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
2270 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2265 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
2271 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 2266 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
2272 | 2267 |
2273 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2268 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
2274 WebGestureEvent::Touchscreen); | 2269 WebGestureEvent::Touchscreen); |
2275 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2270 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
2276 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 2271 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
2277 process_->sink().ClearMessages(); | 2272 EXPECT_EQ(3U, process_->sink().message_count()); |
2278 } | 2273 } |
2279 | 2274 |
2280 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { | 2275 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { |
2281 const WebInputEvent* event = NULL; | 2276 const WebInputEvent* event = NULL; |
2282 ui::LatencyInfo latency_info; | 2277 ui::LatencyInfo latency_info; |
2283 bool is_keyboard_shortcut; | 2278 bool is_keyboard_shortcut; |
2284 std::string result; | 2279 std::string result; |
2285 for (size_t i = 0; i < process->sink().message_count(); ++i) { | 2280 for (size_t i = 0; i < process->sink().message_count(); ++i) { |
2286 const IPC::Message *message = process->sink().GetMessageAt(i); | 2281 const IPC::Message *message = process->sink().GetMessageAt(i); |
2287 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); | 2282 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
2288 EXPECT_TRUE(InputMsg_HandleInputEvent::Read( | 2283 EXPECT_TRUE(InputMsg_HandleInputEvent::Read( |
2289 message, &event, &latency_info, &is_keyboard_shortcut)); | 2284 message, &event, &latency_info, &is_keyboard_shortcut)); |
2290 if (i != 0) | 2285 if (i != 0) |
2291 result += " "; | 2286 result += " "; |
2292 result += WebInputEventTraits::GetName(event->type); | 2287 result += WebInputEventTraits::GetName(event->type); |
2293 } | 2288 } |
2294 process->sink().ClearMessages(); | 2289 process->sink().ClearMessages(); |
2295 return result; | 2290 return result; |
2296 } | 2291 } |
2297 | 2292 |
2298 TEST_F(RenderWidgetHostTest, TouchEmulator) { | 2293 TEST_F(RenderWidgetHostTest, TouchEmulator) { |
2299 simulated_event_time_delta_seconds_ = 0.1; | 2294 simulated_event_time_delta_seconds_ = 0.1; |
2300 host_->DisableGestureDebounce(); | |
2301 // Immediately ack all touches instead of sending them to the renderer. | 2295 // Immediately ack all touches instead of sending them to the renderer. |
2302 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 2296 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
2303 host_->OnMessageReceived( | 2297 host_->OnMessageReceived( |
2304 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true)); | 2298 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true)); |
2305 process_->sink().ClearMessages(); | 2299 process_->sink().ClearMessages(); |
2306 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 2300 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
2307 view_->Show(); | 2301 view_->Show(); |
2308 | 2302 |
2309 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); | 2303 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); |
2310 EXPECT_EQ(0U, process_->sink().message_count()); | 2304 EXPECT_EQ(0U, process_->sink().message_count()); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2675 | 2669 |
2676 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 2670 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
2677 PressTouchPoint(0, 1); | 2671 PressTouchPoint(0, 1); |
2678 SendTouchEvent(); | 2672 SendTouchEvent(); |
2679 CheckLatencyInfoComponentInMessage( | 2673 CheckLatencyInfoComponentInMessage( |
2680 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 2674 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
2681 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 2675 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
2682 } | 2676 } |
2683 | 2677 |
2684 } // namespace content | 2678 } // namespace content |
OLD | NEW |