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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/renderer_host/backing_store.h" | 10 #include "content/browser/renderer_host/backing_store.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 } | 171 } |
172 | 172 |
173 bool FlingInProgress() { | 173 bool FlingInProgress() { |
174 return gesture_event_filter_->fling_in_progress_; | 174 return gesture_event_filter_->fling_in_progress_; |
175 } | 175 } |
176 | 176 |
177 bool WillIgnoreNextACK() { | 177 bool WillIgnoreNextACK() { |
178 return gesture_event_filter_->ignore_next_ack_; | 178 return gesture_event_filter_->ignore_next_ack_; |
179 } | 179 } |
180 | 180 |
181 TapSuppressionState TapSuppressionControllerState() { | 181 TapSuppressionState TouchpadTapSuppressionControllerState() { |
182 TouchpadTapSuppressionController* tsc = | 182 TouchpadTapSuppressionController* tsc = |
183 gesture_event_filter_->tap_suppression_controller_.get(); | 183 gesture_event_filter_->touchpad_tap_suppression_controller_.get(); |
184 return static_cast<TapSuppressionState>(tsc->controller_->state_); | 184 return static_cast<TapSuppressionState>(tsc->controller_->state_); |
185 } | 185 } |
186 | 186 |
187 void SetupForOverscrollControllerTest() { | 187 void SetupForOverscrollControllerTest() { |
188 SetOverscrollControllerEnabled(true); | 188 SetOverscrollControllerEnabled(true); |
189 overscroll_delegate_.reset(new TestOverscrollDelegate); | 189 overscroll_delegate_.reset(new TestOverscrollDelegate); |
190 overscroll_controller_->set_delegate(overscroll_delegate_.get()); | 190 overscroll_controller_->set_delegate(overscroll_delegate_.get()); |
191 } | 191 } |
192 | 192 |
193 void set_maximum_tap_gap_time_ms(int delay_ms) { | 193 void set_maximum_tap_gap_time_ms(int delay_ms) { |
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1869 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseFast) { | 1869 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseFast) { |
1870 process_->sink().ClearMessages(); | 1870 process_->sink().ClearMessages(); |
1871 | 1871 |
1872 // Send GestureFlingStart. | 1872 // Send GestureFlingStart. |
1873 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 1873 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
1874 EXPECT_EQ(1U, process_->sink().message_count()); | 1874 EXPECT_EQ(1U, process_->sink().message_count()); |
1875 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1875 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1876 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 1876 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
1877 host_->GestureEventLastQueueEvent().type); | 1877 host_->GestureEventLastQueueEvent().type); |
1878 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 1878 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
1879 host_->TapSuppressionControllerState()); | 1879 host_->TouchpadTapSuppressionControllerState()); |
rjkroege
2013/03/07 22:56:21
a helper method on MockRenderWidgetHost might have
mohsen
2013/03/08 00:14:58
These unit tests are going to be changed soon (bec
| |
1880 EXPECT_TRUE(host_->FlingInProgress()); | 1880 EXPECT_TRUE(host_->FlingInProgress()); |
1881 | 1881 |
1882 // Send GestureFlingStart Ack. | 1882 // Send GestureFlingStart Ack. |
1883 SendInputEventACK(WebInputEvent::GestureFlingStart, | 1883 SendInputEventACK(WebInputEvent::GestureFlingStart, |
1884 INPUT_EVENT_ACK_STATE_CONSUMED); | 1884 INPUT_EVENT_ACK_STATE_CONSUMED); |
1885 MessageLoop::current()->RunUntilIdle(); | 1885 MessageLoop::current()->RunUntilIdle(); |
1886 EXPECT_EQ(1U, process_->sink().message_count()); | 1886 EXPECT_EQ(1U, process_->sink().message_count()); |
1887 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1887 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1888 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 1888 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
1889 host_->TapSuppressionControllerState()); | 1889 host_->TouchpadTapSuppressionControllerState()); |
1890 EXPECT_TRUE(host_->FlingInProgress()); | 1890 EXPECT_TRUE(host_->FlingInProgress()); |
1891 | 1891 |
1892 // Send GestureFlingCancel. | 1892 // Send GestureFlingCancel. |
1893 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 1893 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
1894 WebGestureEvent::Touchpad); | 1894 WebGestureEvent::Touchpad); |
1895 EXPECT_EQ(2U, process_->sink().message_count()); | 1895 EXPECT_EQ(2U, process_->sink().message_count()); |
1896 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1896 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1897 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 1897 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
1898 host_->GestureEventLastQueueEvent().type); | 1898 host_->GestureEventLastQueueEvent().type); |
1899 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 1899 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
1900 host_->TapSuppressionControllerState()); | 1900 host_->TouchpadTapSuppressionControllerState()); |
1901 EXPECT_FALSE(host_->FlingInProgress()); | 1901 EXPECT_FALSE(host_->FlingInProgress()); |
1902 | 1902 |
1903 // Send GestureFlingCancel Ack. | 1903 // Send GestureFlingCancel Ack. |
1904 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 1904 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
1905 INPUT_EVENT_ACK_STATE_CONSUMED); | 1905 INPUT_EVENT_ACK_STATE_CONSUMED); |
1906 MessageLoop::current()->RunUntilIdle(); | 1906 MessageLoop::current()->RunUntilIdle(); |
1907 EXPECT_EQ(2U, process_->sink().message_count()); | 1907 EXPECT_EQ(2U, process_->sink().message_count()); |
1908 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1908 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1909 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | 1909 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
1910 host_->TapSuppressionControllerState()); | 1910 host_->TouchpadTapSuppressionControllerState()); |
1911 EXPECT_FALSE(host_->FlingInProgress()); | 1911 EXPECT_FALSE(host_->FlingInProgress()); |
1912 | 1912 |
1913 // Send MouseDown. This MouseDown should be suppressed. | 1913 // Send MouseDown. This MouseDown should be suppressed. |
1914 SimulateMouseEvent(WebInputEvent::MouseDown); | 1914 SimulateMouseEvent(WebInputEvent::MouseDown); |
1915 EXPECT_EQ(2U, process_->sink().message_count()); | 1915 EXPECT_EQ(2U, process_->sink().message_count()); |
1916 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1916 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1917 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 1917 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
1918 host_->TapSuppressionControllerState()); | 1918 host_->TouchpadTapSuppressionControllerState()); |
1919 EXPECT_FALSE(host_->FlingInProgress()); | 1919 EXPECT_FALSE(host_->FlingInProgress()); |
1920 | 1920 |
1921 // Send MouseUp. This MouseUp should be suppressed. | 1921 // Send MouseUp. This MouseUp should be suppressed. |
1922 SimulateMouseEvent(WebInputEvent::MouseUp); | 1922 SimulateMouseEvent(WebInputEvent::MouseUp); |
1923 EXPECT_EQ(2U, process_->sink().message_count()); | 1923 EXPECT_EQ(2U, process_->sink().message_count()); |
1924 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1924 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1925 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 1925 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
1926 host_->TapSuppressionControllerState()); | 1926 host_->TouchpadTapSuppressionControllerState()); |
1927 EXPECT_FALSE(host_->FlingInProgress()); | 1927 EXPECT_FALSE(host_->FlingInProgress()); |
1928 } | 1928 } |
1929 | 1929 |
1930 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes | 1930 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes |
1931 // before MouseDown, but there is a small delay between MouseDown and MouseUp. | 1931 // before MouseDown, but there is a small delay between MouseDown and MouseUp. |
1932 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseInsufficientlyLateMouseUp) { | 1932 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseInsufficientlyLateMouseUp) { |
1933 process_->sink().ClearMessages(); | 1933 process_->sink().ClearMessages(); |
1934 | 1934 |
1935 // Send GestureFlingStart. | 1935 // Send GestureFlingStart. |
1936 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 1936 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
1937 EXPECT_EQ(1U, process_->sink().message_count()); | 1937 EXPECT_EQ(1U, process_->sink().message_count()); |
1938 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1938 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1939 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 1939 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
1940 host_->GestureEventLastQueueEvent().type); | 1940 host_->GestureEventLastQueueEvent().type); |
1941 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 1941 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
1942 host_->TapSuppressionControllerState()); | 1942 host_->TouchpadTapSuppressionControllerState()); |
1943 EXPECT_TRUE(host_->FlingInProgress()); | 1943 EXPECT_TRUE(host_->FlingInProgress()); |
1944 | 1944 |
1945 // Send GestureFlingStart Ack. | 1945 // Send GestureFlingStart Ack. |
1946 SendInputEventACK(WebInputEvent::GestureFlingStart, | 1946 SendInputEventACK(WebInputEvent::GestureFlingStart, |
1947 INPUT_EVENT_ACK_STATE_CONSUMED); | 1947 INPUT_EVENT_ACK_STATE_CONSUMED); |
1948 MessageLoop::current()->RunUntilIdle(); | 1948 MessageLoop::current()->RunUntilIdle(); |
1949 EXPECT_EQ(1U, process_->sink().message_count()); | 1949 EXPECT_EQ(1U, process_->sink().message_count()); |
1950 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1950 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1951 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 1951 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
1952 host_->TapSuppressionControllerState()); | 1952 host_->TouchpadTapSuppressionControllerState()); |
1953 EXPECT_TRUE(host_->FlingInProgress()); | 1953 EXPECT_TRUE(host_->FlingInProgress()); |
1954 | 1954 |
1955 // Send GestureFlingCancel. | 1955 // Send GestureFlingCancel. |
1956 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 1956 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
1957 WebGestureEvent::Touchpad); | 1957 WebGestureEvent::Touchpad); |
1958 EXPECT_EQ(2U, process_->sink().message_count()); | 1958 EXPECT_EQ(2U, process_->sink().message_count()); |
1959 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1959 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1960 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 1960 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
1961 host_->GestureEventLastQueueEvent().type); | 1961 host_->GestureEventLastQueueEvent().type); |
1962 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 1962 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
1963 host_->TapSuppressionControllerState()); | 1963 host_->TouchpadTapSuppressionControllerState()); |
1964 EXPECT_FALSE(host_->FlingInProgress()); | 1964 EXPECT_FALSE(host_->FlingInProgress()); |
1965 | 1965 |
1966 // Send GestureFlingCancel Ack. | 1966 // Send GestureFlingCancel Ack. |
1967 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 1967 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
1968 INPUT_EVENT_ACK_STATE_CONSUMED); | 1968 INPUT_EVENT_ACK_STATE_CONSUMED); |
1969 MessageLoop::current()->RunUntilIdle(); | 1969 MessageLoop::current()->RunUntilIdle(); |
1970 EXPECT_EQ(2U, process_->sink().message_count()); | 1970 EXPECT_EQ(2U, process_->sink().message_count()); |
1971 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1971 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1972 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | 1972 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
1973 host_->TapSuppressionControllerState()); | 1973 host_->TouchpadTapSuppressionControllerState()); |
1974 EXPECT_FALSE(host_->FlingInProgress()); | 1974 EXPECT_FALSE(host_->FlingInProgress()); |
1975 | 1975 |
1976 // Send MouseDown. This MouseDown should be suppressed. | 1976 // Send MouseDown. This MouseDown should be suppressed. |
1977 SimulateMouseEvent(WebInputEvent::MouseDown); | 1977 SimulateMouseEvent(WebInputEvent::MouseDown); |
1978 EXPECT_EQ(2U, process_->sink().message_count()); | 1978 EXPECT_EQ(2U, process_->sink().message_count()); |
1979 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1979 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1980 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 1980 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
1981 host_->TapSuppressionControllerState()); | 1981 host_->TouchpadTapSuppressionControllerState()); |
1982 EXPECT_FALSE(host_->FlingInProgress()); | 1982 EXPECT_FALSE(host_->FlingInProgress()); |
1983 | 1983 |
1984 // Wait less than allowed delay between MouseDown and MouseUp, so they are | 1984 // Wait less than allowed delay between MouseDown and MouseUp, so they are |
1985 // still considered a tap. | 1985 // still considered a tap. |
1986 // TODO(mohsen): The amounts used for delays are too much and will slow down | 1986 // TODO(mohsen): The amounts used for delays are too much and will slow down |
1987 // the tests. A better way is to reduce the allowed delays in TSC before each | 1987 // the tests. A better way is to reduce the allowed delays in TSC before each |
1988 // test. So, they should be made accessible and configurable. | 1988 // test. So, they should be made accessible and configurable. |
1989 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1989 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1990 MessageLoop::QuitClosure(), | 1990 MessageLoop::QuitClosure(), |
1991 TimeDelta::FromMilliseconds(100)); | 1991 TimeDelta::FromMilliseconds(100)); |
1992 MessageLoop::current()->Run(); | 1992 MessageLoop::current()->Run(); |
1993 EXPECT_EQ(2U, process_->sink().message_count()); | 1993 EXPECT_EQ(2U, process_->sink().message_count()); |
1994 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1994 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1995 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 1995 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
1996 host_->TapSuppressionControllerState()); | 1996 host_->TouchpadTapSuppressionControllerState()); |
1997 EXPECT_FALSE(host_->FlingInProgress()); | 1997 EXPECT_FALSE(host_->FlingInProgress()); |
1998 | 1998 |
1999 // Send MouseUp. This MouseUp should be suppressed. | 1999 // Send MouseUp. This MouseUp should be suppressed. |
2000 SimulateMouseEvent(WebInputEvent::MouseUp); | 2000 SimulateMouseEvent(WebInputEvent::MouseUp); |
2001 EXPECT_EQ(2U, process_->sink().message_count()); | 2001 EXPECT_EQ(2U, process_->sink().message_count()); |
2002 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2002 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2003 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2003 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2004 host_->TapSuppressionControllerState()); | 2004 host_->TouchpadTapSuppressionControllerState()); |
2005 EXPECT_FALSE(host_->FlingInProgress()); | 2005 EXPECT_FALSE(host_->FlingInProgress()); |
2006 } | 2006 } |
2007 | 2007 |
2008 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes | 2008 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes |
2009 // before MouseDown, but there is a long delay between MouseDown and MouseUp. | 2009 // before MouseDown, but there is a long delay between MouseDown and MouseUp. |
2010 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseSufficientlyLateMouseUp) { | 2010 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseSufficientlyLateMouseUp) { |
2011 process_->sink().ClearMessages(); | 2011 process_->sink().ClearMessages(); |
2012 | 2012 |
2013 // Send GestureFlingStart. | 2013 // Send GestureFlingStart. |
2014 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 2014 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
2015 EXPECT_EQ(1U, process_->sink().message_count()); | 2015 EXPECT_EQ(1U, process_->sink().message_count()); |
2016 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2016 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2017 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 2017 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
2018 host_->GestureEventLastQueueEvent().type); | 2018 host_->GestureEventLastQueueEvent().type); |
2019 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2019 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2020 host_->TapSuppressionControllerState()); | 2020 host_->TouchpadTapSuppressionControllerState()); |
2021 EXPECT_TRUE(host_->FlingInProgress()); | 2021 EXPECT_TRUE(host_->FlingInProgress()); |
2022 | 2022 |
2023 // Send GestureFlingStart Ack. | 2023 // Send GestureFlingStart Ack. |
2024 SendInputEventACK(WebInputEvent::GestureFlingStart, | 2024 SendInputEventACK(WebInputEvent::GestureFlingStart, |
2025 INPUT_EVENT_ACK_STATE_CONSUMED); | 2025 INPUT_EVENT_ACK_STATE_CONSUMED); |
2026 MessageLoop::current()->RunUntilIdle(); | 2026 MessageLoop::current()->RunUntilIdle(); |
2027 EXPECT_EQ(1U, process_->sink().message_count()); | 2027 EXPECT_EQ(1U, process_->sink().message_count()); |
2028 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2028 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2029 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2029 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2030 host_->TapSuppressionControllerState()); | 2030 host_->TouchpadTapSuppressionControllerState()); |
2031 EXPECT_TRUE(host_->FlingInProgress()); | 2031 EXPECT_TRUE(host_->FlingInProgress()); |
2032 | 2032 |
2033 // Send GestureFlingCancel. | 2033 // Send GestureFlingCancel. |
2034 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 2034 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
2035 WebGestureEvent::Touchpad); | 2035 WebGestureEvent::Touchpad); |
2036 EXPECT_EQ(2U, process_->sink().message_count()); | 2036 EXPECT_EQ(2U, process_->sink().message_count()); |
2037 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2037 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2038 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2038 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2039 host_->GestureEventLastQueueEvent().type); | 2039 host_->GestureEventLastQueueEvent().type); |
2040 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 2040 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
2041 host_->TapSuppressionControllerState()); | 2041 host_->TouchpadTapSuppressionControllerState()); |
2042 EXPECT_FALSE(host_->FlingInProgress()); | 2042 EXPECT_FALSE(host_->FlingInProgress()); |
2043 | 2043 |
2044 // Send processed GestureFlingCancel Ack. | 2044 // Send processed GestureFlingCancel Ack. |
2045 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 2045 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
2046 INPUT_EVENT_ACK_STATE_CONSUMED); | 2046 INPUT_EVENT_ACK_STATE_CONSUMED); |
2047 MessageLoop::current()->RunUntilIdle(); | 2047 MessageLoop::current()->RunUntilIdle(); |
2048 EXPECT_EQ(2U, process_->sink().message_count()); | 2048 EXPECT_EQ(2U, process_->sink().message_count()); |
2049 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2049 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2050 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | 2050 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
2051 host_->TapSuppressionControllerState()); | 2051 host_->TouchpadTapSuppressionControllerState()); |
2052 EXPECT_FALSE(host_->FlingInProgress()); | 2052 EXPECT_FALSE(host_->FlingInProgress()); |
2053 | 2053 |
2054 // Send MouseDown. This MouseDown should be suppressed, for now. | 2054 // Send MouseDown. This MouseDown should be suppressed, for now. |
2055 SimulateMouseEvent(WebInputEvent::MouseDown); | 2055 SimulateMouseEvent(WebInputEvent::MouseDown); |
2056 EXPECT_EQ(2U, process_->sink().message_count()); | 2056 EXPECT_EQ(2U, process_->sink().message_count()); |
2057 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2057 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2058 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2058 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2059 host_->TapSuppressionControllerState()); | 2059 host_->TouchpadTapSuppressionControllerState()); |
2060 EXPECT_FALSE(host_->FlingInProgress()); | 2060 EXPECT_FALSE(host_->FlingInProgress()); |
2061 | 2061 |
2062 // Wait more than allowed delay between MosueDown and MouseUp, so they are | 2062 // Wait more than allowed delay between MosueDown and MouseUp, so they are |
2063 // not considered a tap. This should release the previously suppressed | 2063 // not considered a tap. This should release the previously suppressed |
2064 // MouseDown. | 2064 // MouseDown. |
2065 // TODO(mohsen): The amounts used for delays are too much and will slow down | 2065 // TODO(mohsen): The amounts used for delays are too much and will slow down |
2066 // the tests. A better way is to reduce the allowed delays in TSC before each | 2066 // the tests. A better way is to reduce the allowed delays in TSC before each |
2067 // test. So, they should be made configurable and accessible here. | 2067 // test. So, they should be made configurable and accessible here. |
2068 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 2068 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
2069 MessageLoop::QuitClosure(), | 2069 MessageLoop::QuitClosure(), |
2070 TimeDelta::FromMilliseconds(300)); | 2070 TimeDelta::FromMilliseconds(300)); |
2071 MessageLoop::current()->Run(); | 2071 MessageLoop::current()->Run(); |
2072 EXPECT_EQ(3U, process_->sink().message_count()); | 2072 EXPECT_EQ(3U, process_->sink().message_count()); |
2073 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2073 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2074 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2074 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2075 host_->TapSuppressionControllerState()); | 2075 host_->TouchpadTapSuppressionControllerState()); |
2076 EXPECT_FALSE(host_->FlingInProgress()); | 2076 EXPECT_FALSE(host_->FlingInProgress()); |
2077 | 2077 |
2078 // Send MouseUp. This MouseUp should not be suppressed. | 2078 // Send MouseUp. This MouseUp should not be suppressed. |
2079 SimulateMouseEvent(WebInputEvent::MouseUp); | 2079 SimulateMouseEvent(WebInputEvent::MouseUp); |
2080 EXPECT_EQ(4U, process_->sink().message_count()); | 2080 EXPECT_EQ(4U, process_->sink().message_count()); |
2081 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2081 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2082 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2082 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2083 host_->TapSuppressionControllerState()); | 2083 host_->TouchpadTapSuppressionControllerState()); |
2084 EXPECT_FALSE(host_->FlingInProgress()); | 2084 EXPECT_FALSE(host_->FlingInProgress()); |
2085 } | 2085 } |
2086 | 2086 |
2087 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes | 2087 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes |
2088 // before MouseDown, but there is a small delay between the Ack and MouseDown. | 2088 // before MouseDown, but there is a small delay between the Ack and MouseDown. |
2089 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseInsufficientlyLateMouseDown) { | 2089 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseInsufficientlyLateMouseDown) { |
2090 process_->sink().ClearMessages(); | 2090 process_->sink().ClearMessages(); |
2091 | 2091 |
2092 // Send GestureFlingStart. | 2092 // Send GestureFlingStart. |
2093 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 2093 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
2094 EXPECT_EQ(1U, process_->sink().message_count()); | 2094 EXPECT_EQ(1U, process_->sink().message_count()); |
2095 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2095 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2096 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 2096 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
2097 host_->GestureEventLastQueueEvent().type); | 2097 host_->GestureEventLastQueueEvent().type); |
2098 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2098 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2099 host_->TapSuppressionControllerState()); | 2099 host_->TouchpadTapSuppressionControllerState()); |
2100 EXPECT_TRUE(host_->FlingInProgress()); | 2100 EXPECT_TRUE(host_->FlingInProgress()); |
2101 | 2101 |
2102 // Send GestureFlingStart Ack. | 2102 // Send GestureFlingStart Ack. |
2103 SendInputEventACK(WebInputEvent::GestureFlingStart, | 2103 SendInputEventACK(WebInputEvent::GestureFlingStart, |
2104 INPUT_EVENT_ACK_STATE_CONSUMED); | 2104 INPUT_EVENT_ACK_STATE_CONSUMED); |
2105 MessageLoop::current()->RunUntilIdle(); | 2105 MessageLoop::current()->RunUntilIdle(); |
2106 EXPECT_EQ(1U, process_->sink().message_count()); | 2106 EXPECT_EQ(1U, process_->sink().message_count()); |
2107 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2107 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2108 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2108 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2109 host_->TapSuppressionControllerState()); | 2109 host_->TouchpadTapSuppressionControllerState()); |
2110 EXPECT_TRUE(host_->FlingInProgress()); | 2110 EXPECT_TRUE(host_->FlingInProgress()); |
2111 | 2111 |
2112 // Send GestureFlingCancel. | 2112 // Send GestureFlingCancel. |
2113 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 2113 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
2114 WebGestureEvent::Touchpad); | 2114 WebGestureEvent::Touchpad); |
2115 EXPECT_EQ(2U, process_->sink().message_count()); | 2115 EXPECT_EQ(2U, process_->sink().message_count()); |
2116 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2116 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2117 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2117 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2118 host_->GestureEventLastQueueEvent().type); | 2118 host_->GestureEventLastQueueEvent().type); |
2119 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 2119 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
2120 host_->TapSuppressionControllerState()); | 2120 host_->TouchpadTapSuppressionControllerState()); |
2121 EXPECT_FALSE(host_->FlingInProgress()); | 2121 EXPECT_FALSE(host_->FlingInProgress()); |
2122 | 2122 |
2123 // Send GestureFlingCancel Ack. | 2123 // Send GestureFlingCancel Ack. |
2124 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 2124 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
2125 INPUT_EVENT_ACK_STATE_CONSUMED); | 2125 INPUT_EVENT_ACK_STATE_CONSUMED); |
2126 MessageLoop::current()->RunUntilIdle(); | 2126 MessageLoop::current()->RunUntilIdle(); |
2127 EXPECT_EQ(2U, process_->sink().message_count()); | 2127 EXPECT_EQ(2U, process_->sink().message_count()); |
2128 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2128 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2129 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | 2129 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
2130 host_->TapSuppressionControllerState()); | 2130 host_->TouchpadTapSuppressionControllerState()); |
2131 EXPECT_FALSE(host_->FlingInProgress()); | 2131 EXPECT_FALSE(host_->FlingInProgress()); |
2132 | 2132 |
2133 // Wait less than allowed delay between GestureFlingCancel and MouseDown, | 2133 // Wait less than allowed delay between GestureFlingCancel and MouseDown, |
2134 // so the MouseDown is still considered associated with the | 2134 // so the MouseDown is still considered associated with the |
2135 // GestureFlingCancel. | 2135 // GestureFlingCancel. |
2136 // TODO(mohsen): The amounts used for delays are too much and will slow down | 2136 // TODO(mohsen): The amounts used for delays are too much and will slow down |
2137 // the tests. A better way is to reduce the allowed delays in TSC before each | 2137 // the tests. A better way is to reduce the allowed delays in TSC before each |
2138 // test. So, they should be made configurable and accessible here. | 2138 // test. So, they should be made configurable and accessible here. |
2139 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 2139 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
2140 MessageLoop::QuitClosure(), | 2140 MessageLoop::QuitClosure(), |
2141 TimeDelta::FromMilliseconds(300)); | 2141 TimeDelta::FromMilliseconds(300)); |
2142 MessageLoop::current()->Run(); | 2142 MessageLoop::current()->Run(); |
2143 EXPECT_EQ(2U, process_->sink().message_count()); | 2143 EXPECT_EQ(2U, process_->sink().message_count()); |
2144 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2144 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2145 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | 2145 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
2146 host_->TapSuppressionControllerState()); | 2146 host_->TouchpadTapSuppressionControllerState()); |
2147 EXPECT_FALSE(host_->FlingInProgress()); | 2147 EXPECT_FALSE(host_->FlingInProgress()); |
2148 | 2148 |
2149 // Send MouseDown. This MouseDown should be suppressed. | 2149 // Send MouseDown. This MouseDown should be suppressed. |
2150 SimulateMouseEvent(WebInputEvent::MouseDown); | 2150 SimulateMouseEvent(WebInputEvent::MouseDown); |
2151 EXPECT_EQ(2U, process_->sink().message_count()); | 2151 EXPECT_EQ(2U, process_->sink().message_count()); |
2152 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2152 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2153 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2153 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2154 host_->TapSuppressionControllerState()); | 2154 host_->TouchpadTapSuppressionControllerState()); |
2155 EXPECT_FALSE(host_->FlingInProgress()); | 2155 EXPECT_FALSE(host_->FlingInProgress()); |
2156 | 2156 |
2157 // Send MouseUp. This MouseUp should be suppressed. | 2157 // Send MouseUp. This MouseUp should be suppressed. |
2158 SimulateMouseEvent(WebInputEvent::MouseUp); | 2158 SimulateMouseEvent(WebInputEvent::MouseUp); |
2159 EXPECT_EQ(2U, process_->sink().message_count()); | 2159 EXPECT_EQ(2U, process_->sink().message_count()); |
2160 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2160 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2161 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2161 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2162 host_->TapSuppressionControllerState()); | 2162 host_->TouchpadTapSuppressionControllerState()); |
2163 EXPECT_FALSE(host_->FlingInProgress()); | 2163 EXPECT_FALSE(host_->FlingInProgress()); |
2164 } | 2164 } |
2165 | 2165 |
2166 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes | 2166 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes |
2167 // before MouseDown, but there is a long delay between the Ack and MouseDown. | 2167 // before MouseDown, but there is a long delay between the Ack and MouseDown. |
2168 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseSufficientlyLateMouseDown) { | 2168 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseSufficientlyLateMouseDown) { |
2169 process_->sink().ClearMessages(); | 2169 process_->sink().ClearMessages(); |
2170 | 2170 |
2171 // Send GestureFlingStart. | 2171 // Send GestureFlingStart. |
2172 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 2172 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
2173 EXPECT_EQ(1U, process_->sink().message_count()); | 2173 EXPECT_EQ(1U, process_->sink().message_count()); |
2174 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2174 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2175 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 2175 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
2176 host_->GestureEventLastQueueEvent().type); | 2176 host_->GestureEventLastQueueEvent().type); |
2177 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2177 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2178 host_->TapSuppressionControllerState()); | 2178 host_->TouchpadTapSuppressionControllerState()); |
2179 EXPECT_TRUE(host_->FlingInProgress()); | 2179 EXPECT_TRUE(host_->FlingInProgress()); |
2180 | 2180 |
2181 // Send GestureFlingStart Ack. | 2181 // Send GestureFlingStart Ack. |
2182 SendInputEventACK(WebInputEvent::GestureFlingStart, | 2182 SendInputEventACK(WebInputEvent::GestureFlingStart, |
2183 INPUT_EVENT_ACK_STATE_CONSUMED); | 2183 INPUT_EVENT_ACK_STATE_CONSUMED); |
2184 MessageLoop::current()->RunUntilIdle(); | 2184 MessageLoop::current()->RunUntilIdle(); |
2185 EXPECT_EQ(1U, process_->sink().message_count()); | 2185 EXPECT_EQ(1U, process_->sink().message_count()); |
2186 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2186 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2187 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2187 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2188 host_->TapSuppressionControllerState()); | 2188 host_->TouchpadTapSuppressionControllerState()); |
2189 EXPECT_TRUE(host_->FlingInProgress()); | 2189 EXPECT_TRUE(host_->FlingInProgress()); |
2190 | 2190 |
2191 // Send GestureFlingCancel. | 2191 // Send GestureFlingCancel. |
2192 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 2192 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
2193 WebGestureEvent::Touchpad); | 2193 WebGestureEvent::Touchpad); |
2194 EXPECT_EQ(2U, process_->sink().message_count()); | 2194 EXPECT_EQ(2U, process_->sink().message_count()); |
2195 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2195 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2196 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2196 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2197 host_->GestureEventLastQueueEvent().type); | 2197 host_->GestureEventLastQueueEvent().type); |
2198 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 2198 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
2199 host_->TapSuppressionControllerState()); | 2199 host_->TouchpadTapSuppressionControllerState()); |
2200 EXPECT_FALSE(host_->FlingInProgress()); | 2200 EXPECT_FALSE(host_->FlingInProgress()); |
2201 | 2201 |
2202 // Send GestureFlingCancel Ack. | 2202 // Send GestureFlingCancel Ack. |
2203 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 2203 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
2204 INPUT_EVENT_ACK_STATE_CONSUMED); | 2204 INPUT_EVENT_ACK_STATE_CONSUMED); |
2205 MessageLoop::current()->RunUntilIdle(); | 2205 MessageLoop::current()->RunUntilIdle(); |
2206 EXPECT_EQ(2U, process_->sink().message_count()); | 2206 EXPECT_EQ(2U, process_->sink().message_count()); |
2207 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2207 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2208 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | 2208 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
2209 host_->TapSuppressionControllerState()); | 2209 host_->TouchpadTapSuppressionControllerState()); |
2210 EXPECT_FALSE(host_->FlingInProgress()); | 2210 EXPECT_FALSE(host_->FlingInProgress()); |
2211 | 2211 |
2212 // Wait more than allowed delay between GestureFlingCancel and MouseDown, | 2212 // Wait more than allowed delay between GestureFlingCancel and MouseDown, |
2213 // so the MouseDown is not considered associated with the GestureFlingCancel. | 2213 // so the MouseDown is not considered associated with the GestureFlingCancel. |
2214 // TODO(mohsen): The amounts used for delays are too much and will slow down | 2214 // TODO(mohsen): The amounts used for delays are too much and will slow down |
2215 // the tests. A better way is to reduce the allowed delays in TSC before each | 2215 // the tests. A better way is to reduce the allowed delays in TSC before each |
2216 // test. So, they should be made configurable and accessible here. | 2216 // test. So, they should be made configurable and accessible here. |
2217 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 2217 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
2218 MessageLoop::QuitClosure(), | 2218 MessageLoop::QuitClosure(), |
2219 TimeDelta::FromMilliseconds(500)); | 2219 TimeDelta::FromMilliseconds(500)); |
2220 MessageLoop::current()->Run(); | 2220 MessageLoop::current()->Run(); |
2221 EXPECT_EQ(2U, process_->sink().message_count()); | 2221 EXPECT_EQ(2U, process_->sink().message_count()); |
2222 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2222 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2223 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | 2223 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
2224 host_->TapSuppressionControllerState()); | 2224 host_->TouchpadTapSuppressionControllerState()); |
2225 EXPECT_FALSE(host_->FlingInProgress()); | 2225 EXPECT_FALSE(host_->FlingInProgress()); |
2226 | 2226 |
2227 // Send MouseDown. This MouseDown should not be suppressed. | 2227 // Send MouseDown. This MouseDown should not be suppressed. |
2228 SimulateMouseEvent(WebInputEvent::MouseDown); | 2228 SimulateMouseEvent(WebInputEvent::MouseDown); |
2229 EXPECT_EQ(3U, process_->sink().message_count()); | 2229 EXPECT_EQ(3U, process_->sink().message_count()); |
2230 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2230 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2231 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2231 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2232 host_->TapSuppressionControllerState()); | 2232 host_->TouchpadTapSuppressionControllerState()); |
2233 EXPECT_FALSE(host_->FlingInProgress()); | 2233 EXPECT_FALSE(host_->FlingInProgress()); |
2234 | 2234 |
2235 // Send MouseUp. This MouseUp should not be suppressed. | 2235 // Send MouseUp. This MouseUp should not be suppressed. |
2236 SimulateMouseEvent(WebInputEvent::MouseUp); | 2236 SimulateMouseEvent(WebInputEvent::MouseUp); |
2237 EXPECT_EQ(4U, process_->sink().message_count()); | 2237 EXPECT_EQ(4U, process_->sink().message_count()); |
2238 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2238 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2239 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2239 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2240 host_->TapSuppressionControllerState()); | 2240 host_->TouchpadTapSuppressionControllerState()); |
2241 EXPECT_FALSE(host_->FlingInProgress()); | 2241 EXPECT_FALSE(host_->FlingInProgress()); |
2242 } | 2242 } |
2243 | 2243 |
2244 // Test TouchpadTapSuppressionController for when unprocessed GestureFlingCancel | 2244 // Test TouchpadTapSuppressionController for when unprocessed GestureFlingCancel |
2245 // Ack comes after MouseDown and everything happens without any delay. | 2245 // Ack comes after MouseDown and everything happens without any delay. |
2246 TEST_F(RenderWidgetHostTest, GFCAckUnprocessedAfterMouseFast) { | 2246 TEST_F(RenderWidgetHostTest, GFCAckUnprocessedAfterMouseFast) { |
2247 process_->sink().ClearMessages(); | 2247 process_->sink().ClearMessages(); |
2248 | 2248 |
2249 // Send GestureFlingStart. | 2249 // Send GestureFlingStart. |
2250 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 2250 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
2251 EXPECT_EQ(1U, process_->sink().message_count()); | 2251 EXPECT_EQ(1U, process_->sink().message_count()); |
2252 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2252 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2253 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 2253 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
2254 host_->GestureEventLastQueueEvent().type); | 2254 host_->GestureEventLastQueueEvent().type); |
2255 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2255 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2256 host_->TapSuppressionControllerState()); | 2256 host_->TouchpadTapSuppressionControllerState()); |
2257 EXPECT_TRUE(host_->FlingInProgress()); | 2257 EXPECT_TRUE(host_->FlingInProgress()); |
2258 | 2258 |
2259 // Send GestureFlingStart Ack. | 2259 // Send GestureFlingStart Ack. |
2260 SendInputEventACK(WebInputEvent::GestureFlingStart, | 2260 SendInputEventACK(WebInputEvent::GestureFlingStart, |
2261 INPUT_EVENT_ACK_STATE_CONSUMED); | 2261 INPUT_EVENT_ACK_STATE_CONSUMED); |
2262 MessageLoop::current()->RunUntilIdle(); | 2262 MessageLoop::current()->RunUntilIdle(); |
2263 EXPECT_EQ(1U, process_->sink().message_count()); | 2263 EXPECT_EQ(1U, process_->sink().message_count()); |
2264 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2264 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2265 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2265 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2266 host_->TapSuppressionControllerState()); | 2266 host_->TouchpadTapSuppressionControllerState()); |
2267 EXPECT_TRUE(host_->FlingInProgress()); | 2267 EXPECT_TRUE(host_->FlingInProgress()); |
2268 | 2268 |
2269 // Send GestureFlingCancel. | 2269 // Send GestureFlingCancel. |
2270 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 2270 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
2271 WebGestureEvent::Touchpad); | 2271 WebGestureEvent::Touchpad); |
2272 EXPECT_EQ(2U, process_->sink().message_count()); | 2272 EXPECT_EQ(2U, process_->sink().message_count()); |
2273 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2273 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2274 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2274 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2275 host_->GestureEventLastQueueEvent().type); | 2275 host_->GestureEventLastQueueEvent().type); |
2276 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 2276 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
2277 host_->TapSuppressionControllerState()); | 2277 host_->TouchpadTapSuppressionControllerState()); |
2278 EXPECT_FALSE(host_->FlingInProgress()); | 2278 EXPECT_FALSE(host_->FlingInProgress()); |
2279 | 2279 |
2280 // Send MouseDown. This MouseDown should be suppressed, for now. | 2280 // Send MouseDown. This MouseDown should be suppressed, for now. |
2281 SimulateMouseEvent(WebInputEvent::MouseDown); | 2281 SimulateMouseEvent(WebInputEvent::MouseDown); |
2282 EXPECT_EQ(2U, process_->sink().message_count()); | 2282 EXPECT_EQ(2U, process_->sink().message_count()); |
2283 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2283 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2284 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2284 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2285 host_->GestureEventLastQueueEvent().type); | 2285 host_->GestureEventLastQueueEvent().type); |
2286 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2286 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2287 host_->TapSuppressionControllerState()); | 2287 host_->TouchpadTapSuppressionControllerState()); |
2288 EXPECT_FALSE(host_->FlingInProgress()); | 2288 EXPECT_FALSE(host_->FlingInProgress()); |
2289 | 2289 |
2290 // Send unprocessed GestureFlingCancel Ack. This should release the | 2290 // Send unprocessed GestureFlingCancel Ack. This should release the |
2291 // previously suppressed MouseDown. | 2291 // previously suppressed MouseDown. |
2292 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 2292 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
2293 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2293 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2294 MessageLoop::current()->RunUntilIdle(); | 2294 MessageLoop::current()->RunUntilIdle(); |
2295 EXPECT_EQ(3U, process_->sink().message_count()); | 2295 EXPECT_EQ(3U, process_->sink().message_count()); |
2296 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2296 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2297 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2297 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2298 host_->TapSuppressionControllerState()); | 2298 host_->TouchpadTapSuppressionControllerState()); |
2299 EXPECT_FALSE(host_->FlingInProgress()); | 2299 EXPECT_FALSE(host_->FlingInProgress()); |
2300 | 2300 |
2301 // Send MouseUp. This MouseUp should not be suppressed. | 2301 // Send MouseUp. This MouseUp should not be suppressed. |
2302 SimulateMouseEvent(WebInputEvent::MouseUp); | 2302 SimulateMouseEvent(WebInputEvent::MouseUp); |
2303 EXPECT_EQ(4U, process_->sink().message_count()); | 2303 EXPECT_EQ(4U, process_->sink().message_count()); |
2304 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2304 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2305 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2305 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2306 host_->TapSuppressionControllerState()); | 2306 host_->TouchpadTapSuppressionControllerState()); |
2307 EXPECT_FALSE(host_->FlingInProgress()); | 2307 EXPECT_FALSE(host_->FlingInProgress()); |
2308 } | 2308 } |
2309 | 2309 |
2310 // Test TouchpadTapSuppressionController for when processed GestureFlingCancel | 2310 // Test TouchpadTapSuppressionController for when processed GestureFlingCancel |
2311 // Ack comes after MouseDown and everything happens without any delay. | 2311 // Ack comes after MouseDown and everything happens without any delay. |
2312 TEST_F(RenderWidgetHostTest, GFCAckProcessedAfterMouseFast) { | 2312 TEST_F(RenderWidgetHostTest, GFCAckProcessedAfterMouseFast) { |
2313 process_->sink().ClearMessages(); | 2313 process_->sink().ClearMessages(); |
2314 | 2314 |
2315 // Send GestureFlingStart. | 2315 // Send GestureFlingStart. |
2316 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 2316 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
2317 EXPECT_EQ(1U, process_->sink().message_count()); | 2317 EXPECT_EQ(1U, process_->sink().message_count()); |
2318 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2318 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2319 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 2319 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
2320 host_->GestureEventLastQueueEvent().type); | 2320 host_->GestureEventLastQueueEvent().type); |
2321 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2321 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2322 host_->TapSuppressionControllerState()); | 2322 host_->TouchpadTapSuppressionControllerState()); |
2323 EXPECT_TRUE(host_->FlingInProgress()); | 2323 EXPECT_TRUE(host_->FlingInProgress()); |
2324 | 2324 |
2325 // Send GestureFlingStart Ack. | 2325 // Send GestureFlingStart Ack. |
2326 SendInputEventACK(WebInputEvent::GestureFlingStart, | 2326 SendInputEventACK(WebInputEvent::GestureFlingStart, |
2327 INPUT_EVENT_ACK_STATE_CONSUMED); | 2327 INPUT_EVENT_ACK_STATE_CONSUMED); |
2328 MessageLoop::current()->RunUntilIdle(); | 2328 MessageLoop::current()->RunUntilIdle(); |
2329 EXPECT_EQ(1U, process_->sink().message_count()); | 2329 EXPECT_EQ(1U, process_->sink().message_count()); |
2330 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2330 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2331 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2331 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2332 host_->TapSuppressionControllerState()); | 2332 host_->TouchpadTapSuppressionControllerState()); |
2333 EXPECT_TRUE(host_->FlingInProgress()); | 2333 EXPECT_TRUE(host_->FlingInProgress()); |
2334 | 2334 |
2335 // Send GestureFlingCancel. | 2335 // Send GestureFlingCancel. |
2336 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 2336 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
2337 WebGestureEvent::Touchpad); | 2337 WebGestureEvent::Touchpad); |
2338 EXPECT_EQ(2U, process_->sink().message_count()); | 2338 EXPECT_EQ(2U, process_->sink().message_count()); |
2339 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2339 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2340 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2340 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2341 host_->GestureEventLastQueueEvent().type); | 2341 host_->GestureEventLastQueueEvent().type); |
2342 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 2342 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
2343 host_->TapSuppressionControllerState()); | 2343 host_->TouchpadTapSuppressionControllerState()); |
2344 EXPECT_FALSE(host_->FlingInProgress()); | 2344 EXPECT_FALSE(host_->FlingInProgress()); |
2345 | 2345 |
2346 // Send MouseDown. This MouseDown should be suppressed. | 2346 // Send MouseDown. This MouseDown should be suppressed. |
2347 SimulateMouseEvent(WebInputEvent::MouseDown); | 2347 SimulateMouseEvent(WebInputEvent::MouseDown); |
2348 EXPECT_EQ(2U, process_->sink().message_count()); | 2348 EXPECT_EQ(2U, process_->sink().message_count()); |
2349 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2349 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2350 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2350 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2351 host_->GestureEventLastQueueEvent().type); | 2351 host_->GestureEventLastQueueEvent().type); |
2352 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2352 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2353 host_->TapSuppressionControllerState()); | 2353 host_->TouchpadTapSuppressionControllerState()); |
2354 EXPECT_FALSE(host_->FlingInProgress()); | 2354 EXPECT_FALSE(host_->FlingInProgress()); |
2355 | 2355 |
2356 // Send GestureFlingCancel Ack. | 2356 // Send GestureFlingCancel Ack. |
2357 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 2357 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
2358 INPUT_EVENT_ACK_STATE_CONSUMED); | 2358 INPUT_EVENT_ACK_STATE_CONSUMED); |
2359 MessageLoop::current()->RunUntilIdle(); | 2359 MessageLoop::current()->RunUntilIdle(); |
2360 EXPECT_EQ(2U, process_->sink().message_count()); | 2360 EXPECT_EQ(2U, process_->sink().message_count()); |
2361 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2361 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2362 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2362 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2363 host_->TapSuppressionControllerState()); | 2363 host_->TouchpadTapSuppressionControllerState()); |
2364 EXPECT_FALSE(host_->FlingInProgress()); | 2364 EXPECT_FALSE(host_->FlingInProgress()); |
2365 | 2365 |
2366 // Send MouseUp. This MouseUp should be suppressed. | 2366 // Send MouseUp. This MouseUp should be suppressed. |
2367 SimulateMouseEvent(WebInputEvent::MouseUp); | 2367 SimulateMouseEvent(WebInputEvent::MouseUp); |
2368 EXPECT_EQ(2U, process_->sink().message_count()); | 2368 EXPECT_EQ(2U, process_->sink().message_count()); |
2369 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2369 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2370 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2370 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2371 host_->TapSuppressionControllerState()); | 2371 host_->TouchpadTapSuppressionControllerState()); |
2372 EXPECT_FALSE(host_->FlingInProgress()); | 2372 EXPECT_FALSE(host_->FlingInProgress()); |
2373 } | 2373 } |
2374 | 2374 |
2375 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes | 2375 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes |
2376 // after MouseDown and there is a small delay between the Ack and MouseUp. | 2376 // after MouseDown and there is a small delay between the Ack and MouseUp. |
2377 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseInsufficientlyLateMouseUp) { | 2377 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseInsufficientlyLateMouseUp) { |
2378 process_->sink().ClearMessages(); | 2378 process_->sink().ClearMessages(); |
2379 | 2379 |
2380 // Send GestureFlingStart. | 2380 // Send GestureFlingStart. |
2381 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 2381 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
2382 EXPECT_EQ(1U, process_->sink().message_count()); | 2382 EXPECT_EQ(1U, process_->sink().message_count()); |
2383 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2383 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2384 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 2384 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
2385 host_->GestureEventLastQueueEvent().type); | 2385 host_->GestureEventLastQueueEvent().type); |
2386 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2386 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2387 host_->TapSuppressionControllerState()); | 2387 host_->TouchpadTapSuppressionControllerState()); |
2388 EXPECT_TRUE(host_->FlingInProgress()); | 2388 EXPECT_TRUE(host_->FlingInProgress()); |
2389 | 2389 |
2390 // Send GestureFlingStart Ack. | 2390 // Send GestureFlingStart Ack. |
2391 SendInputEventACK(WebInputEvent::GestureFlingStart, | 2391 SendInputEventACK(WebInputEvent::GestureFlingStart, |
2392 INPUT_EVENT_ACK_STATE_CONSUMED); | 2392 INPUT_EVENT_ACK_STATE_CONSUMED); |
2393 MessageLoop::current()->RunUntilIdle(); | 2393 MessageLoop::current()->RunUntilIdle(); |
2394 EXPECT_EQ(1U, process_->sink().message_count()); | 2394 EXPECT_EQ(1U, process_->sink().message_count()); |
2395 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2395 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2396 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2396 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2397 host_->TapSuppressionControllerState()); | 2397 host_->TouchpadTapSuppressionControllerState()); |
2398 EXPECT_TRUE(host_->FlingInProgress()); | 2398 EXPECT_TRUE(host_->FlingInProgress()); |
2399 | 2399 |
2400 // Send GestureFlingCancel. | 2400 // Send GestureFlingCancel. |
2401 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 2401 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
2402 WebGestureEvent::Touchpad); | 2402 WebGestureEvent::Touchpad); |
2403 EXPECT_EQ(2U, process_->sink().message_count()); | 2403 EXPECT_EQ(2U, process_->sink().message_count()); |
2404 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2404 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2405 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2405 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2406 host_->GestureEventLastQueueEvent().type); | 2406 host_->GestureEventLastQueueEvent().type); |
2407 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 2407 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
2408 host_->TapSuppressionControllerState()); | 2408 host_->TouchpadTapSuppressionControllerState()); |
2409 EXPECT_FALSE(host_->FlingInProgress()); | 2409 EXPECT_FALSE(host_->FlingInProgress()); |
2410 | 2410 |
2411 // Send MouseDown. This MouseDown should be suppressed. | 2411 // Send MouseDown. This MouseDown should be suppressed. |
2412 SimulateMouseEvent(WebInputEvent::MouseDown); | 2412 SimulateMouseEvent(WebInputEvent::MouseDown); |
2413 EXPECT_EQ(2U, process_->sink().message_count()); | 2413 EXPECT_EQ(2U, process_->sink().message_count()); |
2414 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2414 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2415 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2415 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2416 host_->GestureEventLastQueueEvent().type); | 2416 host_->GestureEventLastQueueEvent().type); |
2417 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2417 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2418 host_->TapSuppressionControllerState()); | 2418 host_->TouchpadTapSuppressionControllerState()); |
2419 EXPECT_FALSE(host_->FlingInProgress()); | 2419 EXPECT_FALSE(host_->FlingInProgress()); |
2420 | 2420 |
2421 // Send GestureFlingCancel Ack. | 2421 // Send GestureFlingCancel Ack. |
2422 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 2422 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
2423 INPUT_EVENT_ACK_STATE_CONSUMED); | 2423 INPUT_EVENT_ACK_STATE_CONSUMED); |
2424 MessageLoop::current()->RunUntilIdle(); | 2424 MessageLoop::current()->RunUntilIdle(); |
2425 EXPECT_EQ(2U, process_->sink().message_count()); | 2425 EXPECT_EQ(2U, process_->sink().message_count()); |
2426 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2426 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2427 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2427 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2428 host_->TapSuppressionControllerState()); | 2428 host_->TouchpadTapSuppressionControllerState()); |
2429 EXPECT_FALSE(host_->FlingInProgress()); | 2429 EXPECT_FALSE(host_->FlingInProgress()); |
2430 | 2430 |
2431 // Wait less than allowed delay between MouseDown and MouseUp, so they are | 2431 // Wait less than allowed delay between MouseDown and MouseUp, so they are |
2432 // still considered as a tap. | 2432 // still considered as a tap. |
2433 // TODO(mohsen): The amounts used for delays are too much and will slow down | 2433 // TODO(mohsen): The amounts used for delays are too much and will slow down |
2434 // the tests. A better way is to reduce the allowed delays in TSC before each | 2434 // the tests. A better way is to reduce the allowed delays in TSC before each |
2435 // test. So, they should be made configurable and accessible here. | 2435 // test. So, they should be made configurable and accessible here. |
2436 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 2436 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
2437 MessageLoop::QuitClosure(), | 2437 MessageLoop::QuitClosure(), |
2438 TimeDelta::FromMilliseconds(100)); | 2438 TimeDelta::FromMilliseconds(100)); |
2439 MessageLoop::current()->Run(); | 2439 MessageLoop::current()->Run(); |
2440 EXPECT_EQ(2U, process_->sink().message_count()); | 2440 EXPECT_EQ(2U, process_->sink().message_count()); |
2441 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2441 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2442 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2442 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2443 host_->TapSuppressionControllerState()); | 2443 host_->TouchpadTapSuppressionControllerState()); |
2444 EXPECT_FALSE(host_->FlingInProgress()); | 2444 EXPECT_FALSE(host_->FlingInProgress()); |
2445 | 2445 |
2446 // Send MouseUp. This MouseUp should be suppressed. | 2446 // Send MouseUp. This MouseUp should be suppressed. |
2447 SimulateMouseEvent(WebInputEvent::MouseUp); | 2447 SimulateMouseEvent(WebInputEvent::MouseUp); |
2448 EXPECT_EQ(2U, process_->sink().message_count()); | 2448 EXPECT_EQ(2U, process_->sink().message_count()); |
2449 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2449 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2450 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2450 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2451 host_->TapSuppressionControllerState()); | 2451 host_->TouchpadTapSuppressionControllerState()); |
2452 EXPECT_FALSE(host_->FlingInProgress()); | 2452 EXPECT_FALSE(host_->FlingInProgress()); |
2453 } | 2453 } |
2454 | 2454 |
2455 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes | 2455 // Test TouchpadTapSuppressionController for when GestureFlingCancel Ack comes |
2456 // after MouseDown and there is a long delay between the Ack and MouseUp. | 2456 // after MouseDown and there is a long delay between the Ack and MouseUp. |
2457 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseSufficientlyLateMouseUp) { | 2457 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseSufficientlyLateMouseUp) { |
2458 process_->sink().ClearMessages(); | 2458 process_->sink().ClearMessages(); |
2459 | 2459 |
2460 // Send GestureFlingStart. | 2460 // Send GestureFlingStart. |
2461 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); | 2461 SimulateGestureFlingStartEvent(0, -10, WebGestureEvent::Touchpad); |
2462 EXPECT_EQ(1U, process_->sink().message_count()); | 2462 EXPECT_EQ(1U, process_->sink().message_count()); |
2463 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2463 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2464 EXPECT_EQ(WebInputEvent::GestureFlingStart, | 2464 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
2465 host_->GestureEventLastQueueEvent().type); | 2465 host_->GestureEventLastQueueEvent().type); |
2466 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2466 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2467 host_->TapSuppressionControllerState()); | 2467 host_->TouchpadTapSuppressionControllerState()); |
2468 EXPECT_TRUE(host_->FlingInProgress()); | 2468 EXPECT_TRUE(host_->FlingInProgress()); |
2469 | 2469 |
2470 // Send GestureFlingStart Ack. | 2470 // Send GestureFlingStart Ack. |
2471 SendInputEventACK(WebInputEvent::GestureFlingStart, | 2471 SendInputEventACK(WebInputEvent::GestureFlingStart, |
2472 INPUT_EVENT_ACK_STATE_CONSUMED); | 2472 INPUT_EVENT_ACK_STATE_CONSUMED); |
2473 MessageLoop::current()->RunUntilIdle(); | 2473 MessageLoop::current()->RunUntilIdle(); |
2474 EXPECT_EQ(1U, process_->sink().message_count()); | 2474 EXPECT_EQ(1U, process_->sink().message_count()); |
2475 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2475 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2476 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2476 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2477 host_->TapSuppressionControllerState()); | 2477 host_->TouchpadTapSuppressionControllerState()); |
2478 EXPECT_TRUE(host_->FlingInProgress()); | 2478 EXPECT_TRUE(host_->FlingInProgress()); |
2479 | 2479 |
2480 // Send GestureFlingCancel. | 2480 // Send GestureFlingCancel. |
2481 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, | 2481 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
2482 WebGestureEvent::Touchpad); | 2482 WebGestureEvent::Touchpad); |
2483 EXPECT_EQ(2U, process_->sink().message_count()); | 2483 EXPECT_EQ(2U, process_->sink().message_count()); |
2484 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2484 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2485 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2485 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2486 host_->GestureEventLastQueueEvent().type); | 2486 host_->GestureEventLastQueueEvent().type); |
2487 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | 2487 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
2488 host_->TapSuppressionControllerState()); | 2488 host_->TouchpadTapSuppressionControllerState()); |
2489 EXPECT_FALSE(host_->FlingInProgress()); | 2489 EXPECT_FALSE(host_->FlingInProgress()); |
2490 | 2490 |
2491 // Send MouseDown. This MouseDown should be suppressed, for now. | 2491 // Send MouseDown. This MouseDown should be suppressed, for now. |
2492 SimulateMouseEvent(WebInputEvent::MouseDown); | 2492 SimulateMouseEvent(WebInputEvent::MouseDown); |
2493 EXPECT_EQ(2U, process_->sink().message_count()); | 2493 EXPECT_EQ(2U, process_->sink().message_count()); |
2494 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2494 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2495 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | 2495 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
2496 host_->GestureEventLastQueueEvent().type); | 2496 host_->GestureEventLastQueueEvent().type); |
2497 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2497 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2498 host_->TapSuppressionControllerState()); | 2498 host_->TouchpadTapSuppressionControllerState()); |
2499 EXPECT_FALSE(host_->FlingInProgress()); | 2499 EXPECT_FALSE(host_->FlingInProgress()); |
2500 | 2500 |
2501 // Send GestureFlingCancel Ack. | 2501 // Send GestureFlingCancel Ack. |
2502 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 2502 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
2503 INPUT_EVENT_ACK_STATE_CONSUMED); | 2503 INPUT_EVENT_ACK_STATE_CONSUMED); |
2504 MessageLoop::current()->RunUntilIdle(); | 2504 MessageLoop::current()->RunUntilIdle(); |
2505 EXPECT_EQ(2U, process_->sink().message_count()); | 2505 EXPECT_EQ(2U, process_->sink().message_count()); |
2506 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2506 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2507 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, | 2507 EXPECT_EQ(MockRenderWidgetHost::TSC_TAP_DOWN_STASHED, |
2508 host_->TapSuppressionControllerState()); | 2508 host_->TouchpadTapSuppressionControllerState()); |
2509 EXPECT_FALSE(host_->FlingInProgress()); | 2509 EXPECT_FALSE(host_->FlingInProgress()); |
2510 | 2510 |
2511 // Wait more than allowed delay between MouseDown and MouseUp, so they are | 2511 // Wait more than allowed delay between MouseDown and MouseUp, so they are |
2512 // not considered as a tap. This should release the previously suppressed | 2512 // not considered as a tap. This should release the previously suppressed |
2513 // MouseDown. | 2513 // MouseDown. |
2514 // TODO(mohsen): The amounts used for delays are too much and will slow down | 2514 // TODO(mohsen): The amounts used for delays are too much and will slow down |
2515 // the tests. A better way is to reduce the allowed delays in TSC before each | 2515 // the tests. A better way is to reduce the allowed delays in TSC before each |
2516 // test. So, they should be made configurable and accessible here. | 2516 // test. So, they should be made configurable and accessible here. |
2517 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 2517 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
2518 MessageLoop::QuitClosure(), | 2518 MessageLoop::QuitClosure(), |
2519 TimeDelta::FromMilliseconds(300)); | 2519 TimeDelta::FromMilliseconds(300)); |
2520 MessageLoop::current()->Run(); | 2520 MessageLoop::current()->Run(); |
2521 EXPECT_EQ(3U, process_->sink().message_count()); | 2521 EXPECT_EQ(3U, process_->sink().message_count()); |
2522 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2522 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2523 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2523 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2524 host_->TapSuppressionControllerState()); | 2524 host_->TouchpadTapSuppressionControllerState()); |
2525 EXPECT_FALSE(host_->FlingInProgress()); | 2525 EXPECT_FALSE(host_->FlingInProgress()); |
2526 | 2526 |
2527 // Send MouseUp. This MouseUp should not be suppressed. | 2527 // Send MouseUp. This MouseUp should not be suppressed. |
2528 SimulateMouseEvent(WebInputEvent::MouseUp); | 2528 SimulateMouseEvent(WebInputEvent::MouseUp); |
2529 EXPECT_EQ(4U, process_->sink().message_count()); | 2529 EXPECT_EQ(4U, process_->sink().message_count()); |
2530 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 2530 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2531 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | 2531 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
2532 host_->TapSuppressionControllerState()); | 2532 host_->TouchpadTapSuppressionControllerState()); |
2533 EXPECT_FALSE(host_->FlingInProgress()); | 2533 EXPECT_FALSE(host_->FlingInProgress()); |
2534 } | 2534 } |
2535 #endif // defined(USE_AURA) | 2535 #endif // defined(USE_AURA) |
2536 | 2536 |
2537 // Tests that touch-events are queued properly. | 2537 // Tests that touch-events are queued properly. |
2538 TEST_F(RenderWidgetHostTest, TouchEventQueue) { | 2538 TEST_F(RenderWidgetHostTest, TouchEventQueue) { |
2539 process_->sink().ClearMessages(); | 2539 process_->sink().ClearMessages(); |
2540 | 2540 |
2541 PressTouchPoint(1, 1); | 2541 PressTouchPoint(1, 1); |
2542 SendTouchEvent(); | 2542 SendTouchEvent(); |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3929 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3929 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3930 | 3930 |
3931 // Since the overscroll mode has been reset, the next scroll update events | 3931 // Since the overscroll mode has been reset, the next scroll update events |
3932 // should reach the renderer. | 3932 // should reach the renderer. |
3933 SimulateGestureScrollUpdateEvent(-20, 0, 0); | 3933 SimulateGestureScrollUpdateEvent(-20, 0, 0); |
3934 EXPECT_EQ(1U, process_->sink().message_count()); | 3934 EXPECT_EQ(1U, process_->sink().message_count()); |
3935 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3935 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3936 } | 3936 } |
3937 | 3937 |
3938 } // namespace content | 3938 } // namespace content |
OLD | NEW |