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