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

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

Issue 67383002: Initial browser-side implementation for touch-action (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for new blink API - no touch ID for now Created 7 years, 1 month 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 | Annotate | Revision Log
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/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
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() const {
121 return queue_->IsPendingAckTouchStart();
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
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());
791
792 // Send the touchstart for one point (#1).
793 PressTouchPoint(1, 1);
794 SendTouchEvent();
795 EXPECT_EQ(1U, queued_event_count());
796 EXPECT_TRUE(IsPendingAckTouchStart());
797
798 // Send a touchmove for that point (#2).
799 MoveTouchPoint(0, 5, 5);
800 SendTouchEvent();
801 EXPECT_EQ(2U, queued_event_count());
802 EXPECT_TRUE(IsPendingAckTouchStart());
803
804 // Ack the touchstart (#1).
805 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
806 EXPECT_EQ(1U, queued_event_count());
807 EXPECT_FALSE(IsPendingAckTouchStart());
808
809 // Send a touchstart for another point (#3).
810 PressTouchPoint(10, 10);
811 SendTouchEvent();
812 EXPECT_EQ(2U, queued_event_count());
813 EXPECT_FALSE(IsPendingAckTouchStart());
814
815 // Ack the touchmove (#2).
816 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
817 EXPECT_EQ(1U, queued_event_count());
818 EXPECT_TRUE(IsPendingAckTouchStart());
819
820 // Send a touchstart for a third point (#4).
821 PressTouchPoint(15, 15);
822 SendTouchEvent();
823 EXPECT_EQ(2U, queued_event_count());
824 EXPECT_TRUE(IsPendingAckTouchStart());
825
826 // Ack the touchstart for the second point (#3).
827 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
828 EXPECT_EQ(1U, queued_event_count());
829 EXPECT_TRUE(IsPendingAckTouchStart());
830
831 // Ack the touchstart for the third point (#4).
832 SendTouchEventACK(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
833 EXPECT_EQ(0U, queued_event_count());
834 EXPECT_FALSE(IsPendingAckTouchStart());
835 }
836
783 } // namespace content 837 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698