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

Unified Diff: content/renderer/input/main_thread_event_queue_unittest.cc

Issue 2471523002: Make touch events uncancelable during fling when they are on the current active scroll layer (Closed)
Patch Set: clean up code Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/input/main_thread_event_queue_unittest.cc
diff --git a/content/renderer/input/main_thread_event_queue_unittest.cc b/content/renderer/input/main_thread_event_queue_unittest.cc
index 1f8c2a833b04d13910c33d3ec05ad675dc747aba..3bef2d37d94b4cdf134f8f24770fa873cf6a623f 100644
--- a/content/renderer/input/main_thread_event_queue_unittest.cc
+++ b/content/renderer/input/main_thread_event_queue_unittest.cc
@@ -96,10 +96,6 @@ class MainThreadEventQueueTest : public testing::TestWithParam<unsigned>,
return queue_->shared_state_.events_;
}
- void set_is_flinging(bool is_flinging) {
- queue_->set_is_flinging(is_flinging);
- }
-
bool last_touch_start_forced_nonblocking_due_to_fling() {
return queue_->last_touch_start_forced_nonblocking_due_to_fling_;
}
@@ -435,144 +431,130 @@ TEST_P(MainThreadEventQueueTest, RafAlignedTouchInput) {
}
TEST_P(MainThreadEventQueueTest, BlockingTouchesDuringFling) {
- SyntheticWebTouchEvent kEvents[1];
- kEvents[0].PressPoint(10, 10);
- kEvents[0].touchStartOrFirstTouchMove = true;
- set_is_flinging(true);
+ SyntheticWebTouchEvent kEvents;
+ kEvents.PressPoint(10, 10);
+ kEvents.touchStartOrFirstTouchMove = true;
set_enable_fling_passive_listener_flag(true);
EXPECT_FALSE(last_touch_start_forced_nonblocking_due_to_fling());
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED_NON_BLOCKING);
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(1u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(0)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(0)->type);
+ EXPECT_EQ(kEvents.size, handled_events_.at(0)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(0)->type);
EXPECT_TRUE(last_touch_start_forced_nonblocking_due_to_fling());
const WebTouchEvent* last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(0).get());
- kEvents[0].dispatchedDuringFling = true;
- kEvents[0].dispatchType = WebInputEvent::ListenersForcedNonBlockingDueToFling;
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ kEvents.dispatchType = WebInputEvent::ListenersForcedNonBlockingDueToFling;
+ EXPECT_EQ(kEvents, *last_touch_event);
- kEvents[0].MovePoint(0, 30, 30);
+ kEvents.MovePoint(0, 30, 30);
EXPECT_FALSE(main_task_runner_->HasPendingTask());
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED_NON_BLOCKING);
EXPECT_EQ((raf_aligned_input_setting_ & kRafAlignedEnabledTouch) == 0,
main_task_runner_->HasPendingTask());
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(2u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(1)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(1)->type);
+ EXPECT_EQ(kEvents.size, handled_events_.at(1)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(1)->type);
EXPECT_TRUE(last_touch_start_forced_nonblocking_due_to_fling());
last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(1).get());
- kEvents[0].dispatchedDuringFling = true;
- kEvents[0].dispatchType = WebInputEvent::ListenersForcedNonBlockingDueToFling;
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ kEvents.dispatchType = WebInputEvent::ListenersForcedNonBlockingDueToFling;
+ EXPECT_EQ(kEvents, *last_touch_event);
- kEvents[0].MovePoint(0, 50, 50);
- kEvents[0].touchStartOrFirstTouchMove = false;
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ kEvents.MovePoint(0, 50, 50);
+ kEvents.touchStartOrFirstTouchMove = false;
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED_NON_BLOCKING);
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(3u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(2)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(2)->type);
- EXPECT_TRUE(kEvents[0].dispatchedDuringFling);
- EXPECT_EQ(kEvents[0].dispatchType, WebInputEvent::Blocking);
+ EXPECT_EQ(kEvents.size, handled_events_.at(2)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(2)->type);
+ EXPECT_EQ(kEvents.dispatchType, WebInputEvent::Blocking);
last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(2).get());
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ EXPECT_EQ(kEvents, *last_touch_event);
- kEvents[0].ReleasePoint(0);
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ kEvents.ReleasePoint(0);
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED_NON_BLOCKING);
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(4u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(3)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(3)->type);
- EXPECT_TRUE(kEvents[0].dispatchedDuringFling);
- EXPECT_EQ(kEvents[0].dispatchType, WebInputEvent::Blocking);
+ EXPECT_EQ(kEvents.size, handled_events_.at(3)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(3)->type);
+ EXPECT_EQ(kEvents.dispatchType, WebInputEvent::Blocking);
last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(3).get());
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ EXPECT_EQ(kEvents, *last_touch_event);
}
TEST_P(MainThreadEventQueueTest, BlockingTouchesOutsideFling) {
- SyntheticWebTouchEvent kEvents[1];
- kEvents[0].PressPoint(10, 10);
- kEvents[0].touchStartOrFirstTouchMove = true;
- set_is_flinging(false);
+ SyntheticWebTouchEvent kEvents;
+ kEvents.PressPoint(10, 10);
+ kEvents.touchStartOrFirstTouchMove = true;
set_enable_fling_passive_listener_flag(false);
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(1u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(0)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(0)->type);
- EXPECT_FALSE(kEvents[0].dispatchedDuringFling);
- EXPECT_EQ(kEvents[0].dispatchType, WebInputEvent::Blocking);
+ EXPECT_EQ(kEvents.size, handled_events_.at(0)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(0)->type);
+ EXPECT_EQ(kEvents.dispatchType, WebInputEvent::Blocking);
EXPECT_FALSE(last_touch_start_forced_nonblocking_due_to_fling());
const WebTouchEvent* last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(0).get());
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ EXPECT_EQ(kEvents, *last_touch_event);
- set_is_flinging(true);
set_enable_fling_passive_listener_flag(false);
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(2u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(1)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(1)->type);
- EXPECT_FALSE(kEvents[0].dispatchedDuringFling);
- EXPECT_EQ(kEvents[0].dispatchType, WebInputEvent::Blocking);
+ EXPECT_EQ(kEvents.size, handled_events_.at(1)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(1)->type);
+ EXPECT_EQ(kEvents.dispatchType, WebInputEvent::Blocking);
EXPECT_FALSE(last_touch_start_forced_nonblocking_due_to_fling());
last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(1).get());
- kEvents[0].dispatchedDuringFling = true;
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ EXPECT_EQ(kEvents, *last_touch_event);
- set_is_flinging(false);
set_enable_fling_passive_listener_flag(true);
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(3u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(2)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(2)->type);
- EXPECT_TRUE(kEvents[0].dispatchedDuringFling);
- EXPECT_EQ(kEvents[0].dispatchType, WebInputEvent::Blocking);
+ EXPECT_EQ(kEvents.size, handled_events_.at(2)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(2)->type);
+ EXPECT_EQ(kEvents.dispatchType, WebInputEvent::Blocking);
EXPECT_FALSE(last_touch_start_forced_nonblocking_due_to_fling());
last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(2).get());
- kEvents[0].dispatchedDuringFling = false;
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ EXPECT_EQ(kEvents, *last_touch_event);
- kEvents[0].MovePoint(0, 30, 30);
- HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ kEvents.MovePoint(0, 30, 30);
+ HandleEvent(kEvents, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
RunPendingTasksWithSimulatedRaf();
EXPECT_FALSE(main_task_runner_->HasPendingTask());
EXPECT_EQ(0u, event_queue().size());
EXPECT_EQ(4u, handled_events_.size());
- EXPECT_EQ(kEvents[0].size, handled_events_.at(3)->size);
- EXPECT_EQ(kEvents[0].type, handled_events_.at(3)->type);
- EXPECT_FALSE(kEvents[0].dispatchedDuringFling);
- EXPECT_EQ(kEvents[0].dispatchType, WebInputEvent::Blocking);
+ EXPECT_EQ(kEvents.size, handled_events_.at(3)->size);
+ EXPECT_EQ(kEvents.type, handled_events_.at(3)->type);
+ EXPECT_EQ(kEvents.dispatchType, WebInputEvent::Blocking);
EXPECT_FALSE(last_touch_start_forced_nonblocking_due_to_fling());
last_touch_event =
static_cast<const WebTouchEvent*>(handled_events_.at(3).get());
- EXPECT_EQ(kEvents[0], *last_touch_event);
+ EXPECT_EQ(kEvents, *last_touch_event);
}
// The boolean parameterized test varies whether rAF aligned input

Powered by Google App Engine
This is Rietveld 408576698