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

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

Issue 171283002: Always reset touch action at the beginning of a new gesture sequence (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address rbyers' comments. Created 6 years, 10 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/input_router_impl_unittest.cc
diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc
index ff3baafe84f992f4552cfd972acf0f6e1d0887d6..de80c068b822e8273df871ce6fd53a89a2d2b524 100644
--- a/content/browser/renderer_host/input/input_router_impl_unittest.cc
+++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -14,6 +14,7 @@
#include "content/common/content_constants_internal.h"
#include "content/common/edit_command.h"
#include "content/common/input/synthetic_web_input_event_builders.h"
+#include "content/common/input/touch_action.h"
#include "content/common/input/web_input_event_traits.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
@@ -274,6 +275,11 @@ class InputRouterImplTest : public testing::Test {
ViewHostMsg_HasTouchEventHandlers(0, has_handlers));
}
+ void OnSetTouchAction(content::TouchAction touch_action) {
+ input_router_->OnMessageReceived(
+ InputHostMsg_SetTouchAction(0, touch_action));
+ }
+
size_t GetSentMessageCountAndResetSink() {
size_t count = process_->sink().message_count();
process_->sink().ClearMessages();
@@ -955,4 +961,57 @@ TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) {
EXPECT_TRUE(TouchEventTimeoutEnabled());
}
+// Test that TouchActionFilter::OnStartNewTouchSequence is called before the
+// first touch event for a touch sequence reaches the renderer.
+TEST_F(InputRouterImplTest, OnStartNewTouchSequenceBeforeEventReachesRenderer) {
+ OnHasTouchEventHandlers(true);
+
+ // Sequence 1.
+ PressTouchPoint(1, 1);
+ SendTouchEvent();
+ OnSetTouchAction(TouchAction::TOUCH_ACTION_NONE);
+ MoveTouchPoint(0, 5, 5);
+ SendTouchEvent();
+ ReleaseTouchPoint(0);
+ SendTouchEvent();
+
+ // Sequence 2.
+ PressTouchPoint(1, 1);
+ SendTouchEvent();
+ MoveTouchPoint(0, 5, 5);
+ SendTouchEvent();
+ ReleaseTouchPoint(0);
+ SendTouchEvent();
+
+ SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
+ SendInputEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED);
+
+ // Ensure touch action is still none, as the next touch start hasn't been
+ // acked yet. ScrollBegin and ScrollEnd don't require acks.
+ EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
+ SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+
+ // This allows the next touch sequence to start.
+ SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED);
+
+ // Ensure touch action has been set to auto, as a new touch sequence has
+ // started.
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
+ WebGestureEvent::Touchpad);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+
+ SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
+ SendInputEventACK(WebInputEvent::TouchMove, INPUT_EVENT_ACK_STATE_CONSUMED);
+ SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698