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 "cc/scheduler/scheduler.h" | 7 #include "cc/scheduler/scheduler.h" |
8 #include "cc/test/begin_frame_args_test.h" | 8 #include "cc/test/begin_frame_args_test.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 EXPECT_ACTION_UPDATE_STATE( | 1742 EXPECT_ACTION_UPDATE_STATE( |
1743 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1743 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1744 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1744 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1745 | 1745 |
1746 // The deadline is not triggered early until we enter prefer smoothness mode. | 1746 // The deadline is not triggered early until we enter prefer smoothness mode. |
1747 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1747 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1748 state.SetSmoothnessTakesPriority(true); | 1748 state.SetSmoothnessTakesPriority(true); |
1749 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1749 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1750 } | 1750 } |
1751 | 1751 |
| 1752 TEST(SchedulerStateMachineTest, TestTriggerDeadlineEarlyOnLostOutputSurface) { |
| 1753 SchedulerSettings default_scheduler_settings; |
| 1754 StateMachine state(default_scheduler_settings); |
| 1755 state.SetCanStart(); |
| 1756 state.UpdateState(state.NextAction()); |
| 1757 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1758 state.SetVisible(true); |
| 1759 state.SetCanDraw(true); |
| 1760 |
| 1761 state.SetNeedsCommit(); |
| 1762 |
| 1763 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); |
| 1764 EXPECT_ACTION_UPDATE_STATE( |
| 1765 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1766 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1767 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
| 1768 |
| 1769 state.DidLoseOutputSurface(); |
| 1770 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1771 // The deadline should be triggered immediately when output surface is lost. |
| 1772 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
| 1773 } |
| 1774 |
1752 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { | 1775 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { |
1753 SchedulerSettings settings; | 1776 SchedulerSettings settings; |
1754 settings.impl_side_painting = true; | 1777 settings.impl_side_painting = true; |
1755 StateMachine state(settings); | 1778 StateMachine state(settings); |
1756 state.SetCanStart(); | 1779 state.SetCanStart(); |
1757 state.UpdateState(state.NextAction()); | 1780 state.UpdateState(state.NextAction()); |
1758 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1781 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1759 state.SetVisible(true); | 1782 state.SetVisible(true); |
1760 state.SetCanDraw(true); | 1783 state.SetCanDraw(true); |
1761 | 1784 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 state.SetNeedsAnimate(); | 1846 state.SetNeedsAnimate(); |
1824 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1847 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1825 | 1848 |
1826 state.OnBeginImplFrameDeadline(); | 1849 state.OnBeginImplFrameDeadline(); |
1827 EXPECT_ACTION_UPDATE_STATE( | 1850 EXPECT_ACTION_UPDATE_STATE( |
1828 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1851 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
1829 } | 1852 } |
1830 | 1853 |
1831 } // namespace | 1854 } // namespace |
1832 } // namespace cc | 1855 } // namespace cc |
OLD | NEW |