| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 #define EXPECT_SCOPED(statements) \ | 39 #define EXPECT_SCOPED(statements) \ |
| 40 { \ | 40 { \ |
| 41 SCOPED_TRACE(""); \ | 41 SCOPED_TRACE(""); \ |
| 42 statements; \ | 42 statements; \ |
| 43 } | 43 } |
| 44 | 44 |
| 45 namespace cc { | 45 namespace cc { |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 base::TimeDelta kSlowDuration = base::TimeDelta::FromSeconds(1); |
| 49 base::TimeDelta kFastDuration = base::TimeDelta::FromMilliseconds(1); |
| 50 |
| 48 class FakeSchedulerClient : public SchedulerClient { | 51 class FakeSchedulerClient : public SchedulerClient { |
| 49 public: | 52 public: |
| 50 FakeSchedulerClient() | 53 FakeSchedulerClient() |
| 51 : automatic_swap_ack_(true), | 54 : automatic_swap_ack_(true), |
| 52 scheduler_(nullptr) { | 55 scheduler_(nullptr) { |
| 53 Reset(); | 56 Reset(); |
| 54 } | 57 } |
| 55 | 58 |
| 56 void Reset() { | 59 void Reset() { |
| 57 actions_.clear(); | 60 actions_.clear(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); | 272 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); |
| 270 | 273 |
| 271 scheduler_ = TestScheduler::Create( | 274 scheduler_ = TestScheduler::Create( |
| 272 now_src_.get(), client_.get(), scheduler_settings_, 0, | 275 now_src_.get(), client_.get(), scheduler_settings_, 0, |
| 273 task_runner_.get(), fake_external_begin_frame_source_.get(), | 276 task_runner_.get(), fake_external_begin_frame_source_.get(), |
| 274 std::move(fake_compositor_timing_history)); | 277 std::move(fake_compositor_timing_history)); |
| 275 DCHECK(scheduler_); | 278 DCHECK(scheduler_); |
| 276 client_->set_scheduler(scheduler_.get()); | 279 client_->set_scheduler(scheduler_.get()); |
| 277 | 280 |
| 278 // Use large estimates by default to avoid latency recovery in most tests. | 281 // Use large estimates by default to avoid latency recovery in most tests. |
| 279 base::TimeDelta slow_duration = base::TimeDelta::FromSeconds(1); | 282 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 280 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | |
| 281 | 283 |
| 282 return scheduler_.get(); | 284 return scheduler_.get(); |
| 283 } | 285 } |
| 284 | 286 |
| 285 void CreateSchedulerAndInitSurface() { | 287 void CreateSchedulerAndInitSurface() { |
| 286 CreateScheduler(); | 288 CreateScheduler(); |
| 287 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); | 289 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); |
| 288 } | 290 } |
| 289 | 291 |
| 290 void SetUpScheduler(bool initSurface) { | 292 void SetUpScheduler(bool initSurface) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 419 } |
| 418 | 420 |
| 419 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); | 421 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); |
| 420 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline); | 422 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline); |
| 421 void ImplFrameIsNotSkippedAfterLateSwapAck(); | 423 void ImplFrameIsNotSkippedAfterLateSwapAck(); |
| 422 void BeginFramesNotFromClient(bool use_external_begin_frame_source, | 424 void BeginFramesNotFromClient(bool use_external_begin_frame_source, |
| 423 bool throttle_frame_production); | 425 bool throttle_frame_production); |
| 424 void BeginFramesNotFromClient_SwapThrottled( | 426 void BeginFramesNotFromClient_SwapThrottled( |
| 425 bool use_external_begin_frame_source, | 427 bool use_external_begin_frame_source, |
| 426 bool throttle_frame_production); | 428 bool throttle_frame_production); |
| 429 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, |
| 430 ScrollHandlerState scroll_handler_state, |
| 431 base::TimeDelta durations); |
| 427 | 432 |
| 428 scoped_ptr<base::SimpleTestTickClock> now_src_; | 433 scoped_ptr<base::SimpleTestTickClock> now_src_; |
| 429 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 434 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 430 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; | 435 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; |
| 431 SchedulerSettings scheduler_settings_; | 436 SchedulerSettings scheduler_settings_; |
| 432 scoped_ptr<FakeSchedulerClient> client_; | 437 scoped_ptr<FakeSchedulerClient> client_; |
| 433 scoped_ptr<TestScheduler> scheduler_; | 438 scoped_ptr<TestScheduler> scheduler_; |
| 434 FakeCompositorTimingHistory* fake_compositor_timing_history_; | 439 FakeCompositorTimingHistory* fake_compositor_timing_history_; |
| 435 }; | 440 }; |
| 436 | 441 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 client_->Reset(); | 483 client_->Reset(); |
| 479 EXPECT_SCOPED(AdvanceFrame()); | 484 EXPECT_SCOPED(AdvanceFrame()); |
| 480 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 485 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 481 } | 486 } |
| 482 | 487 |
| 483 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { | 488 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { |
| 484 // Set up client with specified estimates. | 489 // Set up client with specified estimates. |
| 485 scheduler_settings_.use_external_begin_frame_source = true; | 490 scheduler_settings_.use_external_begin_frame_source = true; |
| 486 SetUpScheduler(true); | 491 SetUpScheduler(true); |
| 487 | 492 |
| 488 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 493 fake_compositor_timing_history_ |
| 489 base::TimeDelta::FromMilliseconds(2)); | 494 ->SetBeginMainFrameStartToCommitDurationEstimate( |
| 495 base::TimeDelta::FromMilliseconds(2)); |
| 490 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 496 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( |
| 491 base::TimeDelta::FromMilliseconds(4)); | 497 base::TimeDelta::FromMilliseconds(4)); |
| 492 fake_compositor_timing_history_->SetDrawDurationEstimate( | 498 fake_compositor_timing_history_->SetDrawDurationEstimate( |
| 493 base::TimeDelta::FromMilliseconds(1)); | 499 base::TimeDelta::FromMilliseconds(1)); |
| 494 | 500 |
| 495 EXPECT_FALSE(client_->needs_begin_frames()); | 501 EXPECT_FALSE(client_->needs_begin_frames()); |
| 496 scheduler_->SetChildrenNeedBeginFrames(true); | 502 scheduler_->SetChildrenNeedBeginFrames(true); |
| 497 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 503 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 498 EXPECT_TRUE(client_->needs_begin_frames()); | 504 EXPECT_TRUE(client_->needs_begin_frames()); |
| 499 | 505 |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1380 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1375 | 1381 |
| 1376 client_->Reset(); | 1382 client_->Reset(); |
| 1377 scheduler_->SetNeedsBeginMainFrame(); | 1383 scheduler_->SetNeedsBeginMainFrame(); |
| 1378 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1384 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1379 EXPECT_SCOPED(AdvanceFrame()); | 1385 EXPECT_SCOPED(AdvanceFrame()); |
| 1380 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1386 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1381 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1387 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1382 EXPECT_EQ(expect_send_begin_main_frame, | 1388 EXPECT_EQ(expect_send_begin_main_frame, |
| 1383 scheduler_->MainThreadMissedLastDeadline()); | 1389 scheduler_->MainThreadMissedLastDeadline()); |
| 1390 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); |
| 1384 EXPECT_EQ(expect_send_begin_main_frame, | 1391 EXPECT_EQ(expect_send_begin_main_frame, |
| 1385 client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1392 client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1386 } | 1393 } |
| 1387 | 1394 |
| 1388 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { | 1395 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { |
| 1389 scheduler_settings_.use_external_begin_frame_source = true; | 1396 scheduler_settings_.use_external_begin_frame_source = true; |
| 1390 SetUpScheduler(true); | 1397 SetUpScheduler(true); |
| 1391 | 1398 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1392 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1393 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1394 | 1399 |
| 1395 bool expect_send_begin_main_frame = false; | 1400 bool expect_send_begin_main_frame = false; |
| 1396 EXPECT_SCOPED( | 1401 EXPECT_SCOPED( |
| 1397 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1402 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1398 } | 1403 } |
| 1399 | 1404 |
| 1405 // Response times of BeginMainFrame's without the critical path flag set |
| 1406 // should not affect whether we recover latency or not. |
| 1407 TEST_F( |
| 1408 SchedulerTest, |
| 1409 MainFrameSkippedAfterLateCommit_LongBeginMainFrameQueueDurationNotCritical)
{ |
| 1410 scheduler_settings_.use_external_begin_frame_source = true; |
| 1411 SetUpScheduler(true); |
| 1412 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1413 fake_compositor_timing_history_ |
| 1414 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1415 |
| 1416 bool expect_send_begin_main_frame = false; |
| 1417 EXPECT_SCOPED( |
| 1418 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1419 } |
| 1420 |
| 1421 // Response times of BeginMainFrame's with the critical path flag set |
| 1422 // should affect whether we recover latency or not. |
| 1423 TEST_F( |
| 1424 SchedulerTest, |
| 1425 MainFrameNotSkippedAfterLateCommit_LongBeginMainFrameQueueDurationCritical)
{ |
| 1426 scheduler_settings_.use_external_begin_frame_source = true; |
| 1427 SetUpScheduler(true); |
| 1428 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1429 fake_compositor_timing_history_ |
| 1430 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); |
| 1431 fake_compositor_timing_history_ |
| 1432 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1433 |
| 1434 bool expect_send_begin_main_frame = true; |
| 1435 EXPECT_SCOPED( |
| 1436 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1437 } |
| 1438 |
| 1400 TEST_F(SchedulerTest, | 1439 TEST_F(SchedulerTest, |
| 1401 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) { | 1440 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) { |
| 1402 scheduler_settings_.use_external_begin_frame_source = true; | 1441 scheduler_settings_.use_external_begin_frame_source = true; |
| 1403 SetUpScheduler(true); | 1442 SetUpScheduler(true); |
| 1404 scheduler_->SetImplLatencyTakesPriority(true); | 1443 scheduler_->SetTreePrioritiesAndScrollState( |
| 1405 | 1444 SMOOTHNESS_TAKES_PRIORITY, |
| 1406 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1445 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); |
| 1407 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1446 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1408 | 1447 |
| 1409 bool expect_send_begin_main_frame = true; | 1448 bool expect_send_begin_main_frame = true; |
| 1410 EXPECT_SCOPED( | 1449 EXPECT_SCOPED( |
| 1411 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1450 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1412 } | 1451 } |
| 1413 | 1452 |
| 1414 TEST_F(SchedulerTest, | 1453 TEST_F(SchedulerTest, |
| 1415 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) { | 1454 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) { |
| 1416 scheduler_settings_.use_external_begin_frame_source = true; | 1455 scheduler_settings_.use_external_begin_frame_source = true; |
| 1417 SetUpScheduler(true); | 1456 SetUpScheduler(true); |
| 1418 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1457 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1419 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1458 fake_compositor_timing_history_ |
| 1420 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1459 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); |
| 1421 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1422 slow_duration); | |
| 1423 | 1460 |
| 1424 bool expect_send_begin_main_frame = true; | 1461 bool expect_send_begin_main_frame = true; |
| 1425 EXPECT_SCOPED( | 1462 EXPECT_SCOPED( |
| 1426 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1463 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1427 } | 1464 } |
| 1428 | 1465 |
| 1429 TEST_F(SchedulerTest, | 1466 TEST_F(SchedulerTest, |
| 1430 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) { | 1467 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) { |
| 1431 scheduler_settings_.use_external_begin_frame_source = true; | 1468 scheduler_settings_.use_external_begin_frame_source = true; |
| 1432 SetUpScheduler(true); | 1469 SetUpScheduler(true); |
| 1433 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1470 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1434 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1435 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1436 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1471 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( |
| 1437 slow_duration); | 1472 kSlowDuration); |
| 1438 | 1473 |
| 1439 bool expect_send_begin_main_frame = true; | 1474 bool expect_send_begin_main_frame = true; |
| 1440 EXPECT_SCOPED( | 1475 EXPECT_SCOPED( |
| 1441 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1476 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1442 } | 1477 } |
| 1443 | 1478 |
| 1444 TEST_F(SchedulerTest, | 1479 TEST_F(SchedulerTest, |
| 1445 MainFrameNotSkippedAfterLateCommit_ActivateEstimateTooLong) { | 1480 MainFrameNotSkippedAfterLateCommit_ActivateEstimateTooLong) { |
| 1446 scheduler_settings_.use_external_begin_frame_source = true; | 1481 scheduler_settings_.use_external_begin_frame_source = true; |
| 1447 SetUpScheduler(true); | 1482 SetUpScheduler(true); |
| 1448 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1483 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1449 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1484 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); |
| 1450 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1451 fake_compositor_timing_history_->SetActivateDurationEstimate(slow_duration); | |
| 1452 | 1485 |
| 1453 bool expect_send_begin_main_frame = true; | 1486 bool expect_send_begin_main_frame = true; |
| 1454 EXPECT_SCOPED( | 1487 EXPECT_SCOPED( |
| 1455 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1488 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1456 } | 1489 } |
| 1457 | 1490 |
| 1458 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateCommit_DrawEstimateTooLong) { | 1491 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateCommit_DrawEstimateTooLong) { |
| 1459 scheduler_settings_.use_external_begin_frame_source = true; | 1492 scheduler_settings_.use_external_begin_frame_source = true; |
| 1460 SetUpScheduler(true); | 1493 SetUpScheduler(true); |
| 1461 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1494 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1462 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1495 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); |
| 1463 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1464 fake_compositor_timing_history_->SetDrawDurationEstimate(slow_duration); | |
| 1465 | 1496 |
| 1466 bool expect_send_begin_main_frame = true; | 1497 bool expect_send_begin_main_frame = true; |
| 1467 EXPECT_SCOPED( | 1498 EXPECT_SCOPED( |
| 1468 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1499 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1469 } | 1500 } |
| 1470 | 1501 |
| 1471 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( | 1502 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( |
| 1472 bool swap_ack_before_deadline) { | 1503 bool swap_ack_before_deadline) { |
| 1473 // To get into a high latency state, this test disables automatic swap acks. | 1504 // To get into a high latency state, this test disables automatic swap acks. |
| 1474 client_->SetAutomaticSwapAck(false); | 1505 client_->SetAutomaticSwapAck(false); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | 1573 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); |
| 1543 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | 1574 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); |
| 1544 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | 1575 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); |
| 1545 } | 1576 } |
| 1546 } | 1577 } |
| 1547 | 1578 |
| 1548 TEST_F(SchedulerTest, | 1579 TEST_F(SchedulerTest, |
| 1549 ImplFrameSkippedAfterLateSwapAck_FastEstimates_SwapAckThenDeadline) { | 1580 ImplFrameSkippedAfterLateSwapAck_FastEstimates_SwapAckThenDeadline) { |
| 1550 scheduler_settings_.use_external_begin_frame_source = true; | 1581 scheduler_settings_.use_external_begin_frame_source = true; |
| 1551 SetUpScheduler(true); | 1582 SetUpScheduler(true); |
| 1552 | 1583 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1553 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1554 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1555 | 1584 |
| 1556 bool swap_ack_before_deadline = true; | 1585 bool swap_ack_before_deadline = true; |
| 1557 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); | 1586 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1558 } | 1587 } |
| 1559 | 1588 |
| 1560 TEST_F(SchedulerTest, | 1589 TEST_F(SchedulerTest, |
| 1561 ImplFrameSkippedAfterLateSwapAck_FastEstimates_DeadlineThenSwapAck) { | 1590 ImplFrameSkippedAfterLateSwapAck_FastEstimates_DeadlineThenSwapAck) { |
| 1562 scheduler_settings_.use_external_begin_frame_source = true; | 1591 scheduler_settings_.use_external_begin_frame_source = true; |
| 1563 SetUpScheduler(true); | 1592 SetUpScheduler(true); |
| 1564 | 1593 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1565 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1566 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1567 | 1594 |
| 1568 bool swap_ack_before_deadline = false; | 1595 bool swap_ack_before_deadline = false; |
| 1569 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); | 1596 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1597 } |
| 1598 |
| 1599 TEST_F( |
| 1600 SchedulerTest, |
| 1601 ImplFrameSkippedAfterLateSwapAck_LongBeginMainFrameQueueDurationNotCritical)
{ |
| 1602 scheduler_settings_.use_external_begin_frame_source = true; |
| 1603 SetUpScheduler(true); |
| 1604 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1605 fake_compositor_timing_history_ |
| 1606 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1607 |
| 1608 bool swap_ack_before_deadline = false; |
| 1609 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1570 } | 1610 } |
| 1571 | 1611 |
| 1572 TEST_F(SchedulerTest, | 1612 TEST_F(SchedulerTest, |
| 1573 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) { | 1613 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) { |
| 1574 scheduler_settings_.use_external_begin_frame_source = true; | 1614 scheduler_settings_.use_external_begin_frame_source = true; |
| 1575 SetUpScheduler(true); | 1615 SetUpScheduler(true); |
| 1576 | 1616 |
| 1577 // Even if every estimate related to the main thread is slow, we should | 1617 // Even if every estimate related to the main thread is slow, we should |
| 1578 // still expect to recover impl thread latency if the draw is fast and we | 1618 // still expect to recover impl thread latency if the draw is fast and we |
| 1579 // are in impl latency takes priority. | 1619 // are in impl latency takes priority. |
| 1580 scheduler_->SetImplLatencyTakesPriority(true); | 1620 scheduler_->SetTreePrioritiesAndScrollState( |
| 1581 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1621 SMOOTHNESS_TAKES_PRIORITY, |
| 1582 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | 1622 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); |
| 1583 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1623 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 1584 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); | 1624 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); |
| 1585 | 1625 |
| 1586 bool swap_ack_before_deadline = false; | 1626 bool swap_ack_before_deadline = false; |
| 1587 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); | 1627 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1588 } | 1628 } |
| 1589 | 1629 |
| 1590 TEST_F(SchedulerTest, | 1630 TEST_F(SchedulerTest, |
| 1591 ImplFrameSkippedAfterLateSwapAck_OnlyImplSideUpdatesExpected) { | 1631 ImplFrameSkippedAfterLateSwapAck_OnlyImplSideUpdatesExpected) { |
| 1592 // This tests that we recover impl thread latency when there are no commits. | 1632 // This tests that we recover impl thread latency when there are no commits. |
| 1593 scheduler_settings_.use_external_begin_frame_source = true; | 1633 scheduler_settings_.use_external_begin_frame_source = true; |
| 1594 SetUpScheduler(true); | 1634 SetUpScheduler(true); |
| 1595 | 1635 |
| 1596 // To get into a high latency state, this test disables automatic swap acks. | 1636 // To get into a high latency state, this test disables automatic swap acks. |
| 1597 client_->SetAutomaticSwapAck(false); | 1637 client_->SetAutomaticSwapAck(false); |
| 1598 | 1638 |
| 1599 // Even if every estimate related to the main thread is slow, we should | 1639 // Even if every estimate related to the main thread is slow, we should |
| 1600 // still expect to recover impl thread latency if there are no commits from | 1640 // still expect to recover impl thread latency if there are no commits from |
| 1601 // the main thread. | 1641 // the main thread. |
| 1602 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1642 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 1603 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | 1643 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); |
| 1604 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1605 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); | |
| 1606 | 1644 |
| 1607 // Draw and swap for first BeginFrame | 1645 // Draw and swap for first BeginFrame |
| 1608 client_->Reset(); | 1646 client_->Reset(); |
| 1609 scheduler_->SetNeedsRedraw(); | 1647 scheduler_->SetNeedsRedraw(); |
| 1610 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1648 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1611 SendNextBeginFrame(); | 1649 SendNextBeginFrame(); |
| 1612 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); | 1650 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); |
| 1613 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | 1651 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1614 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 3); | 1652 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 3); |
| 1615 | 1653 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 | 1739 |
| 1702 // Verify that we don't skip the actions of the BeginImplFrame | 1740 // Verify that we don't skip the actions of the BeginImplFrame |
| 1703 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 5); | 1741 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 5); |
| 1704 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 5); | 1742 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 5); |
| 1705 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 2, 5); | 1743 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 2, 5); |
| 1706 EXPECT_ACTION("ScheduledActionAnimate", client_, 3, 5); | 1744 EXPECT_ACTION("ScheduledActionAnimate", client_, 3, 5); |
| 1707 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5); | 1745 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5); |
| 1708 } | 1746 } |
| 1709 } | 1747 } |
| 1710 | 1748 |
| 1749 TEST_F( |
| 1750 SchedulerTest, |
| 1751 ImplFrameIsNotSkippedAfterLateSwapAck_BeginMainFrameQueueDurationCriticalToo
Long) { |
| 1752 scheduler_settings_.use_external_begin_frame_source = true; |
| 1753 SetUpScheduler(true); |
| 1754 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1755 fake_compositor_timing_history_ |
| 1756 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); |
| 1757 fake_compositor_timing_history_ |
| 1758 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1759 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); |
| 1760 } |
| 1761 |
| 1711 TEST_F(SchedulerTest, | 1762 TEST_F(SchedulerTest, |
| 1712 ImplFrameIsNotSkippedAfterLateSwapAck_CommitEstimateTooLong) { | 1763 ImplFrameIsNotSkippedAfterLateSwapAck_CommitEstimateTooLong) { |
| 1713 scheduler_settings_.use_external_begin_frame_source = true; | 1764 scheduler_settings_.use_external_begin_frame_source = true; |
| 1714 SetUpScheduler(true); | 1765 SetUpScheduler(true); |
| 1715 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1766 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1716 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1767 fake_compositor_timing_history_ |
| 1717 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1768 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); |
| 1718 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1719 slow_duration); | |
| 1720 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | 1769 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); |
| 1721 } | 1770 } |
| 1722 | 1771 |
| 1723 TEST_F(SchedulerTest, | 1772 TEST_F(SchedulerTest, |
| 1724 ImplFrameIsNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) { | 1773 ImplFrameIsNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) { |
| 1725 scheduler_settings_.use_external_begin_frame_source = true; | 1774 scheduler_settings_.use_external_begin_frame_source = true; |
| 1726 SetUpScheduler(true); | 1775 SetUpScheduler(true); |
| 1727 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1776 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1728 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1729 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1730 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1777 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( |
| 1731 slow_duration); | 1778 kSlowDuration); |
| 1732 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | 1779 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); |
| 1733 } | 1780 } |
| 1734 | 1781 |
| 1735 TEST_F(SchedulerTest, | 1782 TEST_F(SchedulerTest, |
| 1736 ImplFrameIsNotSkippedAfterLateSwapAck_ActivateEstimateTooLong) { | 1783 ImplFrameIsNotSkippedAfterLateSwapAck_ActivateEstimateTooLong) { |
| 1737 scheduler_settings_.use_external_begin_frame_source = true; | 1784 scheduler_settings_.use_external_begin_frame_source = true; |
| 1738 SetUpScheduler(true); | 1785 SetUpScheduler(true); |
| 1739 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1786 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1740 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1787 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); |
| 1741 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1742 fake_compositor_timing_history_->SetActivateDurationEstimate(slow_duration); | |
| 1743 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | 1788 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); |
| 1744 } | 1789 } |
| 1745 | 1790 |
| 1746 TEST_F(SchedulerTest, | 1791 TEST_F(SchedulerTest, |
| 1747 ImplFrameIsNotSkippedAfterLateSwapAck_DrawEstimateTooLong) { | 1792 ImplFrameIsNotSkippedAfterLateSwapAck_DrawEstimateTooLong) { |
| 1748 scheduler_settings_.use_external_begin_frame_source = true; | 1793 scheduler_settings_.use_external_begin_frame_source = true; |
| 1749 SetUpScheduler(true); | 1794 SetUpScheduler(true); |
| 1750 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1795 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1751 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1796 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); |
| 1752 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1753 fake_compositor_timing_history_->SetDrawDurationEstimate(slow_duration); | |
| 1754 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | 1797 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); |
| 1755 } | 1798 } |
| 1756 | 1799 |
| 1757 TEST_F(SchedulerTest, | 1800 TEST_F(SchedulerTest, |
| 1758 MainFrameThenImplFrameSkippedAfterLateCommitAndLateSwapAck) { | 1801 MainFrameThenImplFrameSkippedAfterLateCommitAndLateSwapAck) { |
| 1759 // Set up client with custom estimates. | 1802 // Set up client with custom estimates. |
| 1760 // This test starts off with expensive estimates to prevent latency recovery | 1803 // This test starts off with expensive estimates to prevent latency recovery |
| 1761 // initially, then lowers the estimates to enable it once both the main | 1804 // initially, then lowers the estimates to enable it once both the main |
| 1762 // and impl threads are in a high latency mode. | 1805 // and impl threads are in a high latency mode. |
| 1763 scheduler_settings_.use_external_begin_frame_source = true; | 1806 scheduler_settings_.use_external_begin_frame_source = true; |
| 1764 SetUpScheduler(true); | 1807 SetUpScheduler(true); |
| 1765 | 1808 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 1766 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1767 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | |
| 1768 | 1809 |
| 1769 // To get into a high latency state, this test disables automatic swap acks. | 1810 // To get into a high latency state, this test disables automatic swap acks. |
| 1770 client_->SetAutomaticSwapAck(false); | 1811 client_->SetAutomaticSwapAck(false); |
| 1771 | 1812 |
| 1772 // Impl thread hits deadline before commit finishes to make | 1813 // Impl thread hits deadline before commit finishes to make |
| 1773 // MainThreadMissedLastDeadline true | 1814 // MainThreadMissedLastDeadline true |
| 1774 client_->Reset(); | 1815 client_->Reset(); |
| 1775 scheduler_->SetNeedsBeginMainFrame(); | 1816 scheduler_->SetNeedsBeginMainFrame(); |
| 1776 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1817 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1777 EXPECT_SCOPED(AdvanceFrame()); | 1818 EXPECT_SCOPED(AdvanceFrame()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 | 1859 |
| 1819 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1860 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1820 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1861 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1821 // Note: BeginMainFrame and swap are skipped here because of | 1862 // Note: BeginMainFrame and swap are skipped here because of |
| 1822 // swap ack backpressure, not because of latency recovery. | 1863 // swap ack backpressure, not because of latency recovery. |
| 1823 EXPECT_FALSE(client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1864 EXPECT_FALSE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1824 EXPECT_FALSE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); | 1865 EXPECT_FALSE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| 1825 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1866 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1826 | 1867 |
| 1827 // Lower estimates so that the scheduler will attempt latency recovery. | 1868 // Lower estimates so that the scheduler will attempt latency recovery. |
| 1828 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1869 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1829 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1830 | 1870 |
| 1831 // Now that both threads are in a high latency mode, make sure we | 1871 // Now that both threads are in a high latency mode, make sure we |
| 1832 // skip the BeginMainFrame, then the BeginImplFrame, but not both | 1872 // skip the BeginMainFrame, then the BeginImplFrame, but not both |
| 1833 // at the same time. | 1873 // at the same time. |
| 1834 | 1874 |
| 1835 // Verify we skip BeginMainFrame first. | 1875 // Verify we skip BeginMainFrame first. |
| 1836 client_->Reset(); | 1876 client_->Reset(); |
| 1837 // Previous commit request is still outstanding. | 1877 // Previous commit request is still outstanding. |
| 1838 EXPECT_TRUE(scheduler_->NeedsBeginMainFrame()); | 1878 EXPECT_TRUE(scheduler_->NeedsBeginMainFrame()); |
| 1839 EXPECT_TRUE(scheduler_->SwapThrottled()); | 1879 EXPECT_TRUE(scheduler_->SwapThrottled()); |
| (...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3471 EXPECT_SCOPED(AdvanceFrame()); | 3511 EXPECT_SCOPED(AdvanceFrame()); |
| 3472 | 3512 |
| 3473 // At the next BeginFrame, authoritative interval is used instead of previous | 3513 // At the next BeginFrame, authoritative interval is used instead of previous |
| 3474 // interval. | 3514 // interval. |
| 3475 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); | 3515 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); |
| 3476 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); | 3516 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); |
| 3477 } | 3517 } |
| 3478 | 3518 |
| 3479 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { | 3519 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { |
| 3480 SetUpScheduler(true); | 3520 SetUpScheduler(true); |
| 3481 scheduler_->SetImplLatencyTakesPriority(true); | 3521 |
| 3522 scheduler_->SetTreePrioritiesAndScrollState( |
| 3523 SMOOTHNESS_TAKES_PRIORITY, |
| 3524 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); |
| 3525 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); |
| 3526 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); |
| 3527 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); |
| 3482 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); | 3528 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); |
| 3483 | 3529 |
| 3484 scheduler_->SetImplLatencyTakesPriority(false); | 3530 scheduler_->SetTreePrioritiesAndScrollState( |
| 3531 SMOOTHNESS_TAKES_PRIORITY, |
| 3532 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER); |
| 3533 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); |
| 3534 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
| 3535 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); |
| 3536 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); |
| 3537 |
| 3538 scheduler_->SetTreePrioritiesAndScrollState( |
| 3539 SAME_PRIORITY_FOR_BOTH_TREES, |
| 3540 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); |
| 3541 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); |
| 3542 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
| 3543 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); |
| 3544 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
| 3545 |
| 3546 scheduler_->SetTreePrioritiesAndScrollState( |
| 3547 SAME_PRIORITY_FOR_BOTH_TREES, |
| 3548 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER); |
| 3549 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); |
| 3550 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
| 3551 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); |
| 3485 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); | 3552 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
| 3486 } | 3553 } |
| 3487 | 3554 |
| 3488 TEST_F(SchedulerTest, BeginMainFrameArgs_OnCriticalPath) { | 3555 // The three letters appeneded to each version of this test mean the following:s |
| 3556 // tree_priority: B = both trees same priority; A = active tree priority; |
| 3557 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll |
| 3558 // handler; |
| 3559 // durations: F = fast durations; S = slow durations |
| 3560 bool SchedulerTest::BeginMainFrameOnCriticalPath( |
| 3561 TreePriority tree_priority, |
| 3562 ScrollHandlerState scroll_handler_state, |
| 3563 base::TimeDelta durations) { |
| 3489 scheduler_settings_.use_external_begin_frame_source = true; | 3564 scheduler_settings_.use_external_begin_frame_source = true; |
| 3490 SetUpScheduler(true); | 3565 SetUpScheduler(true); |
| 3491 | 3566 fake_compositor_timing_history_->SetAllEstimatesTo(durations); |
| 3492 scheduler_->SetImplLatencyTakesPriority(false); | 3567 client_->Reset(); |
| 3568 scheduler_->SetTreePrioritiesAndScrollState(tree_priority, |
| 3569 scroll_handler_state); |
| 3493 scheduler_->SetNeedsBeginMainFrame(); | 3570 scheduler_->SetNeedsBeginMainFrame(); |
| 3494 | |
| 3495 client_->Reset(); | |
| 3496 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); | 3571 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); |
| 3497 EXPECT_SCOPED(AdvanceFrame()); | 3572 EXPECT_SCOPED(AdvanceFrame()); |
| 3498 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); | 3573 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); |
| 3499 EXPECT_TRUE(client_->last_begin_main_frame_args().on_critical_path); | 3574 return client_->last_begin_main_frame_args().on_critical_path; |
| 3500 } | 3575 } |
| 3501 | 3576 |
| 3502 TEST_F(SchedulerTest, BeginMainFrameArgs_NotOnCriticalPath) { | 3577 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_BNF) { |
| 3503 scheduler_settings_.use_external_begin_frame_source = true; | 3578 EXPECT_TRUE(BeginMainFrameOnCriticalPath( |
| 3504 SetUpScheduler(true); | 3579 SAME_PRIORITY_FOR_BOTH_TREES, |
| 3580 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER, |
| 3581 kFastDuration)); |
| 3582 } |
| 3505 | 3583 |
| 3506 scheduler_->SetImplLatencyTakesPriority(true); | 3584 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_BNS) { |
| 3507 scheduler_->SetNeedsBeginMainFrame(); | 3585 EXPECT_TRUE(BeginMainFrameOnCriticalPath( |
| 3586 SAME_PRIORITY_FOR_BOTH_TREES, |
| 3587 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER, |
| 3588 kSlowDuration)); |
| 3589 } |
| 3508 | 3590 |
| 3509 client_->Reset(); | 3591 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_BHF) { |
| 3510 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); | 3592 EXPECT_TRUE(BeginMainFrameOnCriticalPath( |
| 3511 EXPECT_SCOPED(AdvanceFrame()); | 3593 SAME_PRIORITY_FOR_BOTH_TREES, |
| 3512 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); | 3594 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kFastDuration)); |
| 3513 EXPECT_FALSE(client_->last_begin_main_frame_args().on_critical_path); | 3595 } |
| 3596 |
| 3597 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_BHS) { |
| 3598 EXPECT_TRUE(BeginMainFrameOnCriticalPath( |
| 3599 SAME_PRIORITY_FOR_BOTH_TREES, |
| 3600 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3601 } |
| 3602 |
| 3603 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_ANF) { |
| 3604 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3605 SMOOTHNESS_TAKES_PRIORITY, |
| 3606 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER, |
| 3607 kFastDuration)); |
| 3608 } |
| 3609 |
| 3610 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_ANS) { |
| 3611 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3612 SMOOTHNESS_TAKES_PRIORITY, |
| 3613 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER, |
| 3614 kSlowDuration)); |
| 3615 } |
| 3616 |
| 3617 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHF) { |
| 3618 EXPECT_TRUE(BeginMainFrameOnCriticalPath( |
| 3619 SMOOTHNESS_TAKES_PRIORITY, |
| 3620 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kFastDuration)); |
| 3621 } |
| 3622 |
| 3623 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3624 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3625 SMOOTHNESS_TAKES_PRIORITY, |
| 3626 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3514 } | 3627 } |
| 3515 | 3628 |
| 3516 } // namespace | 3629 } // namespace |
| 3517 } // namespace cc | 3630 } // namespace cc |
| OLD | NEW |