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

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

Issue 290473006: Add a TouchEventStreamValidator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 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 5bac0bcb0367296c308be85656ca43e6c8c24934..1fa1a7d305ac56eb256fd0c97e53fc47f53906c6 100644
--- a/content/browser/renderer_host/input/input_router_impl_unittest.cc
+++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -241,29 +241,6 @@ class InputRouterImplTest : public testing::Test {
sourceDevice));
}
- void SimulateTouchEvent(WebInputEvent::Type type) {
- touch_event_.ResetPoints();
- int index = PressTouchPoint(0, 0);
- switch (type) {
- case WebInputEvent::TouchStart:
- // Already handled by |PressTouchPoint()|.
- break;
- case WebInputEvent::TouchMove:
- MoveTouchPoint(index, 5, 5);
- break;
- case WebInputEvent::TouchEnd:
- ReleaseTouchPoint(index);
- break;
- case WebInputEvent::TouchCancel:
- CancelTouchPoint(index);
- break;
- default:
- FAIL() << "Invalid touch event type.";
- break;
- }
- SendTouchEvent();
- }
-
void SetTouchTimestamp(base::TimeDelta timestamp) {
touch_event_.SetTimestamp(timestamp);
}
@@ -785,36 +762,34 @@ TEST_F(InputRouterImplTest, UnhandledWheelEvent) {
TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) {
OnHasTouchEventHandlers(true);
+ // Only acks for TouchCancel should always be ignored.
+ ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition(
+ GetEventWithType(WebInputEvent::TouchStart)));
+ ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition(
+ GetEventWithType(WebInputEvent::TouchMove)));
+ ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition(
+ GetEventWithType(WebInputEvent::TouchEnd)));
- int start_type = static_cast<int>(WebInputEvent::TouchStart);
- int end_type = static_cast<int>(WebInputEvent::TouchCancel);
- ASSERT_LT(start_type, end_type);
- for (int i = start_type; i <= end_type; ++i) {
- WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
- if (!WebInputEventTraits::IgnoresAckDisposition(GetEventWithType(type)))
- continue;
-
- // The TouchEventQueue requires an initial TouchStart for it to begin
- // forwarding other touch event types.
- if (type != WebInputEvent::TouchStart) {
- SimulateTouchEvent(WebInputEvent::TouchStart);
- SendInputEventACK(WebInputEvent::TouchStart,
- INPUT_EVENT_ACK_STATE_CONSUMED);
- ASSERT_EQ(1U, GetSentMessageCountAndResetSink());
- ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount());
- ASSERT_EQ(0, client_->in_flight_event_count());
- }
+ // Precede the TouchCancel with an appropriate TouchStart;
+ PressTouchPoint(1, 1);
+ SendTouchEvent();
+ SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
+ ASSERT_EQ(1U, GetSentMessageCountAndResetSink());
+ ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount());
+ ASSERT_EQ(0, client_->in_flight_event_count());
- SimulateTouchEvent(type);
- EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
- EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
- EXPECT_EQ(0, client_->in_flight_event_count());
- EXPECT_FALSE(HasPendingEvents());
- SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
- EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
- EXPECT_FALSE(HasPendingEvents());
- }
+ // The TouchCancel ack is always ignored.
+ CancelTouchPoint(0);
+ SendTouchEvent();
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
+ EXPECT_EQ(0, client_->in_flight_event_count());
+ EXPECT_FALSE(HasPendingEvents());
+ SendInputEventACK(WebInputEvent::TouchCancel,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+ EXPECT_FALSE(HasPendingEvents());
}
TEST_F(InputRouterImplTest, GestureTypesIgnoringAck) {
« no previous file with comments | « content/browser/renderer_host/input/input_router_impl.cc ('k') | content/common/input/gesture_event_stream_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698