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