| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 for (SyntheticWebTouchEvent& event : kEvents) | 415 for (SyntheticWebTouchEvent& event : kEvents) |
| 416 HandleEvent(event, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 416 HandleEvent(event, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 417 | 417 |
| 418 EXPECT_EQ(3u, event_queue().size()); | 418 EXPECT_EQ(3u, event_queue().size()); |
| 419 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 419 EXPECT_TRUE(main_task_runner_->HasPendingTask()); |
| 420 EXPECT_FALSE(needs_main_frame_); | 420 EXPECT_FALSE(needs_main_frame_); |
| 421 main_task_runner_->RunUntilIdle(); | 421 main_task_runner_->RunUntilIdle(); |
| 422 } | 422 } |
| 423 | 423 |
| 424 TEST_P(MainThreadEventQueueTest, RafAlignedMaxSize) { | |
| 425 // Don't run the test when we aren't supporting rAF aligned input. | |
| 426 if (!handle_raf_aligned_input_) | |
| 427 return; | |
| 428 | |
| 429 const size_t kNumEventsToQueue = 16; | |
| 430 WebMouseWheelEvent mouseEvent = | |
| 431 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false); | |
| 432 | |
| 433 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | |
| 434 EXPECT_EQ(0u, event_queue().size()); | |
| 435 | |
| 436 for (size_t i = 0; i < kNumEventsToQueue; ++i) { | |
| 437 mouseEvent.modifiers = i; | |
| 438 HandleEvent(mouseEvent, INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | |
| 439 } | |
| 440 | |
| 441 // There is a maximum number of events we handle in a rAF. kNumEventsToQueue | |
| 442 // exceeds that. Ensure that two rAF calls need to run. | |
| 443 EXPECT_EQ(kNumEventsToQueue, event_queue().size()); | |
| 444 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | |
| 445 EXPECT_TRUE(needs_main_frame_); | |
| 446 RunSimulatedRafOnce(); | |
| 447 EXPECT_TRUE(needs_main_frame_); | |
| 448 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | |
| 449 RunSimulatedRafOnce(); | |
| 450 EXPECT_EQ(0u, event_queue().size()); | |
| 451 EXPECT_FALSE(main_task_runner_->HasPendingTask()); | |
| 452 } | |
| 453 | |
| 454 TEST_P(MainThreadEventQueueTest, BlockingTouchesDuringFling) { | 424 TEST_P(MainThreadEventQueueTest, BlockingTouchesDuringFling) { |
| 455 SyntheticWebTouchEvent kEvents[1]; | 425 SyntheticWebTouchEvent kEvents[1]; |
| 456 kEvents[0].PressPoint(10, 10); | 426 kEvents[0].PressPoint(10, 10); |
| 457 kEvents[0].touchStartOrFirstTouchMove = true; | 427 kEvents[0].touchStartOrFirstTouchMove = true; |
| 458 set_is_flinging(true); | 428 set_is_flinging(true); |
| 459 set_enable_fling_passive_listener_flag(true); | 429 set_enable_fling_passive_listener_flag(true); |
| 460 | 430 |
| 461 EXPECT_FALSE(last_touch_start_forced_nonblocking_due_to_fling()); | 431 EXPECT_FALSE(last_touch_start_forced_nonblocking_due_to_fling()); |
| 462 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 432 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 463 RunPendingTasksWithSimulatedRaf(); | 433 RunPendingTasksWithSimulatedRaf(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 EXPECT_EQ(kEvents[0], *last_touch_event); | 560 EXPECT_EQ(kEvents[0], *last_touch_event); |
| 591 } | 561 } |
| 592 | 562 |
| 593 // The boolean parameterized test varies whether rAF aligned input | 563 // The boolean parameterized test varies whether rAF aligned input |
| 594 // is enabled or not. | 564 // is enabled or not. |
| 595 INSTANTIATE_TEST_CASE_P(MainThreadEventQueueTests, | 565 INSTANTIATE_TEST_CASE_P(MainThreadEventQueueTests, |
| 596 MainThreadEventQueueTest, | 566 MainThreadEventQueueTest, |
| 597 testing::Bool()); | 567 testing::Bool()); |
| 598 | 568 |
| 599 } // namespace content | 569 } // namespace content |
| OLD | NEW |