| 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 "content/browser/renderer_host/input/touch_event_queue.h" | 5 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void ReleaseTouchPoint(int index) { | 228 void ReleaseTouchPoint(int index) { |
| 229 touch_event_.ReleasePoint(index); | 229 touch_event_.ReleasePoint(index); |
| 230 SendTouchEvent(); | 230 SendTouchEvent(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void CancelTouchPoint(int index) { | 233 void CancelTouchPoint(int index) { |
| 234 touch_event_.CancelPoint(index); | 234 touch_event_.CancelPoint(index); |
| 235 SendTouchEvent(); | 235 SendTouchEvent(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void PrependTouchScrollNotification() { |
| 239 queue_->PrependTouchScrollNotification(); |
| 240 } |
| 241 |
| 238 void AdvanceTouchTime(double seconds) { | 242 void AdvanceTouchTime(double seconds) { |
| 239 touch_event_.timeStampSeconds += seconds; | 243 touch_event_.timeStampSeconds += seconds; |
| 240 } | 244 } |
| 241 | 245 |
| 242 void ResetTouchEvent() { | 246 void ResetTouchEvent() { |
| 243 touch_event_ = SyntheticWebTouchEvent(); | 247 touch_event_ = SyntheticWebTouchEvent(); |
| 244 } | 248 } |
| 245 | 249 |
| 246 size_t GetAndResetAckedEventCount() { | 250 size_t GetAndResetAckedEventCount() { |
| 247 size_t count = acked_event_count_; | 251 size_t count = acked_event_count_; |
| (...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2610 | 2614 |
| 2611 // TouchMove should be allowed and test for touches state. | 2615 // TouchMove should be allowed and test for touches state. |
| 2612 const WebTouchEvent& event2 = sent_event(); | 2616 const WebTouchEvent& event2 = sent_event(); |
| 2613 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); | 2617 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); |
| 2614 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); | 2618 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); |
| 2615 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); | 2619 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); |
| 2616 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 2620 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 2617 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 2621 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2618 } | 2622 } |
| 2619 | 2623 |
| 2624 // Tests touch-scroll-notification firing order when the event is placed at the |
| 2625 // end of touch queue because of a pending ack for the head of the queue. |
| 2626 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_EndOfQueue) { |
| 2627 PressTouchPoint(1, 1); |
| 2628 |
| 2629 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 2630 EXPECT_EQ(1U, queued_event_count()); |
| 2631 |
| 2632 // Send the touch-scroll-notification when 3 events are in the queue. |
| 2633 PrependTouchScrollNotification(); |
| 2634 |
| 2635 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 2636 EXPECT_EQ(2U, queued_event_count()); |
| 2637 |
| 2638 // Receive an ACK for the touchstart. |
| 2639 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2640 |
| 2641 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2642 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); |
| 2643 EXPECT_EQ(1U, queued_event_count()); |
| 2644 |
| 2645 // Receive an ACK for the touch-scroll-notification. |
| 2646 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); |
| 2647 |
| 2648 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 2649 EXPECT_EQ(0U, queued_event_count()); |
| 2650 |
| 2651 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type); |
| 2652 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type); |
| 2653 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
| 2654 } |
| 2655 |
| 2656 // Tests touch-scroll-notification firing order when the event is placed in the |
| 2657 // 2nd position in the touch queue between two events. |
| 2658 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_SecondPosition) { |
| 2659 PressTouchPoint(1, 1); |
| 2660 MoveTouchPoint(0, 5, 5); |
| 2661 ReleaseTouchPoint(0); |
| 2662 |
| 2663 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 2664 EXPECT_EQ(3U, queued_event_count()); |
| 2665 |
| 2666 // Send the touch-scroll-notification when 3 events are in the queue. |
| 2667 PrependTouchScrollNotification(); |
| 2668 |
| 2669 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 2670 EXPECT_EQ(4U, queued_event_count()); |
| 2671 |
| 2672 // Receive an ACK for the touchstart. |
| 2673 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2674 |
| 2675 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2676 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type); |
| 2677 EXPECT_EQ(3U, queued_event_count()); |
| 2678 |
| 2679 // Receive an ACK for the touch-scroll-notification. |
| 2680 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED); |
| 2681 |
| 2682 EXPECT_EQ(0U, GetAndResetAckedEventCount()); |
| 2683 EXPECT_EQ(2U, queued_event_count()); |
| 2684 |
| 2685 // Receive an ACK for the touchmove. |
| 2686 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2687 |
| 2688 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2689 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type); |
| 2690 EXPECT_EQ(1U, queued_event_count()); |
| 2691 |
| 2692 // Receive an ACK for the touchend. |
| 2693 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2694 |
| 2695 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 2696 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type); |
| 2697 EXPECT_EQ(0U, queued_event_count()); |
| 2698 |
| 2699 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type); |
| 2700 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type); |
| 2701 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type); |
| 2702 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type); |
| 2703 EXPECT_EQ(4U, GetAndResetSentEventCount()); |
| 2704 } |
| 2705 |
| 2620 } // namespace content | 2706 } // namespace content |
| OLD | NEW |