Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1333)

Side by Side Diff: content/browser/renderer_host/input/input_router_impl_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698