Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: cc/scheduler/scheduler_state_machine_unittest.cc

Issue 1050833002: cc: Remove background ticking from LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto master. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 state.SetNeedsRedraw(true); 164 state.SetNeedsRedraw(true);
165 state.SetNeedsAnimateForTest(false); 165 state.SetNeedsAnimateForTest(false);
166 EXPECT_TRUE(state.BeginFrameNeeded()); 166 EXPECT_TRUE(state.BeginFrameNeeded());
167 167
168 // Don't background tick for needs_redraw. 168 // Don't background tick for needs_redraw.
169 state.SetVisible(false); 169 state.SetVisible(false);
170 state.SetNeedsRedraw(true); 170 state.SetNeedsRedraw(true);
171 state.SetNeedsAnimateForTest(false); 171 state.SetNeedsAnimateForTest(false);
172 EXPECT_FALSE(state.BeginFrameNeeded()); 172 EXPECT_FALSE(state.BeginFrameNeeded());
173 173
174 // Background tick for animations.
175 state.SetVisible(false);
176 state.SetNeedsRedraw(false);
177 state.SetNeedsAnimateForTest(true);
178 EXPECT_TRUE(state.BeginFrameNeeded());
179
180 // Proactively request BeginFrames when commit is pending. 174 // Proactively request BeginFrames when commit is pending.
181 state.SetVisible(true); 175 state.SetVisible(true);
182 state.SetNeedsRedraw(false); 176 state.SetNeedsRedraw(false);
183 state.SetNeedsAnimateForTest(false); 177 state.SetNeedsAnimateForTest(false);
184 state.SetNeedsCommitForTest(true); 178 state.SetNeedsCommitForTest(true);
185 EXPECT_TRUE(state.BeginFrameNeeded()); 179 EXPECT_TRUE(state.BeginFrameNeeded());
186 180
187 // Don't request BeginFrames when commit is pending if 181 // Don't request BeginFrames when commit is pending if
188 // we are currently deferring commits. 182 // we are currently deferring commits.
189 state.SetVisible(true); 183 state.SetVisible(true);
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 state.NotifyReadyToCommit(); 1572 state.NotifyReadyToCommit();
1579 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1573 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1580 1574
1581 EXPECT_TRUE(state.PendingActivationsShouldBeForced()); 1575 EXPECT_TRUE(state.PendingActivationsShouldBeForced());
1582 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1576 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1583 1577
1584 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1578 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1585 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1579 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1586 } 1580 }
1587 1581
1582 TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) {
1583 SchedulerSettings default_scheduler_settings;
1584 StateMachine state(default_scheduler_settings);
1585 state.SetCanStart();
1586 state.UpdateState(state.NextAction());
1587 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1588 state.SetVisible(true);
1589
1590 EXPECT_FALSE(state.BeginFrameNeeded());
1591 state.SetNeedsRedraw(true);
1592 EXPECT_TRUE(state.BeginFrameNeeded());
1593
1594 state.SetVisible(false);
1595 EXPECT_FALSE(state.BeginFrameNeeded());
1596
1597 state.SetVisible(true);
1598 EXPECT_TRUE(state.BeginFrameNeeded());
1599 }
1600
1588 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) { 1601 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) {
1589 SchedulerSettings default_scheduler_settings; 1602 SchedulerSettings default_scheduler_settings;
1590 StateMachine state(default_scheduler_settings); 1603 StateMachine state(default_scheduler_settings);
1591 state.SetCanStart(); 1604 state.SetCanStart();
1592 state.UpdateState(state.NextAction()); 1605 state.UpdateState(state.NextAction());
1593 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1606 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1594 state.SetVisible(false); 1607 state.SetVisible(false);
1595 state.SetNeedsCommit(); 1608 state.SetNeedsCommit();
1596 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1609 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1610 EXPECT_FALSE(state.BeginFrameNeeded());
1611
1612 // When become visible again, the needs commit should still be pending.
1613 state.SetVisible(true);
1614 EXPECT_TRUE(state.BeginFrameNeeded());
1615 state.OnBeginImplFrame();
1616 EXPECT_ACTION_UPDATE_STATE(
1617 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1597 } 1618 }
1598 1619
1599 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) { 1620 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) {
1600 SchedulerSettings default_scheduler_settings; 1621 SchedulerSettings default_scheduler_settings;
1601 StateMachine state(default_scheduler_settings); 1622 StateMachine state(default_scheduler_settings);
1602 state.SetCanStart(); 1623 state.SetCanStart();
1603 state.UpdateState(state.NextAction()); 1624 state.UpdateState(state.NextAction());
1604 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1625 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1605 state.SetVisible(false); 1626 state.SetVisible(false);
1606 state.SetCommitState( 1627 state.SetCommitState(
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 1968 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
1948 bool commit_has_no_updates = true; 1969 bool commit_has_no_updates = true;
1949 state.UpdateStateOnCommit(commit_has_no_updates); 1970 state.UpdateStateOnCommit(commit_has_no_updates);
1950 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); 1971 EXPECT_TRUE(state.ProactiveBeginFrameWanted());
1951 state.OnBeginImplFrame(); 1972 state.OnBeginImplFrame();
1952 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 1973 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
1953 } 1974 }
1954 1975
1955 } // namespace 1976 } // namespace
1956 } // namespace cc 1977 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698