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

Unified Diff: content/browser/renderer_host/input/touch_event_queue_unittest.cc

Issue 1050993004: Route touchmove existence notifications to the TouchEventQueue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/touch_event_queue_unittest.cc
diff --git a/content/browser/renderer_host/input/touch_event_queue_unittest.cc b/content/browser/renderer_host/input/touch_event_queue_unittest.cc
index e322a5f23f9ea72d88e404a010f65b017079097f..682472aed5b8c5b65b7f54c67907b5a9b34f4281 100644
--- a/content/browser/renderer_host/input/touch_event_queue_unittest.cc
+++ b/content/browser/renderer_host/input/touch_event_queue_unittest.cc
@@ -258,6 +258,10 @@ class TouchEventQueueTest : public testing::Test,
queue_->OnHasTouchEventHandlers(has_handlers);
}
+ void OnHasTouchMoveEventHandlers(bool has_handlers) {
+ queue_->OnHasTouchMoveEventHandlers(has_handlers);
+ }
+
void SetAckTimeoutDisabled() { queue_->SetAckTimeoutEnabled(false); }
void SetIsMobileOptimizedSite(bool is_mobile_optimized) {
@@ -316,6 +320,7 @@ class TouchEventQueueTest : public testing::Test,
void ResetQueueWithConfig(const TouchEventQueue::Config& config) {
queue_.reset(new TouchEventQueue(this, config));
queue_->OnHasTouchEventHandlers(true);
+ queue_->OnHasTouchMoveEventHandlers(true);
}
scoped_ptr<TouchEventQueue> queue_;
@@ -579,6 +584,37 @@ TEST_F(TouchEventQueueTest,
EXPECT_EQ(1U, queued_event_count());
}
+TEST_F(TouchEventQueueTest, TouchMoveNotForwardedIfNoTouchMoveHandlers) {
+ OnHasTouchEventHandlers(true);
+ OnHasTouchMoveEventHandlers(false);
+
+ // Send a touch-press event.
+ PressTouchPoint(1, 1);
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+
+ // As there are no touchmove handlers, touchmoves should not be forwarded.
+ MoveTouchPoint(0, 5, 5);
+ EXPECT_EQ(0U, queued_event_count());
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+ EXPECT_EQ(0U, GetAndResetSentEventCount());
+ EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, acked_event_state());
+
+ // If a touchmove handler is added, we should resume forwarding touchmove's
+ // (even if we've dropped previous touchmoves).
+ OnHasTouchMoveEventHandlers(true);
+ MoveTouchPoint(0, 50, 50);
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+
+ ReleaseTouchPoint(0);
+ EXPECT_EQ(1U, GetAndResetSentEventCount());
+ SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(1U, GetAndResetAckedEventCount());
+}
+
// Tests that touch-events are coalesced properly in the queue.
TEST_F(TouchEventQueueTest, Coalesce) {
// Send a touch-press event.
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.cc ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698