Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" | 
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" | 
| 8 #include "content/browser/renderer_host/input/gesture_event_filter.h" | 8 #include "content/browser/renderer_host/input/gesture_event_filter.h" | 
| 9 #include "content/browser/renderer_host/input/immediate_input_router.h" | 9 #include "content/browser/renderer_host/input/immediate_input_router.h" | 
| 10 #include "content/browser/renderer_host/input/input_router_client.h" | 10 #include "content/browser/renderer_host/input/input_router_client.h" | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 } | 142 } | 
| 143 | 143 | 
| 144 const WebTouchEvent& latest_event() const { | 144 const WebTouchEvent& latest_event() const { | 
| 145 return touch_event_queue()->GetLatestEvent().event; | 145 return touch_event_queue()->GetLatestEvent().event; | 
| 146 } | 146 } | 
| 147 | 147 | 
| 148 void EnableNoTouchToRendererWhileScrolling() { | 148 void EnableNoTouchToRendererWhileScrolling() { | 
| 149 input_router()->enable_no_touch_to_renderer_while_scrolling_ = true; | 149 input_router()->enable_no_touch_to_renderer_while_scrolling_ = true; | 
| 150 } | 150 } | 
| 151 | 151 | 
| 152 bool no_touch_move_to_renderer() { | 152 bool no_touch_to_renderer() { | 
| 153 return touch_event_queue()->no_touch_move_to_renderer_; | 153 return touch_event_queue()->no_touch_to_renderer_; | 
| 154 } | 154 } | 
| 155 | 155 | 
| 156 TouchEventQueue* touch_event_queue() const { | 156 TouchEventQueue* touch_event_queue() const { | 
| 157 return input_router()->touch_event_queue(); | 157 return input_router()->touch_event_queue(); | 
| 158 } | 158 } | 
| 159 | 159 | 
| 160 unsigned GestureEventLastQueueEventSize() { | 160 unsigned GestureEventLastQueueEventSize() { | 
| 161 return gesture_event_filter()->coalesced_gesture_events_.size(); | 161 return gesture_event_filter()->coalesced_gesture_events_.size(); | 
| 162 } | 162 } | 
| 163 | 163 | 
| (...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1759 // Check that the second event was sent. | 1759 // Check that the second event was sent. | 
| 1760 EXPECT_EQ(1U, process_->sink().message_count()); | 1760 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1761 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1761 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 
| 1762 InputMsg_HandleInputEvent::ID)); | 1762 InputMsg_HandleInputEvent::ID)); | 
| 1763 process_->sink().ClearMessages(); | 1763 process_->sink().ClearMessages(); | 
| 1764 | 1764 | 
| 1765 // Check that the correct unhandled wheel event was received. | 1765 // Check that the correct unhandled wheel event was received. | 
| 1766 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); | 1766 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); | 
| 1767 } | 1767 } | 
| 1768 | 1768 | 
| 1769 // Tests that no touch move events are sent to renderer during scrolling. | 1769 // Tests that no touch events are sent to renderer during scrolling. | 
| 1770 TEST_F(ImmediateInputRouterTest, NoTouchMoveWhileScroll) { | 1770 TEST_F(ImmediateInputRouterTest, NoTouchWhileScroll) { | 
| 1771 EnableNoTouchToRendererWhileScrolling(); | 1771 EnableNoTouchToRendererWhileScrolling(); | 
| 1772 set_debounce_interval_time_ms(0); | 1772 set_debounce_interval_time_ms(0); | 
| 1773 input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1773 input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 
| 1774 process_->sink().ClearMessages(); | 1774 process_->sink().ClearMessages(); | 
| 1775 | 1775 | 
| 1776 // First touch press. | 1776 // First touch press. | 
| 1777 PressTouchPoint(0, 1); | 1777 PressTouchPoint(0, 1); | 
| 1778 SendTouchEvent(); | 1778 SendTouchEvent(); | 
| 1779 EXPECT_EQ(1U, process_->sink().message_count()); | 1779 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1780 process_->sink().ClearMessages(); | 1780 process_->sink().ClearMessages(); | 
| 1781 SendInputEventACK(WebInputEvent::TouchStart, | 1781 SendInputEventACK(WebInputEvent::TouchStart, | 
| 1782 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1782 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1783 | 1783 | 
| 1784 // Touch move will trigger scroll. | 1784 // Touch move will trigger scroll. | 
| 1785 MoveTouchPoint(0, 20, 5); | 1785 MoveTouchPoint(0, 20, 5); | 
| 1786 SendTouchEvent(); | 1786 SendTouchEvent(); | 
| 1787 EXPECT_EQ(1U, process_->sink().message_count()); | 1787 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1788 process_->sink().ClearMessages(); | 1788 process_->sink().ClearMessages(); | 
| 1789 SendInputEventACK(WebInputEvent::TouchMove, | 1789 SendInputEventACK(WebInputEvent::TouchMove, | 
| 1790 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1790 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1791 | 1791 | 
| 1792 EXPECT_EQ(0U, TouchEventQueueSize()); | |
| 1792 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1793 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 
| 1793 WebGestureEvent::Touchscreen); | 1794 WebGestureEvent::Touchscreen); | 
| 1794 EXPECT_EQ(1U, process_->sink().message_count()); | 1795 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1795 EXPECT_TRUE(no_touch_move_to_renderer()); | 1796 // This is the touch cancel event in the queue. | 
| 1797 EXPECT_EQ(1U, TouchEventQueueSize()); | |
| 1798 EXPECT_TRUE(no_touch_to_renderer()); | |
| 1799 SendInputEventACK(WebInputEvent::TouchCancel, | |
| 1800 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 
 
sadrul
2013/09/23 16:17:33
The line in 1795 checks that only the scroll-begin
 
 | |
| 1796 process_->sink().ClearMessages(); | 1801 process_->sink().ClearMessages(); | 
| 1797 SendInputEventACK(WebInputEvent::GestureScrollBegin, | 1802 SendInputEventACK(WebInputEvent::GestureScrollBegin, | 
| 1798 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1803 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1799 | 1804 | 
| 1800 // Touch move should not be sent to renderer. | 1805 // Touch move should not be sent to renderer. | 
| 1801 MoveTouchPoint(0, 30, 5); | 1806 MoveTouchPoint(0, 30, 5); | 
| 1802 SendTouchEvent(); | 1807 SendTouchEvent(); | 
| 1803 EXPECT_EQ(0U, process_->sink().message_count()); | 1808 EXPECT_EQ(0U, process_->sink().message_count()); | 
| 1804 process_->sink().ClearMessages(); | 1809 process_->sink().ClearMessages(); | 
| 1805 | 1810 | 
| 1806 // Touch moves become ScrollUpdate. | 1811 // Touch moves become ScrollUpdate. | 
| 1807 SimulateGestureScrollUpdateEvent(20, 4, 0); | 1812 SimulateGestureScrollUpdateEvent(20, 4, 0); | 
| 1808 EXPECT_TRUE(no_touch_move_to_renderer()); | 1813 EXPECT_TRUE(no_touch_to_renderer()); | 
| 1809 process_->sink().ClearMessages(); | 1814 process_->sink().ClearMessages(); | 
| 1810 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1815 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 
| 1811 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1816 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1812 | 1817 | 
| 1813 // Touch move should not be sent to renderer. | 1818 // Touch move should not be sent to renderer. | 
| 1814 MoveTouchPoint(0, 65, 10); | 1819 MoveTouchPoint(0, 65, 10); | 
| 1815 SendTouchEvent(); | 1820 SendTouchEvent(); | 
| 1816 EXPECT_EQ(0U, process_->sink().message_count()); | 1821 EXPECT_EQ(0U, process_->sink().message_count()); | 
| 1817 process_->sink().ClearMessages(); | 1822 process_->sink().ClearMessages(); | 
| 1818 | 1823 | 
| 1819 // Touch end should still be sent to renderer. | 1824 // Touch end should not be sent to renderer. | 
| 1820 ReleaseTouchPoint(0); | 1825 ReleaseTouchPoint(0); | 
| 1821 SendTouchEvent(); | 1826 SendTouchEvent(); | 
| 1822 EXPECT_EQ(1U, process_->sink().message_count()); | 1827 EXPECT_EQ(0U, process_->sink().message_count()); | 
| 1823 process_->sink().ClearMessages(); | 1828 process_->sink().ClearMessages(); | 
| 1824 SendInputEventACK(WebInputEvent::TouchEnd, | |
| 1825 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1826 | 1829 | 
| 1827 // On GestureScrollEnd, resume sending touch moves to renderer. | 1830 // On GestureScrollEnd, resume sending touch moves to renderer. | 
| 1828 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, | 1831 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, | 
| 1829 WebGestureEvent::Touchscreen); | 1832 WebGestureEvent::Touchscreen); | 
| 1830 EXPECT_EQ(1U, process_->sink().message_count()); | 1833 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1831 EXPECT_FALSE(no_touch_move_to_renderer()); | 1834 EXPECT_FALSE(no_touch_to_renderer()); | 
| 1832 process_->sink().ClearMessages(); | 1835 process_->sink().ClearMessages(); | 
| 1833 SendInputEventACK(WebInputEvent::GestureScrollEnd, | 1836 SendInputEventACK(WebInputEvent::GestureScrollEnd, | 
| 1834 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1837 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1835 | 1838 | 
| 1836 // Now touch events should come through to renderer. | 1839 // Now touch events should come through to renderer. | 
| 1837 PressTouchPoint(80, 10); | 1840 PressTouchPoint(80, 10); | 
| 1838 SendTouchEvent(); | 1841 SendTouchEvent(); | 
| 1839 EXPECT_EQ(1U, process_->sink().message_count()); | 1842 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1840 process_->sink().ClearMessages(); | 1843 process_->sink().ClearMessages(); | 
| 1841 SendInputEventACK(WebInputEvent::TouchStart, | 1844 SendInputEventACK(WebInputEvent::TouchStart, | 
| 1842 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1845 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1843 | 1846 | 
| 1844 MoveTouchPoint(0, 80, 20); | 1847 MoveTouchPoint(0, 80, 20); | 
| 1845 SendTouchEvent(); | 1848 SendTouchEvent(); | 
| 1846 EXPECT_EQ(1U, process_->sink().message_count()); | 1849 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1847 process_->sink().ClearMessages(); | 1850 process_->sink().ClearMessages(); | 
| 1848 SendInputEventACK(WebInputEvent::TouchMove, | 1851 SendInputEventACK(WebInputEvent::TouchMove, | 
| 1849 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1852 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1850 | 1853 | 
| 1851 ReleaseTouchPoint(0); | 1854 ReleaseTouchPoint(0); | 
| 1852 SendTouchEvent(); | 1855 SendTouchEvent(); | 
| 1853 EXPECT_EQ(1U, process_->sink().message_count()); | 1856 EXPECT_EQ(1U, process_->sink().message_count()); | 
| 1854 process_->sink().ClearMessages(); | 1857 process_->sink().ClearMessages(); | 
| 1855 SendInputEventACK(WebInputEvent::TouchEnd, | 1858 SendInputEventACK(WebInputEvent::TouchEnd, | 
| 1856 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1859 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 
| 1857 } | 1860 } | 
| 1858 } // namespace content | 1861 } // namespace content | 
| OLD | NEW |