Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 9 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
| 10 #include "content/browser/renderer_host/input/input_router_client.h" | 10 #include "content/browser/renderer_host/input/input_router_client.h" |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 | 985 |
| 986 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 986 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
| 987 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 987 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 988 // Now that the Tap has been ACKed, the ShowPress events should receive | 988 // Now that the Tap has been ACKed, the ShowPress events should receive |
| 989 // synthetic acks, and fire immediately. | 989 // synthetic acks, and fire immediately. |
| 990 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 990 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
| 991 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); | 991 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); |
| 992 } | 992 } |
| 993 | 993 |
| 994 // Test that touch ack timeout behavior is properly configured via the command | 994 // Test that touch ack timeout behavior is properly configured via the command |
| 995 // line, and toggled by the view update flags. | 995 // line, and toggled by view update flags and allowed touch actions. |
| 996 TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) { | 996 TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) { |
| 997 // Unless explicitly supported via the command-line, the touch timeout should | |
| 998 // be disabled. | |
| 999 EXPECT_FALSE(TouchEventTimeoutEnabled()); | |
| 1000 | |
| 997 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 1001 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 998 switches::kTouchAckTimeoutDelayMs, "5"); | 1002 switches::kTouchAckTimeoutDelayMs, "5"); |
| 999 TearDown(); | 1003 TearDown(); |
| 1000 SetUp(); | 1004 SetUp(); |
| 1001 ASSERT_TRUE(TouchEventTimeoutEnabled()); | 1005 ASSERT_TRUE(TouchEventTimeoutEnabled()); |
| 1002 | 1006 |
| 1003 // A fixed page scale or mobile viewport should disable the touch timeout. | 1007 // A fixed page scale or mobile viewport should disable the touch timeout. |
| 1004 input_router()->OnViewUpdated(InputRouter::FIXED_PAGE_SCALE); | 1008 input_router()->OnViewUpdated(InputRouter::FIXED_PAGE_SCALE); |
| 1005 EXPECT_FALSE(TouchEventTimeoutEnabled()); | 1009 EXPECT_FALSE(TouchEventTimeoutEnabled()); |
| 1006 | 1010 |
| 1007 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE); | 1011 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE); |
| 1008 EXPECT_TRUE(TouchEventTimeoutEnabled()); | 1012 EXPECT_TRUE(TouchEventTimeoutEnabled()); |
| 1009 | 1013 |
| 1010 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT); | 1014 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT); |
| 1011 EXPECT_FALSE(TouchEventTimeoutEnabled()); | 1015 EXPECT_FALSE(TouchEventTimeoutEnabled()); |
| 1012 | 1016 |
| 1013 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT | | 1017 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT | |
| 1014 InputRouter::FIXED_PAGE_SCALE); | 1018 InputRouter::FIXED_PAGE_SCALE); |
| 1015 EXPECT_FALSE(TouchEventTimeoutEnabled()); | 1019 EXPECT_FALSE(TouchEventTimeoutEnabled()); |
| 1016 | 1020 |
| 1017 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE); | 1021 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE); |
| 1018 EXPECT_TRUE(TouchEventTimeoutEnabled()); | 1022 EXPECT_TRUE(TouchEventTimeoutEnabled()); |
| 1023 | |
| 1024 // TOUCH_ACTION_NONE should disable the touch timeout. | |
| 1025 OnHasTouchEventHandlers(true); | |
| 1026 PressTouchPoint(1, 1); | |
| 1027 SendTouchEvent(); | |
| 1028 OnSetTouchAction(TOUCH_ACTION_NONE); | |
| 1029 EXPECT_FALSE(TouchEventTimeoutEnabled()); | |
| 1030 ReleaseTouchPoint(0); | |
| 1031 SendTouchEvent(); | |
| 1032 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1033 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1034 | |
| 1035 // As the touch-action is reset by a new touch sequence, the timeout behavior | |
| 1036 // should be restored. (Note that this is not entirely accurate: the timeout | |
| 1037 // will be enabled just *after* the new event has been forwarded from the | |
| 1038 // TouchEventQueue to the router, so the timeout won't actually take | |
| 1039 // meaningful effect until the following touch event is sent). | |
|
Rick Byers
2014/03/05 21:24:23
We both agree we like this property. Perhaps make
jdduke (slow)
2014/03/06 00:15:25
Definitely, added a test.
| |
| 1040 PressTouchPoint(1, 1); | |
| 1041 SendTouchEvent(); | |
| 1042 EXPECT_TRUE(TouchEventTimeoutEnabled()); | |
| 1043 ReleaseTouchPoint(0); | |
| 1044 SendTouchEvent(); | |
| 1045 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1046 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | |
| 1047 | |
| 1048 // Only TOUCH_ACTION_NONE should disable the timeout. | |
| 1049 PressTouchPoint(1, 1); | |
| 1050 SendTouchEvent(); | |
| 1051 OnSetTouchAction(TOUCH_ACTION_PAN_Y); | |
| 1052 EXPECT_TRUE(TouchEventTimeoutEnabled()); | |
| 1019 } | 1053 } |
| 1020 | 1054 |
| 1021 // Test that TouchActionFilter::ResetTouchAction is called before the | 1055 // Test that TouchActionFilter::ResetTouchAction is called before the |
| 1022 // first touch event for a touch sequence reaches the renderer. | 1056 // first touch event for a touch sequence reaches the renderer. |
| 1023 TEST_F(InputRouterImplTest, ResetTouchActionBeforeEventReachesRenderer) { | 1057 TEST_F(InputRouterImplTest, ResetTouchActionBeforeEventReachesRenderer) { |
| 1024 OnHasTouchEventHandlers(true); | 1058 OnHasTouchEventHandlers(true); |
| 1025 | 1059 |
| 1026 // Sequence 1. | 1060 // Sequence 1. |
| 1027 PressTouchPoint(1, 1); | 1061 PressTouchPoint(1, 1); |
| 1028 SendTouchEvent(); | 1062 SendTouchEvent(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 // dispatched, because the first tap occured when the touch-action was none. | 1199 // dispatched, because the first tap occured when the touch-action was none. |
| 1166 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, | 1200 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, |
| 1167 WebGestureEvent::Touchscreen); | 1201 WebGestureEvent::Touchscreen); |
| 1168 // This test will become invalid if GestureDoubleTap stops requiring an ack. | 1202 // This test will become invalid if GestureDoubleTap stops requiring an ack. |
| 1169 DCHECK(!WebInputEventTraits::IgnoresAckDisposition( | 1203 DCHECK(!WebInputEventTraits::IgnoresAckDisposition( |
| 1170 WebInputEvent::GestureDoubleTap)); | 1204 WebInputEvent::GestureDoubleTap)); |
| 1171 EXPECT_EQ(0, client_->in_flight_event_count()); | 1205 EXPECT_EQ(0, client_->in_flight_event_count()); |
| 1172 } | 1206 } |
| 1173 | 1207 |
| 1174 } // namespace content | 1208 } // namespace content |
| OLD | NEW |