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