| 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_filter.h" | 9 #include "content/browser/renderer_host/input/gesture_event_filter.h" |
| 10 #include "content/browser/renderer_host/input/input_router_client.h" | 10 #include "content/browser/renderer_host/input/input_router_client.h" |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 SendInputEventACK(WebInputEvent::GestureTapCancel, | 873 SendInputEventACK(WebInputEvent::GestureTapCancel, |
| 874 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 874 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 875 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 875 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 876 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 876 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 877 EXPECT_EQ(0, client_->in_flight_event_count()); | 877 EXPECT_EQ(0, client_->in_flight_event_count()); |
| 878 } | 878 } |
| 879 | 879 |
| 880 // Test that GestureShowPress events don't get out of order due to | 880 // Test that GestureShowPress events don't get out of order due to |
| 881 // ignoring their acks. | 881 // ignoring their acks. |
| 882 TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) { | 882 TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) { |
| 883 SimulateGestureEvent(WebInputEvent::GestureTap, | 883 // GesturePinchBegin ignores its ack. |
| 884 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, |
| 884 WebGestureEvent::Touchscreen); | 885 WebGestureEvent::Touchscreen); |
| 886 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 887 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 885 | 888 |
| 889 // GesturePinchBegin waits for an ack. |
| 890 SimulateGestureEvent(WebInputEvent::GesturePinchUpdate, |
| 891 WebGestureEvent::Touchscreen); |
| 886 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 892 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 887 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 893 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 888 | 894 |
| 889 SimulateGestureEvent(WebInputEvent::GestureShowPress, | 895 SimulateGestureEvent(WebInputEvent::GestureShowPress, |
| 890 WebGestureEvent::Touchscreen); | 896 WebGestureEvent::Touchscreen); |
| 891 | |
| 892 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 897 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 893 // The ShowPress, though it ignores ack, is still stuck in the queue | 898 // The ShowPress, though it ignores ack, is still stuck in the queue |
| 894 // behind the Tap which requires an ack. | 899 // behind the PinchUpdate which requires an ack. |
| 895 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 900 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 896 | 901 |
| 897 SimulateGestureEvent(WebInputEvent::GestureShowPress, | 902 SimulateGestureEvent(WebInputEvent::GestureShowPress, |
| 898 WebGestureEvent::Touchscreen); | 903 WebGestureEvent::Touchscreen); |
| 899 | |
| 900 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 904 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 901 // ShowPress has entered the queue. | 905 // ShowPress has entered the queue. |
| 902 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 906 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 903 | 907 |
| 904 SendInputEventACK(WebInputEvent::GestureTap, | 908 // This ack is ignored. |
| 909 SendInputEventACK(WebInputEvent::GesturePinchBegin, |
| 905 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 910 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 911 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 912 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 906 | 913 |
| 914 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
| 915 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 907 // Now that the Tap has been ACKed, the ShowPress events should receive | 916 // Now that the Tap has been ACKed, the ShowPress events should receive |
| 908 // synthetics acks, and fire immediately. | 917 // synthetic acks, and fire immediately. |
| 909 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 918 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
| 910 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); | 919 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); |
| 911 } | 920 } |
| 912 | 921 |
| 913 // Test that touch ack timeout behavior is properly configured via the command | 922 // Test that touch ack timeout behavior is properly configured via the command |
| 914 // line, and toggled by the view update flags. | 923 // line, and toggled by the view update flags. |
| 915 TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) { | 924 TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) { |
| 916 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 925 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 917 switches::kTouchAckTimeoutDelayMs, "5"); | 926 switches::kTouchAckTimeoutDelayMs, "5"); |
| 918 TearDown(); | 927 TearDown(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 931 | 940 |
| 932 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT | | 941 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT | |
| 933 InputRouter::FIXED_PAGE_SCALE); | 942 InputRouter::FIXED_PAGE_SCALE); |
| 934 EXPECT_FALSE(TouchEventTimeoutEnabled()); | 943 EXPECT_FALSE(TouchEventTimeoutEnabled()); |
| 935 | 944 |
| 936 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE); | 945 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE); |
| 937 EXPECT_TRUE(TouchEventTimeoutEnabled()); | 946 EXPECT_TRUE(TouchEventTimeoutEnabled()); |
| 938 } | 947 } |
| 939 | 948 |
| 940 } // namespace content | 949 } // namespace content |
| OLD | NEW |