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/location.h" | 6 #include "base/location.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 float y1) { | 177 float y1) { |
178 touch_event_.MovePoint(index0, x0, y0); | 178 touch_event_.MovePoint(index0, x0, y0); |
179 touch_event_.MovePoint(index1, x1, y1); | 179 touch_event_.MovePoint(index1, x1, y1); |
180 SendTouchEvent(); | 180 SendTouchEvent(); |
181 } | 181 } |
182 | 182 |
183 void ChangeTouchPointRadius(int index, float radius_x, float radius_y) { | 183 void ChangeTouchPointRadius(int index, float radius_x, float radius_y) { |
184 CHECK_GE(index, 0); | 184 CHECK_GE(index, 0); |
185 CHECK_LT(index, touch_event_.touchesLengthCap); | 185 CHECK_LT(index, touch_event_.touchesLengthCap); |
186 WebTouchPoint& point = touch_event_.touches[index]; | 186 WebTouchPoint& point = touch_event_.touches[index]; |
187 point.radiusX = radius_x; | 187 point.width = radius_x; |
188 point.radiusY = radius_y; | 188 point.height = radius_y; |
189 touch_event_.touches[index].state = WebTouchPoint::StateMoved; | 189 touch_event_.touches[index].state = WebTouchPoint::StateMoved; |
190 touch_event_.causesScrollingIfUncanceled = true; | 190 touch_event_.causesScrollingIfUncanceled = true; |
191 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, | 191 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, |
192 touch_event_.timeStampSeconds, | 192 touch_event_.timeStampSeconds, |
193 &touch_event_); | 193 &touch_event_); |
194 SendTouchEvent(); | 194 SendTouchEvent(); |
195 } | 195 } |
196 | 196 |
197 void ChangeTouchPointRotationAngle(int index, float rotation_angle) { | 197 void ChangeTouchPointRotationAngle(int index, float rotation_angle) { |
198 CHECK_GE(index, 0); | 198 CHECK_GE(index, 0); |
199 CHECK_LT(index, touch_event_.touchesLengthCap); | 199 CHECK_LT(index, touch_event_.touchesLengthCap); |
200 WebTouchPoint& point = touch_event_.touches[index]; | 200 WebTouchPoint& point = touch_event_.touches[index]; |
201 point.rotationAngle = rotation_angle; | 201 point.rotationAngle = rotation_angle; |
202 touch_event_.touches[index].state = WebTouchPoint::StateMoved; | 202 touch_event_.touches[index].state = WebTouchPoint::StateMoved; |
203 touch_event_.causesScrollingIfUncanceled = true; | 203 touch_event_.causesScrollingIfUncanceled = true; |
204 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, | 204 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, |
205 touch_event_.timeStampSeconds, | 205 touch_event_.timeStampSeconds, |
206 &touch_event_); | 206 &touch_event_); |
207 SendTouchEvent(); | 207 SendTouchEvent(); |
208 } | 208 } |
209 | 209 |
210 void ChangeTouchPointForce(int index, float force) { | 210 void ChangeTouchPointForce(int index, float force) { |
211 CHECK_GE(index, 0); | 211 CHECK_GE(index, 0); |
212 CHECK_LT(index, touch_event_.touchesLengthCap); | 212 CHECK_LT(index, touch_event_.touchesLengthCap); |
213 WebTouchPoint& point = touch_event_.touches[index]; | 213 WebTouchPoint& point = touch_event_.touches[index]; |
214 point.force = force; | 214 point.pressure = force; |
215 touch_event_.touches[index].state = WebTouchPoint::StateMoved; | 215 touch_event_.touches[index].state = WebTouchPoint::StateMoved; |
216 touch_event_.causesScrollingIfUncanceled = true; | 216 touch_event_.causesScrollingIfUncanceled = true; |
217 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, | 217 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, |
218 touch_event_.timeStampSeconds, | 218 touch_event_.timeStampSeconds, |
219 &touch_event_); | 219 &touch_event_); |
220 SendTouchEvent(); | 220 SendTouchEvent(); |
221 } | 221 } |
222 | 222 |
223 void ReleaseTouchPoint(int index) { | 223 void ReleaseTouchPoint(int index) { |
224 touch_event_.ReleasePoint(index); | 224 touch_event_.ReleasePoint(index); |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 PressTouchPoint(1, 1); | 827 PressTouchPoint(1, 1); |
828 EXPECT_EQ(1U, queued_event_count()); | 828 EXPECT_EQ(1U, queued_event_count()); |
829 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 829 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
830 EXPECT_EQ(0U, GetAndResetAckedEventCount()); | 830 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
831 | 831 |
832 // Create a touch event that will be queued synchronously by a touch ack. | 832 // Create a touch event that will be queued synchronously by a touch ack. |
833 // Note, this will be triggered by all subsequent touch acks. | 833 // Note, this will be triggered by all subsequent touch acks. |
834 WebTouchEvent followup_event; | 834 WebTouchEvent followup_event; |
835 followup_event.type = WebInputEvent::TouchMove; | 835 followup_event.type = WebInputEvent::TouchMove; |
836 followup_event.touchesLength = 1; | 836 followup_event.touchesLength = 1; |
837 followup_event.touches[0].id = 0; | 837 followup_event.touches[0].pointerId = 0; |
838 followup_event.touches[0].state = WebTouchPoint::StateMoved; | 838 followup_event.touches[0].state = WebTouchPoint::StateMoved; |
839 SetFollowupEvent(followup_event); | 839 SetFollowupEvent(followup_event); |
840 | 840 |
841 // Receive an ACK for the press. This should cause the followup touch-move to | 841 // Receive an ACK for the press. This should cause the followup touch-move to |
842 // be sent to the renderer. | 842 // be sent to the renderer. |
843 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 843 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
844 EXPECT_EQ(1U, queued_event_count()); | 844 EXPECT_EQ(1U, queued_event_count()); |
845 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 845 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
846 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 846 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
847 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state()); | 847 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, acked_event_state()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 896 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
897 } | 897 } |
898 | 898 |
899 // Tests that followup events triggered by an immediate ack from | 899 // Tests that followup events triggered by an immediate ack from |
900 // TouchEventQueue::QueueEvent() are properly handled. | 900 // TouchEventQueue::QueueEvent() are properly handled. |
901 TEST_F(TouchEventQueueTest, ImmediateAckWithFollowupEvents) { | 901 TEST_F(TouchEventQueueTest, ImmediateAckWithFollowupEvents) { |
902 // Create a touch event that will be queued synchronously by a touch ack. | 902 // Create a touch event that will be queued synchronously by a touch ack. |
903 WebTouchEvent followup_event; | 903 WebTouchEvent followup_event; |
904 followup_event.type = WebInputEvent::TouchStart; | 904 followup_event.type = WebInputEvent::TouchStart; |
905 followup_event.touchesLength = 1; | 905 followup_event.touchesLength = 1; |
906 followup_event.touches[0].id = 1; | 906 followup_event.touches[0].pointerId = 1; |
907 followup_event.touches[0].state = WebTouchPoint::StatePressed; | 907 followup_event.touches[0].state = WebTouchPoint::StatePressed; |
908 SetFollowupEvent(followup_event); | 908 SetFollowupEvent(followup_event); |
909 | 909 |
910 // Now, enqueue a stationary touch that will not be forwarded. This should be | 910 // Now, enqueue a stationary touch that will not be forwarded. This should be |
911 // immediately ack'ed with "NO_CONSUMER_EXISTS". The followup event should | 911 // immediately ack'ed with "NO_CONSUMER_EXISTS". The followup event should |
912 // then be enqueued and immediately sent to the renderer. | 912 // then be enqueued and immediately sent to the renderer. |
913 WebTouchEvent stationary_event; | 913 WebTouchEvent stationary_event; |
914 stationary_event.touchesLength = 1; | 914 stationary_event.touchesLength = 1; |
915 stationary_event.type = WebInputEvent::TouchMove; | 915 stationary_event.type = WebInputEvent::TouchMove; |
916 stationary_event.touches[0].id = 1; | 916 stationary_event.touches[0].pointerId = 1; |
917 stationary_event.touches[0].state = WebTouchPoint::StateStationary; | 917 stationary_event.touches[0].state = WebTouchPoint::StateStationary; |
918 SendTouchEvent(stationary_event); | 918 SendTouchEvent(stationary_event); |
919 | 919 |
920 EXPECT_EQ(1U, queued_event_count()); | 920 EXPECT_EQ(1U, queued_event_count()); |
921 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 921 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
922 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 922 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
923 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); | 923 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state()); |
924 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); | 924 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
925 } | 925 } |
926 | 926 |
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 | 2425 |
2426 TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { | 2426 TEST_F(TouchEventQueueTest, UnseenTouchPointerIdsNotForwarded) { |
2427 SyntheticWebTouchEvent event; | 2427 SyntheticWebTouchEvent event; |
2428 event.PressPoint(0, 0); | 2428 event.PressPoint(0, 0); |
2429 SendTouchEvent(event); | 2429 SendTouchEvent(event); |
2430 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2430 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2431 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2431 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2432 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2432 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2433 | 2433 |
2434 // Give the touchmove a previously unseen pointer id; it should not be sent. | 2434 // Give the touchmove a previously unseen pointer id; it should not be sent. |
2435 int press_id = event.touches[0].id; | 2435 int press_id = event.touches[0].pointerId; |
2436 event.MovePoint(0, 1, 1); | 2436 event.MovePoint(0, 1, 1); |
2437 event.touches[0].id = 7; | 2437 event.touches[0].pointerId = 7; |
2438 SendTouchEvent(event); | 2438 SendTouchEvent(event); |
2439 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2439 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
2440 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2440 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2441 | 2441 |
2442 // Give the touchmove a valid id; it should be sent. | 2442 // Give the touchmove a valid id; it should be sent. |
2443 event.touches[0].id = press_id; | 2443 event.touches[0].pointerId = press_id; |
2444 SendTouchEvent(event); | 2444 SendTouchEvent(event); |
2445 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2445 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2446 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2446 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2447 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2447 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2448 | 2448 |
2449 // Do the same for release. | 2449 // Do the same for release. |
2450 event.ReleasePoint(0); | 2450 event.ReleasePoint(0); |
2451 event.touches[0].id = 11; | 2451 event.touches[0].pointerId = 11; |
2452 SendTouchEvent(event); | 2452 SendTouchEvent(event); |
2453 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 2453 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
2454 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2454 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2455 | 2455 |
2456 // Give the touchmove a valid id; it should be sent. | 2456 // Give the touchmove a valid id; it should be sent. |
2457 event.touches[0].id = press_id; | 2457 event.touches[0].pointerId = press_id; |
2458 SendTouchEvent(event); | 2458 SendTouchEvent(event); |
2459 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2459 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2460 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); | 2460 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
2461 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2461 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2462 } | 2462 } |
2463 | 2463 |
2464 // Tests that touch points states are correct in TouchMove events. | 2464 // Tests that touch points states are correct in TouchMove events. |
2465 TEST_F(TouchEventQueueTest, PointerStatesInTouchMove) { | 2465 TEST_F(TouchEventQueueTest, PointerStatesInTouchMove) { |
2466 PressTouchPoint(1, 1); | 2466 PressTouchPoint(1, 1); |
2467 PressTouchPoint(2, 2); | 2467 PressTouchPoint(2, 2); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 // TouchMove should be allowed and test for touches state. | 2606 // TouchMove should be allowed and test for touches state. |
2607 const WebTouchEvent& event2 = sent_event(); | 2607 const WebTouchEvent& event2 = sent_event(); |
2608 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); | 2608 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); |
2609 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); | 2609 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); |
2610 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); | 2610 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); |
2611 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2611 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
2612 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2612 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
2613 } | 2613 } |
2614 | 2614 |
2615 } // namespace content | 2615 } // namespace content |
OLD | NEW |