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

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

Issue 2765583002: Teach main thread event queue about closures. (Closed)
Patch Set: Fix build Created 3 years, 9 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/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 21771186dc1df58896825851333af182ac9a73c5..2d873ffc04452b0aaf2e6747f1ddcc39fc4d3d4e 100644
--- a/content/renderer/input/main_thread_event_queue_unittest.cc
+++ b/content/renderer/input/main_thread_event_queue_unittest.cc
@@ -108,7 +108,7 @@ class MainThreadEventQueueTest : public testing::TestWithParam<unsigned>,
void NeedsMainFrame(int routing_id) override { needs_main_frame_ = true; }
- WebInputEventQueue<EventWithDispatchType>& event_queue() {
+ MainThreadEventQueueTaskList& event_queue() {
return queue_->shared_state_.events_;
}
@@ -440,9 +440,10 @@ TEST_P(MainThreadEventQueueTest, RafAlignedMouseInput) {
WebMouseEvent mouseUp =
SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseUp, 10, 10, 0);
- WebMouseWheelEvent wheelEvents[2] = {
+ WebMouseWheelEvent wheelEvents[3] = {
SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false),
SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 0, false),
+ SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 1, false),
};
EXPECT_FALSE(main_task_runner_->HasPendingTask());
@@ -465,20 +466,35 @@ TEST_P(MainThreadEventQueueTest, RafAlignedMouseInput) {
EXPECT_EQ(0u, event_queue().size());
RunPendingTasksWithSimulatedRaf();
- // Simulate the rAF running before the PostTask occurs. The first rAF
- // shouldn't do anything.
+ // Simulate the rAF running before the PostTask occurs. The rAF
+ // will consume everything.
HandleEvent(mouseDown, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
EXPECT_EQ(2u, event_queue().size());
EXPECT_TRUE(needs_main_frame_);
RunSimulatedRafOnce();
EXPECT_FALSE(needs_main_frame_);
- EXPECT_EQ(2u, event_queue().size());
+ EXPECT_EQ(0u, event_queue().size());
main_task_runner_->RunUntilIdle();
+
+ // Simulate event consumption but no rAF signal. The mouse wheel events
+ // should still be in the queue.
+ handled_events_.clear();
+ HandleEvent(mouseDown, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
+ HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
+ HandleEvent(mouseUp, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
+ HandleEvent(wheelEvents[2], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
+ HandleEvent(wheelEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
+ EXPECT_EQ(5u, event_queue().size());
EXPECT_TRUE(needs_main_frame_);
- EXPECT_EQ(1u, event_queue().size());
- RunPendingTasksWithSimulatedRaf();
- EXPECT_EQ(0u, event_queue().size());
+ main_task_runner_->RunUntilIdle();
+ EXPECT_TRUE(needs_main_frame_);
+ EXPECT_EQ(2u, event_queue().size());
+ RunSimulatedRafOnce();
+ EXPECT_EQ(wheelEvents[2].modifiers(),
+ handled_events_.at(3).event().modifiers());
+ EXPECT_EQ(wheelEvents[0].modifiers(),
+ handled_events_.at(4).event().modifiers());
}
TEST_P(MainThreadEventQueueTest, RafAlignedTouchInput) {
@@ -510,17 +526,28 @@ TEST_P(MainThreadEventQueueTest, RafAlignedTouchInput) {
EXPECT_EQ(0u, event_queue().size());
RunPendingTasksWithSimulatedRaf();
- // Simulate the rAF running before the PostTask occurs. The first rAF
- // shouldn't do anything.
+ // Simulate the rAF running before the PostTask occurs. The rAF
+ // will consume everything.
HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
EXPECT_EQ(2u, event_queue().size());
EXPECT_TRUE(needs_main_frame_);
RunSimulatedRafOnce();
EXPECT_FALSE(needs_main_frame_);
- EXPECT_EQ(2u, event_queue().size());
- RunPendingTasksWithSimulatedRaf();
EXPECT_EQ(0u, event_queue().size());
+ main_task_runner_->RunUntilIdle();
+
+ // Simulate event consumption but no rAF signal. The touch events
+ // should still be in the queue.
+ handled_events_.clear();
+ HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
+ HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING);
+ EXPECT_EQ(2u, event_queue().size());
+ EXPECT_TRUE(needs_main_frame_);
+ main_task_runner_->RunUntilIdle();
+ EXPECT_TRUE(needs_main_frame_);
+ EXPECT_EQ(1u, event_queue().size());
+ RunSimulatedRafOnce();
// Simulate the touch move being discrete
kEvents[0].touchStartOrFirstTouchMove = true;

Powered by Google App Engine
This is Rietveld 408576698