| 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/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "content/browser/renderer_host/input/synthetic_web_input_event_builders
.h" | 8 #include "content/browser/renderer_host/input/synthetic_web_input_event_builders
.h" |
| 9 #include "content/browser/renderer_host/input/touch_event_queue.h" | 9 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 acked_event_count_ = 0; | 110 acked_event_count_ = 0; |
| 111 return count; | 111 return count; |
| 112 } | 112 } |
| 113 | 113 |
| 114 size_t GetAndResetSentEventCount() { | 114 size_t GetAndResetSentEventCount() { |
| 115 size_t count = sent_event_count_; | 115 size_t count = sent_event_count_; |
| 116 sent_event_count_ = 0; | 116 sent_event_count_ = 0; |
| 117 return count; | 117 return count; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool IsPendingAckTouchStart(int touch_id) const { |
| 121 return queue_->IsPendingAckTouchStart(touch_id); |
| 122 } |
| 123 |
| 120 void Flush() { | 124 void Flush() { |
| 121 queue_->FlushQueue(); | 125 queue_->FlushQueue(); |
| 122 } | 126 } |
| 123 | 127 |
| 124 size_t queued_event_count() const { | 128 size_t queued_event_count() const { |
| 125 return queue_->GetQueueSize(); | 129 return queue_->GetQueueSize(); |
| 126 } | 130 } |
| 127 | 131 |
| 128 const WebTouchEvent& latest_event() const { | 132 const WebTouchEvent& latest_event() const { |
| 129 return queue_->GetLatestEvent().event; | 133 return queue_->GetLatestEvent().event; |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 777 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 774 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 778 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 775 | 779 |
| 776 ReleaseTouchPoint(0); | 780 ReleaseTouchPoint(0); |
| 777 SendTouchEvent(); | 781 SendTouchEvent(); |
| 778 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 782 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 779 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 783 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 780 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 784 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 781 } | 785 } |
| 782 | 786 |
| 787 // Tests that IsTouchStartPendingAck works correctly. |
| 788 TEST_F(TouchEventQueueTest, PendingStart) { |
| 789 |
| 790 EXPECT_FALSE(IsPendingAckTouchStart(0)); |
| 791 |
| 792 // Send the touchstart for id 0. |
| 793 PressTouchPoint(1, 1); |
| 794 SendTouchEvent(); |
| 795 EXPECT_EQ(1U, queued_event_count()); |
| 796 EXPECT_TRUE(IsPendingAckTouchStart(0)); |
| 797 EXPECT_FALSE(IsPendingAckTouchStart(1)); |
| 798 |
| 799 // Send a touchmove for id 0. |
| 800 MoveTouchPoint(0, 5, 5); |
| 801 SendTouchEvent(); |
| 802 EXPECT_EQ(2U, queued_event_count()); |
| 803 EXPECT_TRUE(IsPendingAckTouchStart(0)); |
| 804 EXPECT_FALSE(IsPendingAckTouchStart(1)); |
| 805 |
| 806 // Ack the touchstart for id 0. |
| 807 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 808 EXPECT_EQ(1U, queued_event_count()); |
| 809 EXPECT_FALSE(IsPendingAckTouchStart(0)); |
| 810 |
| 811 // Send a touchstart for id 1. |
| 812 PressTouchPoint(10, 10); |
| 813 SendTouchEvent(); |
| 814 EXPECT_EQ(2U, queued_event_count()); |
| 815 EXPECT_FALSE(IsPendingAckTouchStart(0)); |
| 816 EXPECT_FALSE(IsPendingAckTouchStart(1)); |
| 817 EXPECT_FALSE(IsPendingAckTouchStart(2)); |
| 818 |
| 819 // Ack the touchmove for id 0. |
| 820 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 821 EXPECT_EQ(1U, queued_event_count()); |
| 822 EXPECT_FALSE(IsPendingAckTouchStart(0)); |
| 823 EXPECT_TRUE(IsPendingAckTouchStart(1)); |
| 824 EXPECT_FALSE(IsPendingAckTouchStart(2)); |
| 825 |
| 826 // Send a touchstart for id 2. |
| 827 PressTouchPoint(15, 15); |
| 828 SendTouchEvent(); |
| 829 EXPECT_EQ(2U, queued_event_count()); |
| 830 EXPECT_FALSE(IsPendingAckTouchStart(0)); |
| 831 EXPECT_TRUE(IsPendingAckTouchStart(1)); |
| 832 EXPECT_FALSE(IsPendingAckTouchStart(2)); |
| 833 |
| 834 // Ack the touchstart for id 1. |
| 835 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 836 EXPECT_EQ(1U, queued_event_count()); |
| 837 EXPECT_FALSE(IsPendingAckTouchStart(0)); |
| 838 EXPECT_FALSE(IsPendingAckTouchStart(1)); |
| 839 EXPECT_TRUE(IsPendingAckTouchStart(2)); |
| 840 |
| 841 // Ack the touchstart for id 2. |
| 842 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 843 EXPECT_EQ(0U, queued_event_count()); |
| 844 EXPECT_FALSE(IsPendingAckTouchStart(0)); |
| 845 EXPECT_FALSE(IsPendingAckTouchStart(1)); |
| 846 EXPECT_FALSE(IsPendingAckTouchStart(2)); |
| 847 } |
| 848 |
| 783 } // namespace content | 849 } // namespace content |
| OLD | NEW |