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/touch_event_queue.h" | 8 #include "content/browser/renderer_host/input/touch_event_queue.h" |
9 #include "content/common/input/synthetic_web_input_event_builders.h" | 9 #include "content/common/input/synthetic_web_input_event_builders.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 acked_event_count_ = 0; | 120 acked_event_count_ = 0; |
121 return count; | 121 return count; |
122 } | 122 } |
123 | 123 |
124 size_t GetAndResetSentEventCount() { | 124 size_t GetAndResetSentEventCount() { |
125 size_t count = sent_event_count_; | 125 size_t count = sent_event_count_; |
126 sent_event_count_ = 0; | 126 sent_event_count_ = 0; |
127 return count; | 127 return count; |
128 } | 128 } |
129 | 129 |
| 130 bool IsPendingAckTouchStart() const { |
| 131 return queue_->IsPendingAckTouchStart(); |
| 132 } |
| 133 |
130 void Flush() { | 134 void Flush() { |
131 queue_->FlushQueue(); | 135 queue_->FlushQueue(); |
132 } | 136 } |
133 | 137 |
134 size_t queued_event_count() const { | 138 size_t queued_event_count() const { |
135 return queue_->GetQueueSize(); | 139 return queue_->GetQueueSize(); |
136 } | 140 } |
137 | 141 |
138 const WebTouchEvent& latest_event() const { | 142 const WebTouchEvent& latest_event() const { |
139 return queue_->GetLatestEvent().event; | 143 return queue_->GetLatestEvent().event; |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 833 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
830 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 834 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
831 | 835 |
832 ReleaseTouchPoint(0); | 836 ReleaseTouchPoint(0); |
833 SendTouchEvent(); | 837 SendTouchEvent(); |
834 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 838 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
835 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 839 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
836 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 840 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
837 } | 841 } |
838 | 842 |
| 843 // Tests that IsTouchStartPendingAck works correctly. |
| 844 TEST_F(TouchEventQueueTest, PendingStart) { |
| 845 |
| 846 EXPECT_FALSE(IsPendingAckTouchStart()); |
| 847 |
| 848 // Send the touchstart for one point (#1). |
| 849 PressTouchPoint(1, 1); |
| 850 SendTouchEvent(); |
| 851 EXPECT_EQ(1U, queued_event_count()); |
| 852 EXPECT_TRUE(IsPendingAckTouchStart()); |
| 853 |
| 854 // Send a touchmove for that point (#2). |
| 855 MoveTouchPoint(0, 5, 5); |
| 856 SendTouchEvent(); |
| 857 EXPECT_EQ(2U, queued_event_count()); |
| 858 EXPECT_TRUE(IsPendingAckTouchStart()); |
| 859 |
| 860 // Ack the touchstart (#1). |
| 861 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 862 EXPECT_EQ(1U, queued_event_count()); |
| 863 EXPECT_FALSE(IsPendingAckTouchStart()); |
| 864 |
| 865 // Send a touchstart for another point (#3). |
| 866 PressTouchPoint(10, 10); |
| 867 SendTouchEvent(); |
| 868 EXPECT_EQ(2U, queued_event_count()); |
| 869 EXPECT_FALSE(IsPendingAckTouchStart()); |
| 870 |
| 871 // Ack the touchmove (#2). |
| 872 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 873 EXPECT_EQ(1U, queued_event_count()); |
| 874 EXPECT_TRUE(IsPendingAckTouchStart()); |
| 875 |
| 876 // Send a touchstart for a third point (#4). |
| 877 PressTouchPoint(15, 15); |
| 878 SendTouchEvent(); |
| 879 EXPECT_EQ(2U, queued_event_count()); |
| 880 EXPECT_TRUE(IsPendingAckTouchStart()); |
| 881 |
| 882 // Ack the touchstart for the second point (#3). |
| 883 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 884 EXPECT_EQ(1U, queued_event_count()); |
| 885 EXPECT_TRUE(IsPendingAckTouchStart()); |
| 886 |
| 887 // Ack the touchstart for the third point (#4). |
| 888 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 889 EXPECT_EQ(0U, queued_event_count()); |
| 890 EXPECT_FALSE(IsPendingAckTouchStart()); |
| 891 } |
| 892 |
839 } // namespace content | 893 } // namespace content |
OLD | NEW |