| 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" |
| (...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 1540 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 1541 view_->Show(); | 1541 view_->Show(); |
| 1542 | 1542 |
| 1543 { | 1543 { |
| 1544 // Start and end a gesture in the same direction without processing the | 1544 // Start and end a gesture in the same direction without processing the |
| 1545 // gesture events in the renderer. This should initiate and complete an | 1545 // gesture events in the renderer. This should initiate and complete an |
| 1546 // overscroll navigation. | 1546 // overscroll navigation. |
| 1547 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1547 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1548 WebGestureEvent::Touchscreen); | 1548 WebGestureEvent::Touchscreen); |
| 1549 SimulateGestureScrollUpdateEvent(300, -5, 0); | 1549 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 1550 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1551 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1552 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1550 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1553 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1551 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1554 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 1552 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 1555 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1553 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 1556 process_->sink().ClearMessages(); | 1554 process_->sink().ClearMessages(); |
| 1557 | 1555 |
| 1558 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1556 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1559 WebGestureEvent::Touchscreen); | 1557 WebGestureEvent::Touchscreen); |
| 1560 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 1558 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
| 1561 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1559 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1562 EXPECT_EQ(1U, process_->sink().message_count()); | 1560 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1563 SendInputEventACK(WebInputEvent::GestureScrollEnd, | |
| 1564 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1565 } | 1561 } |
| 1566 | 1562 |
| 1567 { | 1563 { |
| 1568 // Start over, except instead of ending the gesture with ScrollEnd, end it | 1564 // Start over, except instead of ending the gesture with ScrollEnd, end it |
| 1569 // with a FlingStart, with velocity in the reverse direction. This should | 1565 // with a FlingStart, with velocity in the reverse direction. This should |
| 1570 // initiate an overscroll navigation, but it should be cancelled because of | 1566 // initiate an overscroll navigation, but it should be cancelled because of |
| 1571 // the fling in the opposite direction. | 1567 // the fling in the opposite direction. |
| 1572 host_->overscroll_delegate()->Reset(); | 1568 host_->overscroll_delegate()->Reset(); |
| 1573 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1569 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1574 WebGestureEvent::Touchscreen); | 1570 WebGestureEvent::Touchscreen); |
| 1575 SimulateGestureScrollUpdateEvent(-300, -5, 0); | 1571 SimulateGestureScrollUpdateEvent(-300, -5, 0); |
| 1576 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1577 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1578 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1572 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1579 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1573 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1580 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); | 1574 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); |
| 1581 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); | 1575 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); |
| 1582 process_->sink().ClearMessages(); | 1576 process_->sink().ClearMessages(); |
| 1583 | 1577 |
| 1584 SimulateGestureFlingStartEvent(100, 0, WebGestureEvent::Touchscreen); | 1578 SimulateGestureFlingStartEvent(100, 0, WebGestureEvent::Touchscreen); |
| 1585 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 1579 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
| 1586 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1580 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1587 EXPECT_EQ(1U, process_->sink().message_count()); | 1581 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1588 } | 1582 } |
| 1589 } | 1583 } |
| 1590 | 1584 |
| 1591 // Tests that touch-scroll events are handled correctly by the overscroll | 1585 // Tests that touch-scroll events are handled correctly by the overscroll |
| 1592 // controller. This also tests that the overscroll controller and the | 1586 // controller. This also tests that the overscroll controller and the |
| 1593 // gesture-event filter play nice with each other. | 1587 // gesture-event filter play nice with each other. |
| 1594 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) { | 1588 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) { |
| 1595 // Turn off debounce handling for test isolation. | 1589 // Turn off debounce handling for test isolation. |
| 1596 host_->SetupForOverscrollControllerTest(); | 1590 host_->SetupForOverscrollControllerTest(); |
| 1597 host_->DisableGestureDebounce(); | 1591 host_->DisableGestureDebounce(); |
| 1598 process_->sink().ClearMessages(); | 1592 process_->sink().ClearMessages(); |
| 1599 | 1593 |
| 1600 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1594 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1601 WebGestureEvent::Touchscreen); | 1595 WebGestureEvent::Touchscreen); |
| 1602 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1603 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1604 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1596 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1605 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1597 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1606 | 1598 |
| 1607 // Send another gesture event and ACK as not being processed. This should | 1599 // Send another gesture event and ACK as not being processed. This should |
| 1608 // initiate the navigation gesture. | 1600 // initiate the navigation gesture. |
| 1609 SimulateGestureScrollUpdateEvent(55, -5, 0); | 1601 SimulateGestureScrollUpdateEvent(55, -5, 0); |
| 1610 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1602 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1611 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1603 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1612 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 1604 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 1613 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1605 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 // Turn off debounce handling for test isolation. | 1643 // Turn off debounce handling for test isolation. |
| 1652 host_->SetupForOverscrollControllerTest(); | 1644 host_->SetupForOverscrollControllerTest(); |
| 1653 host_->DisableGestureDebounce(); | 1645 host_->DisableGestureDebounce(); |
| 1654 process_->sink().ClearMessages(); | 1646 process_->sink().ClearMessages(); |
| 1655 | 1647 |
| 1656 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1648 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1657 WebGestureEvent::Touchscreen); | 1649 WebGestureEvent::Touchscreen); |
| 1658 SimulateGestureScrollUpdateEvent(10, 0, 0); | 1650 SimulateGestureScrollUpdateEvent(10, 0, 0); |
| 1659 | 1651 |
| 1660 // Start scrolling on content. ACK both events as being processed. | 1652 // Start scrolling on content. ACK both events as being processed. |
| 1661 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1662 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1663 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1653 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1664 INPUT_EVENT_ACK_STATE_CONSUMED); | 1654 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1665 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1655 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1666 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1656 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1667 process_->sink().ClearMessages(); | 1657 process_->sink().ClearMessages(); |
| 1668 | 1658 |
| 1669 // Send another gesture event and ACK as not being processed. This should | 1659 // Send another gesture event and ACK as not being processed. This should |
| 1670 // not initiate overscroll because the beginning of the scroll event did | 1660 // not initiate overscroll because the beginning of the scroll event did |
| 1671 // scroll some content on the page. Since there was no overscroll, the event | 1661 // scroll some content on the page. Since there was no overscroll, the event |
| 1672 // should reach the renderer. | 1662 // should reach the renderer. |
| 1673 SimulateGestureScrollUpdateEvent(55, 0, 0); | 1663 SimulateGestureScrollUpdateEvent(55, 0, 0); |
| 1674 EXPECT_EQ(1U, process_->sink().message_count()); | 1664 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1675 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1665 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1676 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1666 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1677 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1667 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1678 } | 1668 } |
| 1679 | 1669 |
| 1680 // Tests that the overscroll controller plays nice with touch-scrolls and the | 1670 // Tests that the overscroll controller plays nice with touch-scrolls and the |
| 1681 // gesture event filter with debounce filtering turned on. | 1671 // gesture event filter with debounce filtering turned on. |
| 1682 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { | 1672 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { |
| 1683 host_->SetupForOverscrollControllerTest(); | 1673 host_->SetupForOverscrollControllerTest(); |
| 1684 host_->set_debounce_interval_time_ms(100); | 1674 host_->set_debounce_interval_time_ms(100); |
| 1685 process_->sink().ClearMessages(); | 1675 process_->sink().ClearMessages(); |
| 1686 | 1676 |
| 1687 // Start scrolling. Receive ACK as it being processed. | 1677 // Start scrolling. Receive ACK as it being processed. |
| 1688 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1678 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1689 WebGestureEvent::Touchscreen); | 1679 WebGestureEvent::Touchscreen); |
| 1690 EXPECT_EQ(1U, process_->sink().message_count()); | 1680 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1691 process_->sink().ClearMessages(); | 1681 process_->sink().ClearMessages(); |
| 1692 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1693 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1694 | 1682 |
| 1695 // Send update events. | 1683 // Send update events. |
| 1696 SimulateGestureScrollUpdateEvent(25, 0, 0); | 1684 SimulateGestureScrollUpdateEvent(25, 0, 0); |
| 1697 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1685 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1698 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1686 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 1699 EXPECT_TRUE(host_->ScrollingInProgress()); | 1687 EXPECT_TRUE(host_->ScrollingInProgress()); |
| 1700 EXPECT_EQ(1U, process_->sink().message_count()); | 1688 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1701 process_->sink().ClearMessages(); | 1689 process_->sink().ClearMessages(); |
| 1702 | 1690 |
| 1703 // Quickly end and restart the scroll gesture. These two events should get | 1691 // Quickly end and restart the scroll gesture. These two events should get |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 TEST_F(RenderWidgetHostTest, GestureScrollDebounceTimerOverscroll) { | 1750 TEST_F(RenderWidgetHostTest, GestureScrollDebounceTimerOverscroll) { |
| 1763 host_->SetupForOverscrollControllerTest(); | 1751 host_->SetupForOverscrollControllerTest(); |
| 1764 host_->set_debounce_interval_time_ms(10); | 1752 host_->set_debounce_interval_time_ms(10); |
| 1765 process_->sink().ClearMessages(); | 1753 process_->sink().ClearMessages(); |
| 1766 | 1754 |
| 1767 // Start scrolling. Receive ACK as it being processed. | 1755 // Start scrolling. Receive ACK as it being processed. |
| 1768 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1756 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1769 WebGestureEvent::Touchscreen); | 1757 WebGestureEvent::Touchscreen); |
| 1770 EXPECT_EQ(1U, process_->sink().message_count()); | 1758 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1771 process_->sink().ClearMessages(); | 1759 process_->sink().ClearMessages(); |
| 1772 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1773 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1774 | 1760 |
| 1775 // Send update events. | 1761 // Send update events. |
| 1776 SimulateGestureScrollUpdateEvent(55, 0, 0); | 1762 SimulateGestureScrollUpdateEvent(55, 0, 0); |
| 1777 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1763 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1778 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1764 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 1779 EXPECT_TRUE(host_->ScrollingInProgress()); | 1765 EXPECT_TRUE(host_->ScrollingInProgress()); |
| 1780 EXPECT_EQ(1U, process_->sink().message_count()); | 1766 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1781 process_->sink().ClearMessages(); | 1767 process_->sink().ClearMessages(); |
| 1782 | 1768 |
| 1783 // Send an end event. This should get in the debounce queue. | 1769 // Send an end event. This should get in the debounce queue. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 process_->sink().ClearMessages(); | 1830 process_->sink().ClearMessages(); |
| 1845 SendInputEventACK(WebInputEvent::TouchMove, | 1831 SendInputEventACK(WebInputEvent::TouchMove, |
| 1846 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1832 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1847 | 1833 |
| 1848 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1834 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1849 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1835 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1850 | 1836 |
| 1851 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1837 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1852 WebGestureEvent::Touchscreen); | 1838 WebGestureEvent::Touchscreen); |
| 1853 SimulateGestureScrollUpdateEvent(20, 0, 0); | 1839 SimulateGestureScrollUpdateEvent(20, 0, 0); |
| 1854 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1855 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1856 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1840 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1857 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1841 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1858 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1842 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1859 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1843 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1860 process_->sink().ClearMessages(); | 1844 process_->sink().ClearMessages(); |
| 1861 | 1845 |
| 1862 // Another touch move event should reach the renderer since overscroll hasn't | 1846 // Another touch move event should reach the renderer since overscroll hasn't |
| 1863 // started yet. | 1847 // started yet. |
| 1864 MoveTouchPoint(0, 65, 10); | 1848 MoveTouchPoint(0, 65, 10); |
| 1865 SendTouchEvent(); | 1849 SendTouchEvent(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 view_->Show(); | 1944 view_->Show(); |
| 1961 | 1945 |
| 1962 // Start scrolling. Receive ACK as it being processed. | 1946 // Start scrolling. Receive ACK as it being processed. |
| 1963 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1947 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1964 WebGestureEvent::Touchscreen); | 1948 WebGestureEvent::Touchscreen); |
| 1965 EXPECT_EQ(1U, process_->sink().message_count()); | 1949 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1966 // The scroll begin event will have received a synthetic ack from the input | 1950 // The scroll begin event will have received a synthetic ack from the input |
| 1967 // router. | 1951 // router. |
| 1968 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1952 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1969 process_->sink().ClearMessages(); | 1953 process_->sink().ClearMessages(); |
| 1970 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 1971 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1972 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1954 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1973 EXPECT_EQ(0U, process_->sink().message_count()); | 1955 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1974 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1956 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1975 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1957 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1976 | 1958 |
| 1977 // Send update events. | 1959 // Send update events. |
| 1978 SimulateGestureScrollUpdateEvent(55, -5, 0); | 1960 SimulateGestureScrollUpdateEvent(55, -5, 0); |
| 1979 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1961 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1980 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1962 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 1981 EXPECT_TRUE(host_->ScrollingInProgress()); | 1963 EXPECT_TRUE(host_->ScrollingInProgress()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2007 FROM_HERE, | 1989 FROM_HERE, |
| 2008 base::MessageLoop::QuitClosure(), | 1990 base::MessageLoop::QuitClosure(), |
| 2009 TimeDelta::FromMilliseconds(10)); | 1991 TimeDelta::FromMilliseconds(10)); |
| 2010 base::MessageLoop::current()->Run(); | 1992 base::MessageLoop::current()->Run(); |
| 2011 EXPECT_EQ(1U, process_->sink().message_count()); | 1993 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2012 process_->sink().ClearMessages(); | 1994 process_->sink().ClearMessages(); |
| 2013 // The scroll end event will have received a synthetic ack from the input | 1995 // The scroll end event will have received a synthetic ack from the input |
| 2014 // router. | 1996 // router. |
| 2015 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1997 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2016 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1998 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 2017 | |
| 2018 SendInputEventACK(blink::WebInputEvent::GestureScrollEnd, | |
| 2019 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2020 EXPECT_EQ(0U, process_->sink().message_count()); | 1999 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2021 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 2022 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | |
| 2023 | 2000 |
| 2024 // Start scrolling. Receive ACK as it being processed. | 2001 // Start scrolling. Receive ACK as it being processed. |
| 2025 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2002 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2026 WebGestureEvent::Touchscreen); | 2003 WebGestureEvent::Touchscreen); |
| 2027 EXPECT_EQ(1U, process_->sink().message_count()); | 2004 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2028 // The scroll begin event will have received a synthetic ack from the input | 2005 // The scroll begin event will have received a synthetic ack from the input |
| 2029 // router. | 2006 // router. |
| 2030 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2007 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2031 process_->sink().ClearMessages(); | 2008 process_->sink().ClearMessages(); |
| 2032 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2033 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2034 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2009 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2035 EXPECT_EQ(0U, process_->sink().message_count()); | 2010 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2036 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2011 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 2037 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2012 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2038 | 2013 |
| 2039 // Send update events. | 2014 // Send update events. |
| 2040 SimulateGestureScrollUpdateEvent(235, -5, 0); | 2015 SimulateGestureScrollUpdateEvent(235, -5, 0); |
| 2041 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2016 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2042 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 2017 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 2043 EXPECT_TRUE(host_->ScrollingInProgress()); | 2018 EXPECT_TRUE(host_->ScrollingInProgress()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2070 FROM_HERE, | 2045 FROM_HERE, |
| 2071 base::MessageLoop::QuitClosure(), | 2046 base::MessageLoop::QuitClosure(), |
| 2072 TimeDelta::FromMilliseconds(10)); | 2047 TimeDelta::FromMilliseconds(10)); |
| 2073 base::MessageLoop::current()->Run(); | 2048 base::MessageLoop::current()->Run(); |
| 2074 EXPECT_EQ(1U, process_->sink().message_count()); | 2049 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2075 process_->sink().ClearMessages(); | 2050 process_->sink().ClearMessages(); |
| 2076 // The scroll end event will have received a synthetic ack from the input | 2051 // The scroll end event will have received a synthetic ack from the input |
| 2077 // router. | 2052 // router. |
| 2078 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2053 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2079 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 2054 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 2080 | |
| 2081 SendInputEventACK(blink::WebInputEvent::GestureScrollEnd, | |
| 2082 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2083 EXPECT_EQ(0U, process_->sink().message_count()); | 2055 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2084 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 2085 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | |
| 2086 } | 2056 } |
| 2087 | 2057 |
| 2088 TEST_F(RenderWidgetHostTest, OverscrollDirectionChange) { | 2058 TEST_F(RenderWidgetHostTest, OverscrollDirectionChange) { |
| 2089 host_->SetupForOverscrollControllerTest(); | 2059 host_->SetupForOverscrollControllerTest(); |
| 2090 host_->set_debounce_interval_time_ms(100); | 2060 host_->set_debounce_interval_time_ms(100); |
| 2091 process_->sink().ClearMessages(); | 2061 process_->sink().ClearMessages(); |
| 2092 | 2062 |
| 2093 // Start scrolling. Receive ACK as it being processed. | 2063 // Start scrolling. Receive ACK as it being processed. |
| 2094 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2064 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2095 WebGestureEvent::Touchscreen); | 2065 WebGestureEvent::Touchscreen); |
| 2096 EXPECT_EQ(1U, process_->sink().message_count()); | 2066 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2097 process_->sink().ClearMessages(); | 2067 process_->sink().ClearMessages(); |
| 2098 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2099 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2100 | 2068 |
| 2101 // Send update events and receive ack as not consumed. | 2069 // Send update events and receive ack as not consumed. |
| 2102 SimulateGestureScrollUpdateEvent(125, -5, 0); | 2070 SimulateGestureScrollUpdateEvent(125, -5, 0); |
| 2103 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2071 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2104 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 2072 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 2105 EXPECT_TRUE(host_->ScrollingInProgress()); | 2073 EXPECT_TRUE(host_->ScrollingInProgress()); |
| 2106 EXPECT_EQ(1U, process_->sink().message_count()); | 2074 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2107 process_->sink().ClearMessages(); | 2075 process_->sink().ClearMessages(); |
| 2108 | 2076 |
| 2109 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2077 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 SimulateMouseMove(5, 10, 0); | 2144 SimulateMouseMove(5, 10, 0); |
| 2177 SendInputEventACK(WebInputEvent::MouseMove, | 2145 SendInputEventACK(WebInputEvent::MouseMove, |
| 2178 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2146 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2179 EXPECT_EQ(1U, process_->sink().message_count()); | 2147 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2180 process_->sink().ClearMessages(); | 2148 process_->sink().ClearMessages(); |
| 2181 | 2149 |
| 2182 // Now try with gestures. | 2150 // Now try with gestures. |
| 2183 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2151 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2184 WebGestureEvent::Touchscreen); | 2152 WebGestureEvent::Touchscreen); |
| 2185 SimulateGestureScrollUpdateEvent(300, -5, 0); | 2153 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 2186 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2187 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2188 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2154 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2189 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2155 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2190 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 2156 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 2191 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2157 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 2192 process_->sink().ClearMessages(); | 2158 process_->sink().ClearMessages(); |
| 2193 | 2159 |
| 2194 // Overscroll gesture is in progress. Send a mouse-move now. This should | 2160 // Overscroll gesture is in progress. Send a mouse-move now. This should |
| 2195 // complete the gesture (because the amount overscrolled is above the | 2161 // complete the gesture (because the amount overscrolled is above the |
| 2196 // threshold). | 2162 // threshold). |
| 2197 SimulateMouseMove(5, 10, 0); | 2163 SimulateMouseMove(5, 10, 0); |
| 2198 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 2164 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
| 2199 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2165 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 2200 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2166 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2201 EXPECT_EQ(1U, process_->sink().message_count()); | 2167 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2202 process_->sink().ClearMessages(); | 2168 process_->sink().ClearMessages(); |
| 2203 SendInputEventACK(WebInputEvent::MouseMove, | 2169 SendInputEventACK(WebInputEvent::MouseMove, |
| 2204 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2170 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2205 | 2171 |
| 2206 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2172 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 2207 WebGestureEvent::Touchscreen); | 2173 WebGestureEvent::Touchscreen); |
| 2208 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2174 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2209 EXPECT_EQ(1U, process_->sink().message_count()); | 2175 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2210 process_->sink().ClearMessages(); | 2176 process_->sink().ClearMessages(); |
| 2211 SendInputEventACK(WebInputEvent::GestureScrollEnd, | |
| 2212 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2213 | 2177 |
| 2214 // Move mouse some more. The mouse-move events should reach the renderer. | 2178 // Move mouse some more. The mouse-move events should reach the renderer. |
| 2215 SimulateMouseMove(5, 10, 0); | 2179 SimulateMouseMove(5, 10, 0); |
| 2216 EXPECT_EQ(1U, process_->sink().message_count()); | 2180 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2217 | 2181 |
| 2218 SendInputEventACK(WebInputEvent::MouseMove, | 2182 SendInputEventACK(WebInputEvent::MouseMove, |
| 2219 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2183 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2220 process_->sink().ClearMessages(); | 2184 process_->sink().ClearMessages(); |
| 2221 } | 2185 } |
| 2222 | 2186 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 host_->SetupForOverscrollControllerTest(); | 2252 host_->SetupForOverscrollControllerTest(); |
| 2289 process_->sink().ClearMessages(); | 2253 process_->sink().ClearMessages(); |
| 2290 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 2254 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 2291 view_->Show(); | 2255 view_->Show(); |
| 2292 | 2256 |
| 2293 // Start an overscroll with gesture scroll. In the middle of the scroll, blur | 2257 // Start an overscroll with gesture scroll. In the middle of the scroll, blur |
| 2294 // the host. | 2258 // the host. |
| 2295 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2259 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2296 WebGestureEvent::Touchscreen); | 2260 WebGestureEvent::Touchscreen); |
| 2297 SimulateGestureScrollUpdateEvent(300, -5, 0); | 2261 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 2298 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2299 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2300 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2262 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2301 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2263 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2302 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 2264 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 2303 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2265 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 2304 | 2266 |
| 2305 host_->Blur(); | 2267 host_->Blur(); |
| 2306 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2268 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 2307 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2269 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2308 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 2270 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
| 2309 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_x()); | 2271 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_x()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 2323 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 2362 view_->Show(); | 2324 view_->Show(); |
| 2363 | 2325 |
| 2364 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); | 2326 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); |
| 2365 EXPECT_EQ(0U, process_->sink().message_count()); | 2327 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2366 | 2328 |
| 2367 // Mouse press becomes touch start which in turn becomes tap. | 2329 // Mouse press becomes touch start which in turn becomes tap. |
| 2368 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); | 2330 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); |
| 2369 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); | 2331 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); |
| 2370 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); | 2332 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); |
| 2371 SendInputEventACK(WebInputEvent::GestureTapDown, | |
| 2372 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2373 | 2333 |
| 2374 // Mouse drag generates touch move, cancels tap and starts scroll. | 2334 // Mouse drag generates touch move, cancels tap and starts scroll. |
| 2375 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true); | 2335 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true); |
| 2376 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2336 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2377 EXPECT_EQ( | 2337 EXPECT_EQ( |
| 2378 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", | 2338 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", |
| 2379 GetInputMessageTypes(process_)); | 2339 GetInputMessageTypes(process_)); |
| 2380 SendInputEventACK(WebInputEvent::GestureTapCancel, | |
| 2381 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2382 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2383 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2384 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2340 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2385 INPUT_EVENT_ACK_STATE_CONSUMED); | 2341 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2386 EXPECT_EQ(0U, process_->sink().message_count()); | 2342 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2387 | 2343 |
| 2388 // Mouse drag with shift becomes pinch. | 2344 // Mouse drag with shift becomes pinch. |
| 2389 SimulateMouseEvent( | 2345 SimulateMouseEvent( |
| 2390 WebInputEvent::MouseMove, 10, 40, WebInputEvent::ShiftKey, true); | 2346 WebInputEvent::MouseMove, 10, 40, WebInputEvent::ShiftKey, true); |
| 2391 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2347 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2392 EXPECT_EQ("GesturePinchBegin", | 2348 EXPECT_EQ("GesturePinchBegin", |
| 2393 GetInputMessageTypes(process_)); | 2349 GetInputMessageTypes(process_)); |
| 2394 SendInputEventACK(WebInputEvent::GesturePinchBegin, | |
| 2395 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2396 EXPECT_EQ(0U, process_->sink().message_count()); | 2350 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2397 | 2351 |
| 2398 SimulateMouseEvent( | 2352 SimulateMouseEvent( |
| 2399 WebInputEvent::MouseMove, 10, 50, WebInputEvent::ShiftKey, true); | 2353 WebInputEvent::MouseMove, 10, 50, WebInputEvent::ShiftKey, true); |
| 2400 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2354 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2401 EXPECT_EQ("GesturePinchUpdate", | 2355 EXPECT_EQ("GesturePinchUpdate", |
| 2402 GetInputMessageTypes(process_)); | 2356 GetInputMessageTypes(process_)); |
| 2403 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 2357 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
| 2404 INPUT_EVENT_ACK_STATE_CONSUMED); | 2358 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2405 EXPECT_EQ(0U, process_->sink().message_count()); | 2359 EXPECT_EQ(0U, process_->sink().message_count()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2417 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2371 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2418 EXPECT_EQ("GestureScrollUpdate", | 2372 EXPECT_EQ("GestureScrollUpdate", |
| 2419 GetInputMessageTypes(process_)); | 2373 GetInputMessageTypes(process_)); |
| 2420 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2374 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2421 INPUT_EVENT_ACK_STATE_CONSUMED); | 2375 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2422 EXPECT_EQ(0U, process_->sink().message_count()); | 2376 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2423 | 2377 |
| 2424 SimulateMouseEvent(WebInputEvent::MouseUp, 10, 70, 0, true); | 2378 SimulateMouseEvent(WebInputEvent::MouseUp, 10, 70, 0, true); |
| 2425 EXPECT_EQ(WebInputEvent::TouchEnd, host_->acked_touch_event_type()); | 2379 EXPECT_EQ(WebInputEvent::TouchEnd, host_->acked_touch_event_type()); |
| 2426 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_)); | 2380 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_)); |
| 2427 SendInputEventACK(WebInputEvent::GestureScrollEnd, | |
| 2428 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2429 EXPECT_EQ(0U, process_->sink().message_count()); | 2381 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2430 | 2382 |
| 2431 // Mouse move does nothing. | 2383 // Mouse move does nothing. |
| 2432 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 80, 0, false); | 2384 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 80, 0, false); |
| 2433 EXPECT_EQ(0U, process_->sink().message_count()); | 2385 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2434 | 2386 |
| 2435 // Another mouse down continues scroll. | 2387 // Another mouse down continues scroll. |
| 2436 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 80, 0, true); | 2388 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 80, 0, true); |
| 2437 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); | 2389 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); |
| 2438 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); | 2390 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); |
| 2439 SendInputEventACK(WebInputEvent::GestureTapDown, | |
| 2440 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2441 EXPECT_EQ(0U, process_->sink().message_count()); | 2391 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2442 | 2392 |
| 2443 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 100, 0, true); | 2393 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 100, 0, true); |
| 2444 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2394 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2445 EXPECT_EQ( | 2395 EXPECT_EQ( |
| 2446 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", | 2396 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", |
| 2447 GetInputMessageTypes(process_)); | 2397 GetInputMessageTypes(process_)); |
| 2448 SendInputEventACK(WebInputEvent::GestureTapCancel, | |
| 2449 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2450 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2451 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2452 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2398 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2453 INPUT_EVENT_ACK_STATE_CONSUMED); | 2399 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2454 EXPECT_EQ(0U, process_->sink().message_count()); | 2400 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2455 | 2401 |
| 2456 // Another pinch. | 2402 // Another pinch. |
| 2457 SimulateMouseEvent( | 2403 SimulateMouseEvent( |
| 2458 WebInputEvent::MouseMove, 10, 110, WebInputEvent::ShiftKey, true); | 2404 WebInputEvent::MouseMove, 10, 110, WebInputEvent::ShiftKey, true); |
| 2459 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2405 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2460 EXPECT_EQ("GesturePinchBegin", | 2406 EXPECT_EQ("GesturePinchBegin", |
| 2461 GetInputMessageTypes(process_)); | 2407 GetInputMessageTypes(process_)); |
| 2462 SendInputEventACK(WebInputEvent::GesturePinchBegin, | |
| 2463 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2464 EXPECT_EQ(0U, process_->sink().message_count()); | 2408 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2465 | 2409 |
| 2466 SimulateMouseEvent( | 2410 SimulateMouseEvent( |
| 2467 WebInputEvent::MouseMove, 10, 120, WebInputEvent::ShiftKey, true); | 2411 WebInputEvent::MouseMove, 10, 120, WebInputEvent::ShiftKey, true); |
| 2468 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2412 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2469 EXPECT_EQ("GesturePinchUpdate", | 2413 EXPECT_EQ("GesturePinchUpdate", |
| 2470 GetInputMessageTypes(process_)); | 2414 GetInputMessageTypes(process_)); |
| 2471 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 2415 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
| 2472 INPUT_EVENT_ACK_STATE_CONSUMED); | 2416 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2473 EXPECT_EQ(0U, process_->sink().message_count()); | 2417 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2474 | 2418 |
| 2475 // Turn off emulation during a pinch. | 2419 // Turn off emulation during a pinch. |
| 2476 host_->OnMessageReceived( | 2420 host_->OnMessageReceived( |
| 2477 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false)); | 2421 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false)); |
| 2478 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); | 2422 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); |
| 2479 EXPECT_EQ("GesturePinchEnd GestureScrollEnd", | 2423 EXPECT_EQ("GesturePinchEnd GestureScrollEnd", |
| 2480 GetInputMessageTypes(process_)); | 2424 GetInputMessageTypes(process_)); |
| 2481 SendInputEventACK(WebInputEvent::GesturePinchEnd, | |
| 2482 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2483 SendInputEventACK(WebInputEvent::GestureScrollEnd, | |
| 2484 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2485 EXPECT_EQ(0U, process_->sink().message_count()); | 2425 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2486 | 2426 |
| 2487 // Mouse event should pass untouched. | 2427 // Mouse event should pass untouched. |
| 2488 SimulateMouseEvent( | 2428 SimulateMouseEvent( |
| 2489 WebInputEvent::MouseMove, 10, 10, WebInputEvent::ShiftKey, true); | 2429 WebInputEvent::MouseMove, 10, 10, WebInputEvent::ShiftKey, true); |
| 2490 EXPECT_EQ("MouseMove", GetInputMessageTypes(process_)); | 2430 EXPECT_EQ("MouseMove", GetInputMessageTypes(process_)); |
| 2491 SendInputEventACK(WebInputEvent::MouseMove, | 2431 SendInputEventACK(WebInputEvent::MouseMove, |
| 2492 INPUT_EVENT_ACK_STATE_CONSUMED); | 2432 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2493 EXPECT_EQ(0U, process_->sink().message_count()); | 2433 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2494 | 2434 |
| 2495 // Turn on emulation. | 2435 // Turn on emulation. |
| 2496 host_->OnMessageReceived( | 2436 host_->OnMessageReceived( |
| 2497 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true)); | 2437 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true)); |
| 2498 EXPECT_EQ(0U, process_->sink().message_count()); | 2438 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2499 | 2439 |
| 2500 // Another touch. | 2440 // Another touch. |
| 2501 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); | 2441 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); |
| 2502 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); | 2442 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); |
| 2503 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); | 2443 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); |
| 2504 SendInputEventACK(WebInputEvent::GestureTapDown, | |
| 2505 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2506 EXPECT_EQ(0U, process_->sink().message_count()); | 2444 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2507 | 2445 |
| 2508 // Scroll. | 2446 // Scroll. |
| 2509 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true); | 2447 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true); |
| 2510 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); | 2448 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2511 EXPECT_EQ( | 2449 EXPECT_EQ( |
| 2512 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", | 2450 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", |
| 2513 GetInputMessageTypes(process_)); | 2451 GetInputMessageTypes(process_)); |
| 2514 SendInputEventACK(WebInputEvent::GestureTapCancel, | |
| 2515 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2516 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2517 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2518 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2452 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2519 INPUT_EVENT_ACK_STATE_CONSUMED); | 2453 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2520 | 2454 |
| 2521 // Turn off emulation during a scroll. | 2455 // Turn off emulation during a scroll. |
| 2522 host_->OnMessageReceived( | 2456 host_->OnMessageReceived( |
| 2523 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false)); | 2457 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false)); |
| 2524 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); | 2458 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); |
| 2525 | 2459 |
| 2526 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_)); | 2460 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_)); |
| 2527 SendInputEventACK(WebInputEvent::GestureScrollEnd, | |
| 2528 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2529 EXPECT_EQ(0U, process_->sink().message_count()); | 2461 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2530 } | 2462 } |
| 2531 | 2463 |
| 2532 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \ | 2464 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \ |
| 2533 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \ | 2465 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \ |
| 2534 host_->SetupForInputRouterTest(); \ | 2466 host_->SetupForInputRouterTest(); \ |
| 2535 host_->INPUTMSG(); \ | 2467 host_->INPUTMSG(); \ |
| 2536 EXPECT_TRUE(host_->mock_input_router()->send_event_called_); \ | 2468 EXPECT_TRUE(host_->mock_input_router()->send_event_called_); \ |
| 2537 } | 2469 } |
| 2538 | 2470 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2741 ui::LatencyInfo()); | 2673 ui::LatencyInfo()); |
| 2742 CheckLatencyInfoComponentInMessage( | 2674 CheckLatencyInfoComponentInMessage( |
| 2743 process_, GetLatencyComponentId(), WebInputEvent::MouseMove); | 2675 process_, GetLatencyComponentId(), WebInputEvent::MouseMove); |
| 2744 SendInputEventACK(WebInputEvent::MouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); | 2676 SendInputEventACK(WebInputEvent::MouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2745 | 2677 |
| 2746 // Tests RWHI::ForwardGestureEvent(). | 2678 // Tests RWHI::ForwardGestureEvent(). |
| 2747 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2679 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2748 WebGestureEvent::Touchscreen); | 2680 WebGestureEvent::Touchscreen); |
| 2749 CheckLatencyInfoComponentInMessage( | 2681 CheckLatencyInfoComponentInMessage( |
| 2750 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollBegin); | 2682 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollBegin); |
| 2751 SendInputEventACK(WebInputEvent::GestureScrollBegin, | |
| 2752 INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 2753 | 2683 |
| 2754 // Tests RWHI::ForwardGestureEventWithLatencyInfo(). | 2684 // Tests RWHI::ForwardGestureEventWithLatencyInfo(). |
| 2755 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, | 2685 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, |
| 2756 WebGestureEvent::Touchscreen, | 2686 WebGestureEvent::Touchscreen, |
| 2757 ui::LatencyInfo()); | 2687 ui::LatencyInfo()); |
| 2758 CheckLatencyInfoComponentInMessage( | 2688 CheckLatencyInfoComponentInMessage( |
| 2759 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); | 2689 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); |
| 2760 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2690 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2761 INPUT_EVENT_ACK_STATE_CONSUMED); | 2691 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2762 | 2692 |
| 2763 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 2693 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
| 2764 PressTouchPoint(0, 1); | 2694 PressTouchPoint(0, 1); |
| 2765 SendTouchEvent(); | 2695 SendTouchEvent(); |
| 2766 CheckLatencyInfoComponentInMessage( | 2696 CheckLatencyInfoComponentInMessage( |
| 2767 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 2697 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
| 2768 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 2698 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2769 } | 2699 } |
| 2770 | 2700 |
| 2771 } // namespace content | 2701 } // namespace content |
| OLD | NEW |