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

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: Another attempt at rebasing. 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
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 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 state.NotifyReadyToCommit(); 1543 state.NotifyReadyToCommit();
1550 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1544 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1551 1545
1552 EXPECT_TRUE(state.PendingActivationsShouldBeForced()); 1546 EXPECT_TRUE(state.PendingActivationsShouldBeForced());
1553 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1547 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1554 1548
1555 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1549 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1556 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1550 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1557 } 1551 }
1558 1552
1553 TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) {
1554 SchedulerSettings default_scheduler_settings;
1555 StateMachine state(default_scheduler_settings);
1556 state.SetCanStart();
1557 state.UpdateState(state.NextAction());
1558 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1559 state.SetVisible(true);
1560
1561 EXPECT_FALSE(state.BeginFrameNeeded());
1562 state.SetNeedsRedraw(true);
1563 EXPECT_TRUE(state.BeginFrameNeeded());
1564
1565 state.SetVisible(false);
1566 EXPECT_FALSE(state.BeginFrameNeeded());
1567
1568 state.SetVisible(true);
1569 EXPECT_TRUE(state.BeginFrameNeeded());
1570 }
1571
1559 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) { 1572 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) {
1560 SchedulerSettings default_scheduler_settings; 1573 SchedulerSettings default_scheduler_settings;
1561 StateMachine state(default_scheduler_settings); 1574 StateMachine state(default_scheduler_settings);
1562 state.SetCanStart(); 1575 state.SetCanStart();
1563 state.UpdateState(state.NextAction()); 1576 state.UpdateState(state.NextAction());
1564 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1577 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1565 state.SetVisible(false); 1578 state.SetVisible(false);
1566 state.SetNeedsCommit(); 1579 state.SetNeedsCommit();
1567 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1580 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1581 EXPECT_FALSE(state.BeginFrameNeeded());
1582
1583 // When become visible again, the needs commit should still be pending.
1584 state.SetVisible(true);
1585 EXPECT_TRUE(state.BeginFrameNeeded());
1586 state.OnBeginImplFrame();
1587 EXPECT_ACTION_UPDATE_STATE(
1588 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1568 } 1589 }
1569 1590
1570 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) { 1591 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) {
1571 SchedulerSettings default_scheduler_settings; 1592 SchedulerSettings default_scheduler_settings;
1572 StateMachine state(default_scheduler_settings); 1593 StateMachine state(default_scheduler_settings);
1573 state.SetCanStart(); 1594 state.SetCanStart();
1574 state.UpdateState(state.NextAction()); 1595 state.UpdateState(state.NextAction());
1575 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1596 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1576 state.SetVisible(false); 1597 state.SetVisible(false);
1577 state.SetCommitState( 1598 state.SetCommitState(
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 1939 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
1919 bool commit_has_no_updates = true; 1940 bool commit_has_no_updates = true;
1920 state.UpdateStateOnCommit(commit_has_no_updates); 1941 state.UpdateStateOnCommit(commit_has_no_updates);
1921 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); 1942 EXPECT_TRUE(state.ProactiveBeginFrameWanted());
1922 state.OnBeginImplFrame(); 1943 state.OnBeginImplFrame();
1923 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 1944 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
1924 } 1945 }
1925 1946
1926 } // namespace 1947 } // namespace
1927 } // namespace cc 1948 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698