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_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "cc/scheduler/scheduler.h" | 8 #include "cc/scheduler/scheduler.h" |
9 #include "cc/test/begin_frame_args_test.h" | 9 #include "cc/test/begin_frame_args_test.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 state.NotifyReadyToCommit(); | 1491 state.NotifyReadyToCommit(); |
1492 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1492 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1493 | 1493 |
1494 EXPECT_TRUE(state.PendingActivationsShouldBeForced()); | 1494 EXPECT_TRUE(state.PendingActivationsShouldBeForced()); |
1495 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); | 1495 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); |
1496 | 1496 |
1497 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); | 1497 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); |
1498 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); | 1498 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); |
1499 } | 1499 } |
1500 | 1500 |
| 1501 TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) { |
| 1502 SchedulerSettings default_scheduler_settings; |
| 1503 StateMachine state(default_scheduler_settings); |
| 1504 state.SetCanStart(); |
| 1505 state.UpdateState(state.NextAction()); |
| 1506 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1507 state.SetVisible(true); |
| 1508 |
| 1509 EXPECT_FALSE(state.BeginFrameNeeded()); |
| 1510 state.SetNeedsRedraw(true); |
| 1511 EXPECT_TRUE(state.BeginFrameNeeded()); |
| 1512 |
| 1513 state.SetVisible(false); |
| 1514 EXPECT_FALSE(state.BeginFrameNeeded()); |
| 1515 |
| 1516 state.SetVisible(true); |
| 1517 EXPECT_TRUE(state.BeginFrameNeeded()); |
| 1518 } |
| 1519 |
1501 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) { | 1520 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) { |
1502 SchedulerSettings default_scheduler_settings; | 1521 SchedulerSettings default_scheduler_settings; |
1503 StateMachine state(default_scheduler_settings); | 1522 StateMachine state(default_scheduler_settings); |
1504 state.SetCanStart(); | 1523 state.SetCanStart(); |
1505 state.UpdateState(state.NextAction()); | 1524 state.UpdateState(state.NextAction()); |
1506 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1525 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1507 state.SetVisible(false); | 1526 state.SetVisible(false); |
1508 state.SetNeedsCommit(); | 1527 state.SetNeedsCommit(); |
1509 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); | 1528 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); |
| 1529 EXPECT_FALSE(state.BeginFrameNeeded()); |
| 1530 |
| 1531 // When become visible again, the needs commit should still be pending. |
| 1532 state.SetVisible(true); |
| 1533 EXPECT_TRUE(state.BeginFrameNeeded()); |
| 1534 state.OnBeginImplFrame(); |
| 1535 EXPECT_ACTION_UPDATE_STATE( |
| 1536 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1510 } | 1537 } |
1511 | 1538 |
1512 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) { | 1539 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) { |
1513 SchedulerSettings default_scheduler_settings; | 1540 SchedulerSettings default_scheduler_settings; |
1514 StateMachine state(default_scheduler_settings); | 1541 StateMachine state(default_scheduler_settings); |
1515 state.SetCanStart(); | 1542 state.SetCanStart(); |
1516 state.UpdateState(state.NextAction()); | 1543 state.UpdateState(state.NextAction()); |
1517 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1544 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1518 state.SetVisible(false); | 1545 state.SetVisible(false); |
1519 state.SetCommitState( | 1546 state.SetCommitState( |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1724 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1698 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1725 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1699 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | 1726 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
1700 | 1727 |
1701 state.DidLoseOutputSurface(); | 1728 state.DidLoseOutputSurface(); |
1702 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1729 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1703 // The deadline should be triggered immediately when output surface is lost. | 1730 // The deadline should be triggered immediately when output surface is lost. |
1704 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | 1731 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
1705 } | 1732 } |
1706 | 1733 |
| 1734 TEST(SchedulerStateMachineTest, TestTriggerDeadlineImmediatelyWhenInvisible) { |
| 1735 SchedulerSettings settings; |
| 1736 settings.impl_side_painting = true; |
| 1737 StateMachine state(settings); |
| 1738 SET_UP_STATE(state) |
| 1739 |
| 1740 state.SetNeedsCommit(); |
| 1741 |
| 1742 state.OnBeginImplFrame(); |
| 1743 EXPECT_ACTION_UPDATE_STATE( |
| 1744 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1745 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1746 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
| 1747 |
| 1748 state.SetVisible(false); |
| 1749 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1750 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
| 1751 } |
| 1752 |
1707 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { | 1753 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { |
1708 SchedulerSettings settings; | 1754 SchedulerSettings settings; |
1709 settings.impl_side_painting = true; | 1755 settings.impl_side_painting = true; |
1710 StateMachine state(settings); | 1756 StateMachine state(settings); |
1711 SET_UP_STATE(state) | 1757 SET_UP_STATE(state) |
1712 | 1758 |
1713 // Test requesting an animation that, when run, causes us to draw. | 1759 // Test requesting an animation that, when run, causes us to draw. |
1714 state.SetNeedsAnimate(); | 1760 state.SetNeedsAnimate(); |
1715 EXPECT_TRUE(state.BeginFrameNeeded()); | 1761 EXPECT_TRUE(state.BeginFrameNeeded()); |
1716 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1762 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1887 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1842 bool commit_has_no_updates = true; | 1888 bool commit_has_no_updates = true; |
1843 state.UpdateStateOnCommit(commit_has_no_updates); | 1889 state.UpdateStateOnCommit(commit_has_no_updates); |
1844 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); | 1890 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); |
1845 state.OnBeginImplFrame(); | 1891 state.OnBeginImplFrame(); |
1846 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1892 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1847 } | 1893 } |
1848 | 1894 |
1849 } // namespace | 1895 } // namespace |
1850 } // namespace cc | 1896 } // namespace cc |
OLD | NEW |