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 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1697 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1698 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1698 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1699 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | 1699 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
1700 | 1700 |
1701 state.DidLoseOutputSurface(); | 1701 state.DidLoseOutputSurface(); |
1702 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1702 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1703 // The deadline should be triggered immediately when output surface is lost. | 1703 // The deadline should be triggered immediately when output surface is lost. |
1704 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | 1704 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
1705 } | 1705 } |
1706 | 1706 |
1707 TEST(SchedulerStateMachineTest, TestTriggerDeadlineImmediatelyWhenInvisible) { | |
1708 SchedulerSettings settings; | |
1709 settings.impl_side_painting = true; | |
1710 StateMachine state(settings); | |
1711 SET_UP_STATE(state) | |
1712 | |
1713 state.SetNeedsCommit(); | |
1714 | |
1715 state.OnBeginImplFrame(); | |
1716 EXPECT_ACTION_UPDATE_STATE( | |
1717 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | |
1718 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
1719 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | |
1720 | |
1721 state.SetVisible(false); | |
1722 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | |
1723 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | |
1724 } | |
1725 | |
1726 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { | 1707 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { |
1727 SchedulerSettings settings; | 1708 SchedulerSettings settings; |
1728 settings.impl_side_painting = true; | 1709 settings.impl_side_painting = true; |
1729 StateMachine state(settings); | 1710 StateMachine state(settings); |
1730 SET_UP_STATE(state) | 1711 SET_UP_STATE(state) |
1731 | 1712 |
1732 // Test requesting an animation that, when run, causes us to draw. | 1713 // Test requesting an animation that, when run, causes us to draw. |
1733 state.SetNeedsAnimate(); | 1714 state.SetNeedsAnimate(); |
1734 EXPECT_TRUE(state.BeginFrameNeeded()); | 1715 EXPECT_TRUE(state.BeginFrameNeeded()); |
1735 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1716 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1841 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1861 bool commit_has_no_updates = true; | 1842 bool commit_has_no_updates = true; |
1862 state.UpdateStateOnCommit(commit_has_no_updates); | 1843 state.UpdateStateOnCommit(commit_has_no_updates); |
1863 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); | 1844 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); |
1864 state.OnBeginImplFrame(); | 1845 state.OnBeginImplFrame(); |
1865 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1846 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1866 } | 1847 } |
1867 | 1848 |
1868 } // namespace | 1849 } // namespace |
1869 } // namespace cc | 1850 } // namespace cc |
OLD | NEW |