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 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1784 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1785 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1785 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1786 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | 1786 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
1787 | 1787 |
1788 state.DidLoseOutputSurface(); | 1788 state.DidLoseOutputSurface(); |
1789 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1789 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1790 // The deadline should be triggered immediately when output surface is lost. | 1790 // The deadline should be triggered immediately when output surface is lost. |
1791 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); | 1791 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
1792 } | 1792 } |
1793 | 1793 |
| 1794 TEST(SchedulerStateMachineTest, TestTriggerDeadlineImmediatelyWhenInvisible) { |
| 1795 SchedulerSettings settings; |
| 1796 settings.impl_side_painting = true; |
| 1797 StateMachine state(settings); |
| 1798 SET_UP_STATE(state) |
| 1799 |
| 1800 state.SetNeedsCommit(); |
| 1801 |
| 1802 state.OnBeginImplFrame(); |
| 1803 EXPECT_ACTION_UPDATE_STATE( |
| 1804 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1805 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1806 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
| 1807 |
| 1808 state.SetVisible(false); |
| 1809 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1810 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); |
| 1811 } |
| 1812 |
1794 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { | 1813 TEST(SchedulerStateMachineTest, TestSetNeedsAnimate) { |
1795 SchedulerSettings settings; | 1814 SchedulerSettings settings; |
1796 settings.impl_side_painting = true; | 1815 settings.impl_side_painting = true; |
1797 StateMachine state(settings); | 1816 StateMachine state(settings); |
1798 SET_UP_STATE(state) | 1817 SET_UP_STATE(state) |
1799 | 1818 |
1800 // Test requesting an animation that, when run, causes us to draw. | 1819 // Test requesting an animation that, when run, causes us to draw. |
1801 state.SetNeedsAnimate(); | 1820 state.SetNeedsAnimate(); |
1802 EXPECT_TRUE(state.BeginFrameNeeded()); | 1821 EXPECT_TRUE(state.BeginFrameNeeded()); |
1803 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1822 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1947 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1929 bool commit_has_no_updates = true; | 1948 bool commit_has_no_updates = true; |
1930 state.UpdateStateOnCommit(commit_has_no_updates); | 1949 state.UpdateStateOnCommit(commit_has_no_updates); |
1931 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); | 1950 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); |
1932 state.OnBeginImplFrame(); | 1951 state.OnBeginImplFrame(); |
1933 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1952 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1934 } | 1953 } |
1935 | 1954 |
1936 } // namespace | 1955 } // namespace |
1937 } // namespace cc | 1956 } // namespace cc |
OLD | NEW |