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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | 45 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
46 PickleIterator iter(message); | 46 PickleIterator iter(message); |
47 const char* data; | 47 const char* data; |
48 int data_length; | 48 int data_length; |
49 if (!message.ReadData(&iter, &data, &data_length)) | 49 if (!message.ReadData(&iter, &data, &data_length)) |
50 return NULL; | 50 return NULL; |
51 return reinterpret_cast<const WebInputEvent*>(data); | 51 return reinterpret_cast<const WebInputEvent*>(data); |
52 } | 52 } |
53 | 53 |
54 WebInputEvent& GetEventWithType(WebInputEvent::Type type) { | |
55 WebInputEvent* event = NULL; | |
56 if (WebInputEvent::isMouseEventType(type)) { | |
57 static WebMouseEvent mouse; | |
58 event = &mouse; | |
59 } else if (WebInputEvent::isTouchEventType(type)) { | |
60 static WebTouchEvent touch; | |
61 event = &touch; | |
62 } else if (WebInputEvent::isKeyboardEventType(type)) { | |
63 static WebKeyboardEvent key; | |
64 event = &key; | |
65 } else if (WebInputEvent::isGestureEventType(type)) { | |
66 static WebGestureEvent gesture; | |
67 event = &gesture; | |
68 } else if (type == WebInputEvent::MouseWheel) { | |
69 static WebMouseWheelEvent wheel; | |
70 event = &wheel; | |
71 } | |
72 CHECK(event); | |
73 event->type = type; | |
74 return *event; | |
75 } | |
76 | |
77 bool GetIsShortcutFromHandleInputEventMessage(const IPC::Message* msg) { | 54 bool GetIsShortcutFromHandleInputEventMessage(const IPC::Message* msg) { |
78 InputMsg_HandleInputEvent::Schema::Param param; | 55 InputMsg_HandleInputEvent::Schema::Param param; |
79 InputMsg_HandleInputEvent::Read(msg, ¶m); | 56 InputMsg_HandleInputEvent::Read(msg, ¶m); |
80 return param.c; | 57 return param.c; |
81 } | 58 } |
82 | 59 |
83 template<typename MSG_T, typename ARG_T1> | 60 template<typename MSG_T, typename ARG_T1> |
84 void ExpectIPCMessageWithArg1(const IPC::Message* msg, const ARG_T1& arg1) { | 61 void ExpectIPCMessageWithArg1(const IPC::Message* msg, const ARG_T1& arg1) { |
85 ASSERT_EQ(MSG_T::ID, msg->type()); | 62 ASSERT_EQ(MSG_T::ID, msg->type()); |
86 typename MSG_T::Schema::Param param; | 63 typename MSG_T::Schema::Param param; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 touch_event_.MovePoint(index, x, y); | 245 touch_event_.MovePoint(index, x, y); |
269 } | 246 } |
270 | 247 |
271 void ReleaseTouchPoint(int index) { | 248 void ReleaseTouchPoint(int index) { |
272 touch_event_.ReleasePoint(index); | 249 touch_event_.ReleasePoint(index); |
273 } | 250 } |
274 | 251 |
275 void CancelTouchPoint(int index) { | 252 void CancelTouchPoint(int index) { |
276 touch_event_.CancelPoint(index); | 253 touch_event_.CancelPoint(index); |
277 } | 254 } |
278 | |
279 void SendInputEventACK(blink::WebInputEvent::Type type, | 255 void SendInputEventACK(blink::WebInputEvent::Type type, |
280 InputEventAckState ack_result) { | 256 InputEventAckState ack_result) { |
281 scoped_ptr<IPC::Message> response( | 257 scoped_ptr<IPC::Message> response( |
282 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, | 258 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, |
283 ui::LatencyInfo())); | 259 ui::LatencyInfo())); |
284 input_router_->OnMessageReceived(*response); | 260 input_router_->OnMessageReceived(*response); |
285 } | 261 } |
286 | 262 |
287 InputRouterImpl* input_router() const { | 263 InputRouterImpl* input_router() const { |
288 return input_router_.get(); | 264 return input_router_.get(); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 } | 735 } |
760 | 736 |
761 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { | 737 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { |
762 OnHasTouchEventHandlers(true); | 738 OnHasTouchEventHandlers(true); |
763 | 739 |
764 int start_type = static_cast<int>(WebInputEvent::TouchStart); | 740 int start_type = static_cast<int>(WebInputEvent::TouchStart); |
765 int end_type = static_cast<int>(WebInputEvent::TouchCancel); | 741 int end_type = static_cast<int>(WebInputEvent::TouchCancel); |
766 ASSERT_LT(start_type, end_type); | 742 ASSERT_LT(start_type, end_type); |
767 for (int i = start_type; i <= end_type; ++i) { | 743 for (int i = start_type; i <= end_type; ++i) { |
768 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); | 744 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); |
769 if (!WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type))) | 745 if (!WebInputEventTraits::IgnoresAckDisposition(type)) |
770 continue; | 746 continue; |
771 | 747 |
772 // The TouchEventQueue requires an initial TouchStart for it to begin | 748 // The TouchEventQueue requires an initial TouchStart for it to begin |
773 // forwarding other touch event types. | 749 // forwarding other touch event types. |
774 if (type != WebInputEvent::TouchStart) { | 750 if (type != WebInputEvent::TouchStart) { |
775 SimulateTouchEvent(WebInputEvent::TouchStart); | 751 SimulateTouchEvent(WebInputEvent::TouchStart); |
776 SendInputEventACK(WebInputEvent::TouchStart, | 752 SendInputEventACK(WebInputEvent::TouchStart, |
777 INPUT_EVENT_ACK_STATE_CONSUMED); | 753 INPUT_EVENT_ACK_STATE_CONSUMED); |
778 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); | 754 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); |
779 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 755 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 WebInputEvent::GestureTapCancel, | 796 WebInputEvent::GestureTapCancel, |
821 WebInputEvent::GestureScrollBegin, | 797 WebInputEvent::GestureScrollBegin, |
822 WebInputEvent::GestureScrollUpdate, | 798 WebInputEvent::GestureScrollUpdate, |
823 WebInputEvent::GestureScrollUpdateWithoutPropagation, | 799 WebInputEvent::GestureScrollUpdateWithoutPropagation, |
824 WebInputEvent::GesturePinchBegin, | 800 WebInputEvent::GesturePinchBegin, |
825 WebInputEvent::GesturePinchUpdate, | 801 WebInputEvent::GesturePinchUpdate, |
826 WebInputEvent::GesturePinchEnd, | 802 WebInputEvent::GesturePinchEnd, |
827 WebInputEvent::GestureScrollEnd}; | 803 WebInputEvent::GestureScrollEnd}; |
828 for (int i = 0; i < kEventTypesLength; ++i) { | 804 for (int i = 0; i < kEventTypesLength; ++i) { |
829 WebInputEvent::Type type = eventTypes[i]; | 805 WebInputEvent::Type type = eventTypes[i]; |
830 if (!WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type))) { | 806 if (!WebInputEventTraits::IgnoresAckDisposition(type)) { |
831 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); | 807 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); |
832 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 808 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
833 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 809 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
834 EXPECT_EQ(1, client_->in_flight_event_count()); | 810 EXPECT_EQ(1, client_->in_flight_event_count()); |
835 EXPECT_TRUE(HasPendingEvents()); | 811 EXPECT_TRUE(HasPendingEvents()); |
836 | 812 |
837 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 813 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
838 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 814 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
839 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 815 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
840 EXPECT_EQ(0, client_->in_flight_event_count()); | 816 EXPECT_EQ(0, client_->in_flight_event_count()); |
841 EXPECT_FALSE(HasPendingEvents()); | 817 EXPECT_FALSE(HasPendingEvents()); |
842 continue; | 818 continue; |
843 } | 819 } |
844 | 820 |
845 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); | 821 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); |
846 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 822 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
847 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 823 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
848 EXPECT_EQ(0, client_->in_flight_event_count()); | 824 EXPECT_EQ(0, client_->in_flight_event_count()); |
849 EXPECT_FALSE(HasPendingEvents()); | 825 EXPECT_FALSE(HasPendingEvents()); |
| 826 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 827 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 828 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 829 EXPECT_FALSE(HasPendingEvents()); |
850 } | 830 } |
851 } | 831 } |
852 | 832 |
853 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { | 833 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { |
854 int start_type = static_cast<int>(WebInputEvent::MouseDown); | 834 int start_type = static_cast<int>(WebInputEvent::MouseDown); |
855 int end_type = static_cast<int>(WebInputEvent::ContextMenu); | 835 int end_type = static_cast<int>(WebInputEvent::ContextMenu); |
856 ASSERT_LT(start_type, end_type); | 836 ASSERT_LT(start_type, end_type); |
857 for (int i = start_type; i <= end_type; ++i) { | 837 for (int i = start_type; i <= end_type; ++i) { |
858 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); | 838 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); |
859 int expected_in_flight_event_count = | 839 int expected_in_flight_event_count = |
860 WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type)) ? 0 | 840 WebInputEventTraits::IgnoresAckDisposition(type) ? 0 : 1; |
861 : 1; | |
862 | 841 |
863 // Note: Mouse event acks are never forwarded to the ack handler, so the key | 842 // Note: Mouse event acks are never forwarded to the ack handler, so the key |
864 // result here is that ignored ack types don't affect the in-flight count. | 843 // result here is that ignored ack types don't affect the in-flight count. |
865 SimulateMouseEvent(type, 0, 0); | 844 SimulateMouseEvent(type, 0, 0); |
866 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 845 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
867 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 846 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
868 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); | 847 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); |
869 if (expected_in_flight_event_count) { | 848 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
870 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 849 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
871 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 850 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
872 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 851 EXPECT_EQ(0, client_->in_flight_event_count()); |
873 EXPECT_EQ(0, client_->in_flight_event_count()); | |
874 } | |
875 } | 852 } |
876 } | 853 } |
877 | 854 |
878 // Guard against breaking changes to the list of ignored event ack types in | 855 // Guard against breaking changes to the list of ignored event ack types in |
879 // |WebInputEventTraits::IgnoresAckDisposition|. | 856 // |WebInputEventTraits::IgnoresAckDisposition|. |
880 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { | 857 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { |
881 const WebInputEvent::Type kRequiredEventAckTypes[] = { | 858 const WebInputEvent::Type kRequiredEventAckTypes[] = { |
882 WebInputEvent::MouseMove, | 859 WebInputEvent::MouseMove, |
883 WebInputEvent::MouseWheel, | 860 WebInputEvent::MouseWheel, |
884 WebInputEvent::RawKeyDown, | 861 WebInputEvent::RawKeyDown, |
885 WebInputEvent::KeyDown, | 862 WebInputEvent::KeyDown, |
886 WebInputEvent::KeyUp, | 863 WebInputEvent::KeyUp, |
887 WebInputEvent::Char, | 864 WebInputEvent::Char, |
888 WebInputEvent::GestureScrollUpdate, | 865 WebInputEvent::GestureScrollUpdate, |
889 WebInputEvent::GestureFlingStart, | 866 WebInputEvent::GestureFlingStart, |
890 WebInputEvent::GestureFlingCancel, | 867 WebInputEvent::GestureFlingCancel, |
891 WebInputEvent::GesturePinchUpdate, | 868 WebInputEvent::GesturePinchUpdate, |
892 WebInputEvent::TouchStart, | 869 WebInputEvent::TouchStart, |
893 WebInputEvent::TouchMove | 870 WebInputEvent::TouchMove |
894 }; | 871 }; |
895 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) { | 872 for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) { |
896 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i]; | 873 const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i]; |
897 EXPECT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 874 EXPECT_FALSE(WebInputEventTraits::IgnoresAckDisposition(required_ack_type)); |
898 GetEventWithType(required_ack_type))); | |
899 } | 875 } |
900 } | 876 } |
901 | 877 |
902 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't | 878 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't |
903 // wait for ACKs. | 879 // wait for ACKs. |
904 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { | 880 TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { |
905 // Interleave a few events that do and do not ignore acks, ensuring that | 881 // Interleave a few events that do and do not ignore acks, ensuring that |
906 // ack-ignoring events aren't dispatched until all prior events which observe | 882 // ack-ignoring events aren't dispatched until all prior events which observe |
907 // their ack disposition have been dispatched. | 883 // their ack disposition have been dispatched. |
908 | 884 |
(...skipping 28 matching lines...) Expand all Loading... |
937 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 913 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
938 WebGestureEvent::Touchscreen); | 914 WebGestureEvent::Touchscreen); |
939 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 915 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
940 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 916 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
941 | 917 |
942 SimulateGestureEvent(WebInputEvent::GestureTapCancel, | 918 SimulateGestureEvent(WebInputEvent::GestureTapCancel, |
943 WebGestureEvent::Touchscreen); | 919 WebGestureEvent::Touchscreen); |
944 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 920 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
945 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 921 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
946 | 922 |
947 // Now ack each ack-respecting event. Ack-ignoring events should not be | 923 // Now ack each event. Ack-ignoring events should not be dispatched until all |
948 // dispatched until all prior events which observe ack disposition have been | 924 // prior events which observe ack disposition have been fired, at which |
949 // fired, at which point they should be sent immediately. They should also | 925 // point they should be sent immediately. They should also have no effect |
950 // have no effect on the in-flight event count. | 926 // on the in-flight event count. |
| 927 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
| 928 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 929 |
951 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 930 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
952 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 931 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
953 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 932 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
954 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); | 933 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); |
955 EXPECT_EQ(1, client_->in_flight_event_count()); | 934 EXPECT_EQ(1, client_->in_flight_event_count()); |
956 | 935 |
| 936 // For events which ignore ack disposition, non-synthetic acks are ignored. |
| 937 SendInputEventACK(WebInputEvent::GestureTapDown, |
| 938 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 939 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 940 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 941 EXPECT_EQ(1, client_->in_flight_event_count()); |
| 942 |
957 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 943 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
958 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 944 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
959 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 945 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
960 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); | 946 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); |
961 EXPECT_EQ(1, client_->in_flight_event_count()); | 947 EXPECT_EQ(1, client_->in_flight_event_count()); |
962 | 948 |
| 949 // For events which ignore ack disposition, non-synthetic acks are ignored. |
| 950 SendInputEventACK(WebInputEvent::GestureShowPress, |
| 951 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 952 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 953 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 954 EXPECT_EQ(1, client_->in_flight_event_count()); |
| 955 |
963 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 956 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
964 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 957 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
965 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 958 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
966 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); | 959 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); |
967 EXPECT_EQ(0, client_->in_flight_event_count()); | 960 EXPECT_EQ(0, client_->in_flight_event_count()); |
| 961 |
| 962 // For events which ignore ack disposition, non-synthetic acks are ignored. |
| 963 SendInputEventACK(WebInputEvent::GestureTapCancel, |
| 964 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 965 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 966 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 967 EXPECT_EQ(0, client_->in_flight_event_count()); |
968 } | 968 } |
969 | 969 |
970 // Test that GestureShowPress events don't get out of order due to | 970 // Test that GestureShowPress events don't get out of order due to |
971 // ignoring their acks. | 971 // ignoring their acks. |
972 TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) { | 972 TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) { |
973 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 973 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
974 WebGestureEvent::Touchscreen); | 974 WebGestureEvent::Touchscreen); |
975 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 975 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
976 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 976 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
977 | 977 |
(...skipping 18 matching lines...) Expand all Loading... |
996 // The ShowPress, though it ignores ack, is still stuck in the queue | 996 // The ShowPress, though it ignores ack, is still stuck in the queue |
997 // behind the PinchUpdate which requires an ack. | 997 // behind the PinchUpdate which requires an ack. |
998 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 998 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
999 | 999 |
1000 SimulateGestureEvent(WebInputEvent::GestureShowPress, | 1000 SimulateGestureEvent(WebInputEvent::GestureShowPress, |
1001 WebGestureEvent::Touchscreen); | 1001 WebGestureEvent::Touchscreen); |
1002 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1002 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1003 // ShowPress has entered the queue. | 1003 // ShowPress has entered the queue. |
1004 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1004 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
1005 | 1005 |
| 1006 // This ack is ignored. |
| 1007 SendInputEventACK(WebInputEvent::GesturePinchBegin, |
| 1008 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1009 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1010 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 1011 |
1006 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 1012 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
1007 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1013 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1008 // Now that the Tap has been ACKed, the ShowPress events should receive | 1014 // Now that the Tap has been ACKed, the ShowPress events should receive |
1009 // synthetic acks, and fire immediately. | 1015 // synthetic acks, and fire immediately. |
1010 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 1016 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
1011 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); | 1017 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); |
1012 } | 1018 } |
1013 | 1019 |
1014 // Test that touch ack timeout behavior is properly configured via the command | 1020 // Test that touch ack timeout behavior is properly configured via the command |
1015 // line, and toggled by view update flags and allowed touch actions. | 1021 // line, and toggled by view update flags and allowed touch actions. |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 // First tap. | 1281 // First tap. |
1276 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 1282 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
1277 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1283 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1278 WebGestureEvent::Touchscreen); | 1284 WebGestureEvent::Touchscreen); |
1279 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1285 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1280 | 1286 |
1281 // The GestureTapUnconfirmed is converted into a tap, as the touch action is | 1287 // The GestureTapUnconfirmed is converted into a tap, as the touch action is |
1282 // auto. | 1288 // auto. |
1283 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, | 1289 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, |
1284 WebGestureEvent::Touchscreen); | 1290 WebGestureEvent::Touchscreen); |
| 1291 SendInputEventACK(WebInputEvent::GestureTap, |
| 1292 INPUT_EVENT_ACK_STATE_CONSUMED); |
1285 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1293 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1286 | 1294 |
1287 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned | 1295 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned |
1288 // into a tap. | 1296 // into a tap. |
1289 SimulateGestureEvent(WebInputEvent::GestureTap, WebGestureEvent::Touchscreen); | 1297 SimulateGestureEvent(WebInputEvent::GestureTap, WebGestureEvent::Touchscreen); |
1290 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1298 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1291 | 1299 |
1292 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); | 1300 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); |
1293 SendInputEventACK(WebInputEvent::TouchStart, | 1301 SendInputEventACK(WebInputEvent::TouchStart, |
1294 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 1302 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
1295 | 1303 |
1296 // Second Tap. | 1304 // Second Tap. |
1297 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1305 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1298 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1306 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1299 WebGestureEvent::Touchscreen); | 1307 WebGestureEvent::Touchscreen); |
1300 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1308 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1301 | 1309 |
1302 // Although the touch-action is now auto, the double tap still won't be | 1310 // Although the touch-action is now auto, the double tap still won't be |
1303 // dispatched, because the first tap occured when the touch-action was none. | 1311 // dispatched, because the first tap occured when the touch-action was none. |
1304 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, | 1312 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, |
1305 WebGestureEvent::Touchscreen); | 1313 WebGestureEvent::Touchscreen); |
1306 // This test will become invalid if GestureDoubleTap stops requiring an ack. | 1314 // This test will become invalid if GestureDoubleTap stops requiring an ack. |
1307 DCHECK(!WebInputEventTraits::IgnoresAckDisposition( | 1315 DCHECK(!WebInputEventTraits::IgnoresAckDisposition( |
1308 GetEventWithType(WebInputEvent::GestureDoubleTap))); | 1316 WebInputEvent::GestureDoubleTap)); |
1309 EXPECT_EQ(0, client_->in_flight_event_count()); | 1317 EXPECT_EQ(0, client_->in_flight_event_count()); |
1310 } | 1318 } |
1311 | 1319 |
1312 // Test that the router will call the client's |DidFlush| after all events have | 1320 // Test that the router will call the client's |DidFlush| after all events have |
1313 // been dispatched following a call to |Flush|. | 1321 // been dispatched following a call to |Flush|. |
1314 TEST_F(InputRouterImplTest, InputFlush) { | 1322 TEST_F(InputRouterImplTest, InputFlush) { |
1315 EXPECT_FALSE(HasPendingEvents()); | 1323 EXPECT_FALSE(HasPendingEvents()); |
1316 | 1324 |
1317 // Flushing an empty router should immediately trigger DidFlush. | 1325 // Flushing an empty router should immediately trigger DidFlush. |
1318 Flush(); | 1326 Flush(); |
(...skipping 15 matching lines...) Expand all Loading... |
1334 | 1342 |
1335 // Ensure different types of enqueued events will prevent the DidFlush call | 1343 // Ensure different types of enqueued events will prevent the DidFlush call |
1336 // until all such events have been fully dispatched. | 1344 // until all such events have been fully dispatched. |
1337 MoveTouchPoint(0, 50, 50); | 1345 MoveTouchPoint(0, 50, 50); |
1338 SendTouchEvent(); | 1346 SendTouchEvent(); |
1339 ASSERT_TRUE(HasPendingEvents()); | 1347 ASSERT_TRUE(HasPendingEvents()); |
1340 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1348 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1341 WebGestureEvent::Touchscreen); | 1349 WebGestureEvent::Touchscreen); |
1342 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 1350 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
1343 WebGestureEvent::Touchscreen); | 1351 WebGestureEvent::Touchscreen); |
1344 SimulateGestureEvent(WebInputEvent::GesturePinchBegin, | |
1345 WebGestureEvent::Touchscreen); | |
1346 SimulateGestureEvent(WebInputEvent::GesturePinchUpdate, | |
1347 WebGestureEvent::Touchscreen); | |
1348 Flush(); | 1352 Flush(); |
1349 EXPECT_EQ(0U, GetAndResetDidFlushCount()); | 1353 EXPECT_EQ(0U, GetAndResetDidFlushCount()); |
1350 | 1354 |
1351 // Repeated flush calls should have no effect. | 1355 // Repeated flush calls should have no effect. |
1352 Flush(); | 1356 Flush(); |
1353 EXPECT_EQ(0U, GetAndResetDidFlushCount()); | 1357 EXPECT_EQ(0U, GetAndResetDidFlushCount()); |
1354 | 1358 |
1355 // There are still pending gestures. | 1359 // There are still pending gestures. |
1356 SendInputEventACK(WebInputEvent::TouchMove, | 1360 SendInputEventACK(WebInputEvent::TouchMove, |
1357 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1361 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1358 EXPECT_EQ(0U, GetAndResetDidFlushCount()); | 1362 EXPECT_EQ(0U, GetAndResetDidFlushCount()); |
1359 EXPECT_TRUE(HasPendingEvents()); | 1363 EXPECT_TRUE(HasPendingEvents()); |
1360 | 1364 |
1361 // One more gesture to go. | 1365 // One more gesture to go. |
1362 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1366 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
1363 INPUT_EVENT_ACK_STATE_CONSUMED); | 1367 INPUT_EVENT_ACK_STATE_CONSUMED); |
1364 EXPECT_EQ(0U, GetAndResetDidFlushCount()); | 1368 EXPECT_EQ(0U, GetAndResetDidFlushCount()); |
1365 EXPECT_TRUE(HasPendingEvents()); | 1369 EXPECT_TRUE(HasPendingEvents()); |
1366 | 1370 |
1367 // The final ack'ed gesture should trigger the DidFlush. | 1371 // The final ack'ed gesture should trigger the DidFlush. |
1368 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 1372 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1369 INPUT_EVENT_ACK_STATE_CONSUMED); | 1373 INPUT_EVENT_ACK_STATE_CONSUMED); |
1370 EXPECT_EQ(1U, GetAndResetDidFlushCount()); | 1374 EXPECT_EQ(1U, GetAndResetDidFlushCount()); |
1371 EXPECT_FALSE(HasPendingEvents()); | 1375 EXPECT_FALSE(HasPendingEvents()); |
1372 } | 1376 } |
1373 | 1377 |
1374 // Test that GesturePinchUpdate is handled specially for trackpad | 1378 // Test that GesturePinchUpdate is handled specially for trackpad |
1375 TEST_F(InputRouterImplTest, TrackpadPinchUpdate) { | 1379 TEST_F(InputRouterImplTest, TrackpadPinchUpdate) { |
1376 // For now Trackpad PinchUpdate events are just immediately ACKed | 1380 // For now Trackpad PinchUpdate events are just immediately ACKed |
1377 // as unconsumed without going to the renderer. | 1381 // as unconsumed without going to the renderer. |
1378 // TODO(rbyers): Update for wheel event behavior - crbug.com/289887. | 1382 // TODO(rbyers): Update for wheel event behavior - crbug.com/289887. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 | 1432 |
1429 // Ack the second scroll. | 1433 // Ack the second scroll. |
1430 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1434 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1431 INPUT_EVENT_ACK_STATE_CONSUMED); | 1435 INPUT_EVENT_ACK_STATE_CONSUMED); |
1432 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1436 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1433 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1437 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
1434 EXPECT_EQ(0, client_->in_flight_event_count()); | 1438 EXPECT_EQ(0, client_->in_flight_event_count()); |
1435 } | 1439 } |
1436 | 1440 |
1437 } // namespace content | 1441 } // namespace content |
OLD | NEW |