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