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/debug/trace_event.h" | 7 #include "base/debug/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 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); | 1752 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
1753 EXPECT_ACTION_UPDATE_STATE( | 1753 EXPECT_ACTION_UPDATE_STATE( |
1754 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1754 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1755 | 1755 |
1756 state.OnBeginImplFrameDeadlinePending(); | 1756 state.OnBeginImplFrameDeadlinePending(); |
1757 state.OnBeginImplFrameDeadline(); | 1757 state.OnBeginImplFrameDeadline(); |
1758 EXPECT_ACTION_UPDATE_STATE( | 1758 EXPECT_ACTION_UPDATE_STATE( |
1759 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1759 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
1760 } | 1760 } |
1761 | 1761 |
| 1762 TEST(SchedulerStateMachineTest, TestAnimateAfterCommitBeforeDraw) { |
| 1763 SchedulerSettings settings; |
| 1764 settings.impl_side_painting = true; |
| 1765 StateMachine state(settings); |
| 1766 state.SetCanStart(); |
| 1767 state.UpdateState(state.NextAction()); |
| 1768 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 1769 state.SetVisible(true); |
| 1770 state.SetCanDraw(true); |
| 1771 |
| 1772 // Check that animations are updated before we start a commit. |
| 1773 state.SetNeedsAnimate(); |
| 1774 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1775 state.SetNeedsCommit(); |
| 1776 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
| 1777 EXPECT_TRUE(state.BeginFrameNeeded()); |
| 1778 |
| 1779 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); |
| 1780 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
| 1781 EXPECT_ACTION_UPDATE_STATE( |
| 1782 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 1783 |
| 1784 state.NotifyBeginMainFrameStarted(); |
| 1785 state.NotifyReadyToCommit(); |
| 1786 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
| 1787 |
| 1788 state.OnBeginImplFrameDeadlinePending(); |
| 1789 state.OnBeginImplFrameDeadline(); |
| 1790 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
| 1791 EXPECT_ACTION_UPDATE_STATE( |
| 1792 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1793 } |
| 1794 |
1762 TEST(SchedulerStateMachineTest, TestSetNeedsAnimateAfterAnimate) { | 1795 TEST(SchedulerStateMachineTest, TestSetNeedsAnimateAfterAnimate) { |
1763 SchedulerSettings settings; | 1796 SchedulerSettings settings; |
1764 settings.impl_side_painting = true; | 1797 settings.impl_side_painting = true; |
1765 StateMachine state(settings); | 1798 StateMachine state(settings); |
1766 state.SetCanStart(); | 1799 state.SetCanStart(); |
1767 state.UpdateState(state.NextAction()); | 1800 state.UpdateState(state.NextAction()); |
1768 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1801 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1769 state.SetVisible(true); | 1802 state.SetVisible(true); |
1770 state.SetCanDraw(true); | 1803 state.SetCanDraw(true); |
1771 | 1804 |
1772 // Test requesting an animation after we have already animated during this | 1805 // Test requesting an animation after we have already animated during this |
1773 // frame. | 1806 // frame. |
1774 state.SetNeedsRedraw(true); | 1807 state.SetNeedsRedraw(true); |
1775 EXPECT_TRUE(state.BeginFrameNeeded()); | 1808 EXPECT_TRUE(state.BeginFrameNeeded()); |
1776 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1809 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1777 | 1810 |
1778 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); | 1811 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); |
1779 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); | 1812 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); |
1780 | 1813 |
1781 state.SetNeedsAnimate(); | 1814 state.SetNeedsAnimate(); |
1782 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1815 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1783 | 1816 |
1784 state.OnBeginImplFrameDeadline(); | 1817 state.OnBeginImplFrameDeadline(); |
1785 EXPECT_ACTION_UPDATE_STATE( | 1818 EXPECT_ACTION_UPDATE_STATE( |
1786 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1819 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
1787 } | 1820 } |
1788 | 1821 |
1789 } // namespace | 1822 } // namespace |
1790 } // namespace cc | 1823 } // namespace cc |
OLD | NEW |