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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 EXPECT_EQ(0u, event_queue().size()); | 259 EXPECT_EQ(0u, event_queue().size()); |
260 EXPECT_EQ(2u, additional_acked_events_.size()); | 260 EXPECT_EQ(2u, additional_acked_events_.size()); |
261 EXPECT_EQ(kEvents[2].uniqueTouchEventId, additional_acked_events_.at(0)); | 261 EXPECT_EQ(kEvents[2].uniqueTouchEventId, additional_acked_events_.at(0)); |
262 EXPECT_EQ(kEvents[3].uniqueTouchEventId, additional_acked_events_.at(1)); | 262 EXPECT_EQ(kEvents[3].uniqueTouchEventId, additional_acked_events_.at(1)); |
263 | 263 |
264 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 264 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
265 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 265 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
266 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 266 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
267 EXPECT_EQ(1u, event_queue().size()); | 267 EXPECT_EQ(1u, event_queue().size()); |
268 RunPendingTasksWithSimulatedRaf(); | 268 RunPendingTasksWithSimulatedRaf(); |
269 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 1); | 269 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 2); |
270 } | 270 } |
271 | 271 |
272 TEST_P(MainThreadEventQueueTest, InterleavedEvents) { | 272 TEST_P(MainThreadEventQueueTest, InterleavedEvents) { |
273 WebMouseWheelEvent kWheelEvents[2] = { | 273 WebMouseWheelEvent kWheelEvents[2] = { |
274 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false), | 274 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false), |
275 SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 0, false), | 275 SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 0, false), |
276 }; | 276 }; |
277 SyntheticWebTouchEvent kTouchEvents[2]; | 277 SyntheticWebTouchEvent kTouchEvents[2]; |
278 kTouchEvents[0].PressPoint(10, 10); | 278 kTouchEvents[0].PressPoint(10, 10); |
279 kTouchEvents[0].MovePoint(0, 20, 20); | 279 kTouchEvents[0].MovePoint(0, 20, 20); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 420 |
421 // Simulate the touch move being discrete | 421 // Simulate the touch move being discrete |
422 kEvents[0].touchStartOrFirstTouchMove = true; | 422 kEvents[0].touchStartOrFirstTouchMove = true; |
423 kEvents[1].touchStartOrFirstTouchMove = true; | 423 kEvents[1].touchStartOrFirstTouchMove = true; |
424 | 424 |
425 for (SyntheticWebTouchEvent& event : kEvents) | 425 for (SyntheticWebTouchEvent& event : kEvents) |
426 HandleEvent(event, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 426 HandleEvent(event, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
427 | 427 |
428 EXPECT_EQ(3u, event_queue().size()); | 428 EXPECT_EQ(3u, event_queue().size()); |
429 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 429 EXPECT_TRUE(main_task_runner_->HasPendingTask()); |
430 EXPECT_FALSE(needs_main_frame_); | 430 EXPECT_TRUE(needs_main_frame_); |
431 main_task_runner_->RunUntilIdle(); | 431 main_task_runner_->RunUntilIdle(); |
432 } | 432 } |
433 | 433 |
434 TEST_P(MainThreadEventQueueTest, RafAlignedTouchInputCoalescedMoves) { | 434 TEST_P(MainThreadEventQueueTest, RafAlignedTouchInputCoalescedMoves) { |
435 // Don't run the test when we aren't supporting rAF aligned input. | 435 // Don't run the test when we aren't supporting rAF aligned input. |
436 if ((raf_aligned_input_setting_ & kRafAlignedEnabledTouch) == 0) | 436 if ((raf_aligned_input_setting_ & kRafAlignedEnabledTouch) == 0) |
437 return; | 437 return; |
438 | 438 |
439 SyntheticWebTouchEvent kEvents[2]; | 439 SyntheticWebTouchEvent kEvents[2]; |
440 kEvents[0].PressPoint(10, 10); | 440 kEvents[0].PressPoint(10, 10); |
441 kEvents[0].MovePoint(0, 50, 50); | 441 kEvents[0].MovePoint(0, 50, 50); |
442 kEvents[1].PressPoint(10, 10); | 442 kEvents[1].PressPoint(10, 10); |
443 kEvents[1].MovePoint(0, 20, 20); | 443 kEvents[1].MovePoint(0, 20, 20); |
444 kEvents[0].dispatchType = WebInputEvent::EventNonBlocking; | 444 kEvents[0].dispatchType = WebInputEvent::EventNonBlocking; |
445 | 445 |
446 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | 446 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
447 EXPECT_EQ(0u, event_queue().size()); | 447 EXPECT_EQ(0u, event_queue().size()); |
448 | 448 |
449 // Send a continuous input event (ack required) and then | 449 // Send a continuous input event (ack required) and then |
450 // a discrete event. The events should coalesce together | 450 // a discrete event. The events should coalesce together |
451 // and a post task should be on the queue at the end. | 451 // and a post task should be on the queue at the end. |
452 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 452 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
453 EXPECT_EQ(1u, event_queue().size()); | 453 EXPECT_EQ(1u, event_queue().size()); |
454 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | 454 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
455 EXPECT_TRUE(needs_main_frame_); | 455 EXPECT_TRUE(needs_main_frame_); |
456 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 456 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
457 EXPECT_EQ(1u, event_queue().size()); | 457 EXPECT_EQ(1u, event_queue().size()); |
458 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 458 EXPECT_FALSE(main_task_runner_->HasPendingTask()); |
459 EXPECT_TRUE(needs_main_frame_); | 459 EXPECT_TRUE(needs_main_frame_); |
460 RunPendingTasksWithSimulatedRaf(); | 460 RunPendingTasksWithSimulatedRaf(); |
461 EXPECT_EQ(0u, event_queue().size()); | 461 EXPECT_EQ(0u, event_queue().size()); |
462 EXPECT_EQ(1u, additional_acked_events_.size()); | 462 EXPECT_EQ(1u, additional_acked_events_.size()); |
463 additional_acked_events_.clear(); | 463 additional_acked_events_.clear(); |
464 | 464 |
465 // Send a non-cancelable ack required event, and then a non-ack | 465 // Send a non-cancelable ack required event, and then a non-ack |
466 // required event they should be coalesced together. | 466 // required event they should be coalesced together. |
467 EXPECT_TRUE(HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 467 EXPECT_TRUE(HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
468 EXPECT_EQ(1u, event_queue().size()); | 468 EXPECT_EQ(1u, event_queue().size()); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 620 |
621 // The boolean parameterized test varies whether rAF aligned input | 621 // The boolean parameterized test varies whether rAF aligned input |
622 // is enabled or not. | 622 // is enabled or not. |
623 INSTANTIATE_TEST_CASE_P( | 623 INSTANTIATE_TEST_CASE_P( |
624 MainThreadEventQueueTests, | 624 MainThreadEventQueueTests, |
625 MainThreadEventQueueTest, | 625 MainThreadEventQueueTest, |
626 testing::Range(0u, | 626 testing::Range(0u, |
627 (kRafAlignedEnabledTouch | kRafAlignedEnabledMouse) + 1)); | 627 (kRafAlignedEnabledTouch | kRafAlignedEnabledMouse) + 1)); |
628 | 628 |
629 } // namespace content | 629 } // namespace content |
OLD | NEW |