| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <new> | 7 #include <new> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 336 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 337 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 337 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 338 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 338 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 339 | 339 |
| 340 EXPECT_EQ(2u, event_queue().size()); | 340 EXPECT_EQ(2u, event_queue().size()); |
| 341 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 341 EXPECT_TRUE(main_task_runner_->HasPendingTask()); |
| 342 RunPendingTasksWithSimulatedRaf(); | 342 RunPendingTasksWithSimulatedRaf(); |
| 343 | 343 |
| 344 EXPECT_EQ(0u, event_queue().size()); | 344 EXPECT_EQ(0u, event_queue().size()); |
| 345 EXPECT_EQ(2u, additional_acked_events_.size()); | 345 EXPECT_EQ(2u, additional_acked_events_.size()); |
| 346 EXPECT_EQ(kEvents[2].uniqueTouchEventId, additional_acked_events_.at(0)); | 346 EXPECT_EQ(kEvents[1].uniqueTouchEventId, additional_acked_events_.at(0)); |
| 347 EXPECT_EQ(kEvents[3].uniqueTouchEventId, additional_acked_events_.at(1)); | 347 EXPECT_EQ(kEvents[2].uniqueTouchEventId, additional_acked_events_.at(1)); |
| 348 |
| 349 const WebTouchEvent* last_touch_event = |
| 350 static_cast<const WebTouchEvent*>(handled_events_.at(1).eventPointer()); |
| 351 EXPECT_EQ(kEvents[3].uniqueTouchEventId, |
| 352 last_touch_event->uniqueTouchEventId); |
| 348 | 353 |
| 349 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 354 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 350 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 355 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 351 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 356 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 352 EXPECT_EQ(1u, event_queue().size()); | 357 EXPECT_EQ(1u, event_queue().size()); |
| 353 RunPendingTasksWithSimulatedRaf(); | 358 RunPendingTasksWithSimulatedRaf(); |
| 354 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 2); | 359 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 2); |
| 355 } | 360 } |
| 356 | 361 |
| 357 TEST_P(MainThreadEventQueueTest, InterleavedEvents) { | 362 TEST_P(MainThreadEventQueueTest, InterleavedEvents) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 SyntheticWebTouchEvent kEvents[2]; | 530 SyntheticWebTouchEvent kEvents[2]; |
| 526 kEvents[0].PressPoint(10, 10); | 531 kEvents[0].PressPoint(10, 10); |
| 527 kEvents[0].MovePoint(0, 50, 50); | 532 kEvents[0].MovePoint(0, 50, 50); |
| 528 kEvents[1].PressPoint(10, 10); | 533 kEvents[1].PressPoint(10, 10); |
| 529 kEvents[1].MovePoint(0, 20, 20); | 534 kEvents[1].MovePoint(0, 20, 20); |
| 530 kEvents[0].dispatchType = WebInputEvent::EventNonBlocking; | 535 kEvents[0].dispatchType = WebInputEvent::EventNonBlocking; |
| 531 | 536 |
| 532 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | 537 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
| 533 EXPECT_EQ(0u, event_queue().size()); | 538 EXPECT_EQ(0u, event_queue().size()); |
| 534 | 539 |
| 535 // Send a continuous input event (ack required) and then | 540 // Send a discrete input event and then a continuous |
| 536 // a discrete event. The events should coalesce together | 541 // (ack required) event. The events should coalesce together |
| 537 // and a post task should be on the queue at the end. | 542 // and a post task should be on the queue at the end. |
| 543 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 544 EXPECT_EQ(1u, event_queue().size()); |
| 545 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
| 546 EXPECT_TRUE(needs_main_frame_); |
| 538 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 547 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 539 EXPECT_EQ(1u, event_queue().size()); | 548 EXPECT_EQ(1u, event_queue().size()); |
| 540 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | 549 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
| 541 EXPECT_TRUE(needs_main_frame_); | 550 EXPECT_TRUE(needs_main_frame_); |
| 542 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 543 EXPECT_EQ(1u, event_queue().size()); | |
| 544 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | |
| 545 EXPECT_TRUE(needs_main_frame_); | |
| 546 RunPendingTasksWithSimulatedRaf(); | 551 RunPendingTasksWithSimulatedRaf(); |
| 547 EXPECT_EQ(0u, event_queue().size()); | 552 EXPECT_EQ(0u, event_queue().size()); |
| 548 EXPECT_EQ(1u, additional_acked_events_.size()); | 553 EXPECT_EQ(1u, additional_acked_events_.size()); |
| 549 additional_acked_events_.clear(); | 554 additional_acked_events_.clear(); |
| 550 | 555 |
| 551 // Send a non-cancelable ack required event, and then a non-ack | 556 // Send a non-cancelable ack required event, and then a non-ack |
| 552 // required event they should be coalesced together. | 557 // required event they should be coalesced together. |
| 553 EXPECT_TRUE(HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 558 EXPECT_TRUE(HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
| 554 EXPECT_EQ(1u, event_queue().size()); | 559 EXPECT_EQ(1u, event_queue().size()); |
| 555 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | 560 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 "MainThreadResponsivenessScrollIntervention", "Control"); | 775 "MainThreadResponsivenessScrollIntervention", "Control"); |
| 771 queue_ = new MainThreadEventQueue(kTestRoutingID, | 776 queue_ = new MainThreadEventQueue(kTestRoutingID, |
| 772 &dummy_main_thread_event_queue_client_, | 777 &dummy_main_thread_event_queue_client_, |
| 773 main_task_runner_, &renderer_scheduler_); | 778 main_task_runner_, &renderer_scheduler_); |
| 774 EXPECT_FALSE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); | 779 EXPECT_FALSE(enable_non_blocking_due_to_main_thread_responsiveness_flag()); |
| 775 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0), | 780 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0), |
| 776 main_thread_responsiveness_threshold()); | 781 main_thread_responsiveness_threshold()); |
| 777 } | 782 } |
| 778 | 783 |
| 779 } // namespace content | 784 } // namespace content |
| OLD | NEW |