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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 2659123004: cc: Add scheduler support for invalidating content on impl thread. (Closed)
Patch Set: no DCHECK Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/scheduler_test_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler_unittest.cc
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index f3bf54b89eb0b412472126725fd315fe5ac97e16..03afa472f5d1bc8c7edb5b8983653007bac786cd 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -171,6 +171,9 @@ class FakeSchedulerClient : public SchedulerClient,
actions_.push_back("ScheduledActionInvalidateCompositorFrameSink");
states_.push_back(scheduler_->AsValue());
}
+ void ScheduledActionPerformImplSideInvalidation() override {
+ PushAction("ScheduledActionPerformImplSideInvalidation");
+ }
void SendBeginMainFrameNotExpectedSoon() override {
PushAction("SendBeginMainFrameNotExpectedSoon");
@@ -3183,6 +3186,86 @@ TEST_F(SchedulerTest, NoCompositorFrameSinkCreationWhileCommitPending) {
client_);
}
+TEST_F(SchedulerTest, ImplSideInvalidationsInDeadline) {
+ SetUpScheduler(EXTERNAL_BFS);
+
+ // Request an impl-side invalidation and trigger the deadline. Ensure that the
+ // invalidation runs inside the deadline.
+ scheduler_->SetNeedsImplSideInvalidation();
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
+
+ // Deadline.
+ client_->Reset();
+ task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
+ EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_);
+}
+
+TEST_F(SchedulerTest, ImplSideInvalidationsMergedWithCommit) {
+ SetUpScheduler(EXTERNAL_BFS);
+
+ // Request a main frame and invalidation, the only action run should be
+ // sending the main frame.
+ scheduler_->SetNeedsBeginMainFrame();
+ scheduler_->SetNeedsImplSideInvalidation();
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
+ EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
+
+ // Respond with a commit. The scheduler should only perform the commit
+ // actions since the impl-side invalidation request will be merged with the
+ // commit.
+ client_->Reset();
+ scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now());
+ scheduler_->NotifyReadyToCommit();
+ EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
+ EXPECT_FALSE(scheduler_->needs_impl_side_invalidation());
+
+ // Deadline.
+ client_->Reset();
+ task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
+ EXPECT_NO_ACTION(client_);
+}
+
+TEST_F(SchedulerTest, AbortedCommitsTriggerImplSideInvalidations) {
+ SetUpScheduler(EXTERNAL_BFS);
+
+ // Request a main frame and invalidation.
+ scheduler_->SetNeedsBeginMainFrame();
+ scheduler_->SetNeedsImplSideInvalidation();
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
+ EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
+
+ // Abort the main frame and request another one, the impl-side invalidations
+ // should not be blocked on the main frame.
+ client_->Reset();
+ scheduler_->SetNeedsBeginMainFrame();
+ scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now());
+ scheduler_->BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
+ task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
+ EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_);
+
+ // Activate the sync tree.
+ client_->Reset();
+ scheduler_->NotifyReadyToActivate();
+ EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
+
+ // Second impl frame.
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
+ EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
+
+ // Deadline.
+ client_->Reset();
+ task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
+ EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_);
+}
+
// The three letters appeneded to each version of this test mean the following:s
// tree_priority: B = both trees same priority; A = active tree priority;
// scroll_handler_state: H = affects scroll handler; N = does not affect scroll
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/scheduler_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698