| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 EXPECT_EQ(1U, process_->sink().message_count()); | 1343 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1344 process_->sink().ClearMessages(); | 1344 process_->sink().ClearMessages(); |
| 1345 | 1345 |
| 1346 // Receive ACK for the second (coalesced) event as not processed. This should | 1346 // Receive ACK for the second (coalesced) event as not processed. This should |
| 1347 // not initiate overscroll, since the beginning of the scroll has been | 1347 // not initiate overscroll, since the beginning of the scroll has been |
| 1348 // consumed. The queued event with different modifiers should be sent to the | 1348 // consumed. The queued event with different modifiers should be sent to the |
| 1349 // renderer. | 1349 // renderer. |
| 1350 SendInputEventACK(WebInputEvent::MouseWheel, | 1350 SendInputEventACK(WebInputEvent::MouseWheel, |
| 1351 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1351 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1352 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1352 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1353 EXPECT_EQ(0U, process_->sink().message_count()); | 1353 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1354 | 1354 |
| 1355 process_->sink().ClearMessages(); | 1355 process_->sink().ClearMessages(); |
| 1356 SendInputEventACK(WebInputEvent::MouseWheel, | 1356 SendInputEventACK(WebInputEvent::MouseWheel, |
| 1357 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1357 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1358 EXPECT_EQ(0U, process_->sink().message_count()); | 1358 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1359 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1359 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1360 | 1360 |
| 1361 // Indicate the end of the scrolling from the touchpad. | 1361 // Indicate the end of the scrolling from the touchpad. |
| 1362 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad); | 1362 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad); |
| 1363 EXPECT_EQ(1U, process_->sink().message_count()); | 1363 EXPECT_EQ(1U, process_->sink().message_count()); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 // not initiate overscroll because the beginning of the scroll event did | 1680 // not initiate overscroll because the beginning of the scroll event did |
| 1681 // scroll some content on the page. Since there was no overscroll, the event | 1681 // scroll some content on the page. Since there was no overscroll, the event |
| 1682 // should reach the renderer. | 1682 // should reach the renderer. |
| 1683 SimulateGestureScrollUpdateEvent(55, 0, 0); | 1683 SimulateGestureScrollUpdateEvent(55, 0, 0); |
| 1684 EXPECT_EQ(1U, process_->sink().message_count()); | 1684 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1685 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1685 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1686 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1686 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1687 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1687 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 // Tests that if the page is scrolled because of a scroll-gesture, then that | |
| 1691 // particular scroll sequence never generates overscroll if the scroll direction | |
| 1692 // is vertical. | |
| 1693 TEST_F(RenderWidgetHostTest, GestureScrollConsumedVertical) { | |
| 1694 // Turn off debounce handling for test isolation. | |
| 1695 host_->SetupForOverscrollControllerTest(); | |
| 1696 host_->set_debounce_interval_time_ms(0); | |
| 1697 process_->sink().ClearMessages(); | |
| 1698 | |
| 1699 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | |
| 1700 WebGestureEvent::Touchscreen); | |
| 1701 SimulateGestureScrollUpdateEvent(0, -1, 0); | |
| 1702 | |
| 1703 // Start scrolling on content. ACK both events as being processed. | |
| 1704 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1705 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1706 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
| 1707 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1708 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | |
| 1709 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | |
| 1710 | |
| 1711 // Send another gesture event and ACK as not being processed. This should | |
| 1712 // initiate overscroll because the scroll was in the vertical direction even | |
| 1713 // though the beginning of the scroll did scroll content. | |
| 1714 SimulateGestureScrollUpdateEvent(0, -50, 0); | |
| 1715 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
| 1716 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1717 EXPECT_EQ(OVERSCROLL_NORTH, host_->overscroll_mode()); | |
| 1718 | |
| 1719 // Changing direction of scroll to be horizontal to test that this causes the | |
| 1720 // vertical overscroll to stop. | |
| 1721 SimulateGestureScrollUpdateEvent(500, 0, 0); | |
| 1722 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | |
| 1723 } | |
| 1724 | |
| 1725 // Tests that the overscroll controller plays nice with touch-scrolls and the | 1690 // Tests that the overscroll controller plays nice with touch-scrolls and the |
| 1726 // gesture event filter with debounce filtering turned on. | 1691 // gesture event filter with debounce filtering turned on. |
| 1727 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { | 1692 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { |
| 1728 host_->SetupForOverscrollControllerTest(); | 1693 host_->SetupForOverscrollControllerTest(); |
| 1729 host_->set_debounce_interval_time_ms(100); | 1694 host_->set_debounce_interval_time_ms(100); |
| 1730 process_->sink().ClearMessages(); | 1695 process_->sink().ClearMessages(); |
| 1731 | 1696 |
| 1732 // Start scrolling. Receive ACK as it being processed. | 1697 // Start scrolling. Receive ACK as it being processed. |
| 1733 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1698 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1734 WebGestureEvent::Touchscreen); | 1699 WebGestureEvent::Touchscreen); |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2512 | 2477 |
| 2513 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { | 2478 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { |
| 2514 host_->SetupForInputRouterTest(); | 2479 host_->SetupForInputRouterTest(); |
| 2515 | 2480 |
| 2516 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 2481 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 2517 | 2482 |
| 2518 EXPECT_TRUE(host_->mock_input_router()->message_received_); | 2483 EXPECT_TRUE(host_->mock_input_router()->message_received_); |
| 2519 } | 2484 } |
| 2520 | 2485 |
| 2521 } // namespace content | 2486 } // namespace content |
| OLD | NEW |