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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 1184863004: cc: Move timing history to the Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, add include Created 5 years, 6 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
Index: cc/scheduler/scheduler_unittest.cc
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index 2b2e583f29780d5d12a374880c7efbbcc68f618d..c41acded98d6f58c7a7918a7b379393d23370fef 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -14,6 +14,7 @@
#include "base/run_loop.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
+#include "cc/debug/rendering_stats_instrumentation.h"
#include "cc/test/begin_frame_args_test.h"
#include "cc/test/ordered_simple_task_runner.h"
#include "cc/test/scheduler_test_common.h"
@@ -141,13 +142,6 @@ class FakeSchedulerClient : public SchedulerClient {
actions_.push_back("ScheduledActionInvalidateOutputSurface");
states_.push_back(scheduler_->AsValue());
}
- base::TimeDelta DrawDurationEstimate() override { return base::TimeDelta(); }
- base::TimeDelta BeginMainFrameToCommitDurationEstimate() override {
- return base::TimeDelta();
- }
- base::TimeDelta CommitToActivateDurationEstimate() override {
- return base::TimeDelta();
- }
void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
begin_frame_args_sent_to_children_ = args;
@@ -193,31 +187,6 @@ class FakeSchedulerClient : public SchedulerClient {
TestScheduler* scheduler_;
};
-class SchedulerClientWithFixedEstimates : public FakeSchedulerClient {
- public:
- SchedulerClientWithFixedEstimates(
- base::TimeDelta draw_duration,
- base::TimeDelta begin_main_frame_to_commit_duration,
- base::TimeDelta commit_to_activate_duration)
- : draw_duration_(draw_duration),
- begin_main_frame_to_commit_duration_(
- begin_main_frame_to_commit_duration),
- commit_to_activate_duration_(commit_to_activate_duration) {}
-
- base::TimeDelta DrawDurationEstimate() override { return draw_duration_; }
- base::TimeDelta BeginMainFrameToCommitDurationEstimate() override {
- return begin_main_frame_to_commit_duration_;
- }
- base::TimeDelta CommitToActivateDurationEstimate() override {
- return commit_to_activate_duration_;
- }
-
- private:
- base::TimeDelta draw_duration_;
- base::TimeDelta begin_main_frame_to_commit_duration_;
- base::TimeDelta commit_to_activate_duration_;
-};
-
class FakeExternalBeginFrameSource : public BeginFrameSourceBase {
public:
explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client)
@@ -265,9 +234,11 @@ class SchedulerTest : public testing::Test {
fake_external_begin_frame_source_ =
fake_external_begin_frame_source.get();
}
+ rendering_stats_instrumentation_ = RenderingStatsInstrumentation::Create();
scheduler_ = TestScheduler::Create(now_src_.get(), client_.get(),
scheduler_settings_, 0, task_runner_,
- fake_external_begin_frame_source.Pass());
+ fake_external_begin_frame_source.Pass(),
+ rendering_stats_instrumentation_.get());
DCHECK(scheduler_);
client_->set_scheduler(scheduler_.get());
return scheduler_.get();
@@ -425,6 +396,7 @@ class SchedulerTest : public testing::Test {
SchedulerSettings scheduler_settings_;
scoped_ptr<FakeSchedulerClient> client_;
scoped_ptr<TestScheduler> scheduler_;
+ scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation_;
};
TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
@@ -476,13 +448,13 @@ TEST_F(SchedulerTest, SendBeginFramesToChildrenWithoutCommit) {
TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) {
// Set up client with specified estimates.
- SchedulerClientWithFixedEstimates* client =
- new SchedulerClientWithFixedEstimates(
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(2),
- base::TimeDelta::FromMilliseconds(4));
scheduler_settings_.use_external_begin_frame_source = true;
- SetUpScheduler(make_scoped_ptr(client).Pass(), true);
+ SetUpScheduler(true);
+ scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1));
+ scheduler_->SetBeginMainFrameToCommitDurationEstimate(
+ base::TimeDelta::FromMilliseconds(2));
+ scheduler_->SetCommitToActivateDurationEstimate(
+ base::TimeDelta::FromMilliseconds(4));
EXPECT_FALSE(client_->needs_begin_frames());
scheduler_->SetChildrenNeedBeginFrames(true);
@@ -1321,16 +1293,15 @@ void SchedulerTest::MainFrameInHighLatencyMode(
int64 commit_to_activate_estimate_in_ms,
bool impl_latency_takes_priority,
bool should_send_begin_main_frame) {
- // Set up client with specified estimates (draw duration is set to 1).
- SchedulerClientWithFixedEstimates* client =
- new SchedulerClientWithFixedEstimates(
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(
- begin_main_frame_to_commit_estimate_in_ms),
- base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms));
-
scheduler_settings_.use_external_begin_frame_source = true;
- SetUpScheduler(make_scoped_ptr(client).Pass(), true);
+ SetUpScheduler(true);
+
+ scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1));
+ scheduler_->SetBeginMainFrameToCommitDurationEstimate(
+ base::TimeDelta::FromMilliseconds(
+ begin_main_frame_to_commit_estimate_in_ms));
+ scheduler_->SetCommitToActivateDurationEstimate(
+ base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms));
scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority);
@@ -1345,9 +1316,9 @@ void SchedulerTest::MainFrameInHighLatencyMode(
scheduler_->NotifyReadyToCommit();
scheduler_->NotifyReadyToActivate();
EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode());
- EXPECT_TRUE(client->HasAction("ScheduledActionSendBeginMainFrame"));
+ EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame"));
- client->Reset();
+ client_->Reset();
scheduler_->SetNeedsCommit();
EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode());
EXPECT_SCOPED(AdvanceFrame());
@@ -1355,7 +1326,7 @@ void SchedulerTest::MainFrameInHighLatencyMode(
task_runner().RunPendingTasks(); // Run posted deadline.
EXPECT_EQ(scheduler_->MainThreadIsInHighLatencyMode(),
should_send_begin_main_frame);
- EXPECT_EQ(client->HasAction("ScheduledActionSendBeginMainFrame"),
+ EXPECT_EQ(client_->HasAction("ScheduledActionSendBeginMainFrame"),
should_send_begin_main_frame);
}
@@ -1393,14 +1364,15 @@ TEST_F(
// Since we are simulating a long commit, set up a client with draw duration
// estimates that prevent skipping main frames to get to low latency mode.
- SchedulerClientWithFixedEstimates* client =
- new SchedulerClientWithFixedEstimates(
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(32),
- base::TimeDelta::FromMilliseconds(32));
scheduler_settings_.use_external_begin_frame_source = true;
scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
- SetUpScheduler(make_scoped_ptr(client).Pass(), true);
+ SetUpScheduler(true);
+
+ scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1));
+ scheduler_->SetBeginMainFrameToCommitDurationEstimate(
+ base::TimeDelta::FromMilliseconds(32));
+ scheduler_->SetCommitToActivateDurationEstimate(
+ base::TimeDelta::FromMilliseconds(32));
// Disables automatic swap acks so this test can force swap ack throttling
// to simulate a blocked Browser ui thread.
@@ -1470,15 +1442,16 @@ TEST_F(SchedulerTest,
// Since we are simulating a long commit, set up a client with draw duration
// estimates that prevent skipping main frames to get to low latency mode.
- SchedulerClientWithFixedEstimates* client =
- new SchedulerClientWithFixedEstimates(
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(32),
- base::TimeDelta::FromMilliseconds(32));
scheduler_settings_.use_external_begin_frame_source = true;
scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
scheduler_settings_.main_frame_before_activation_enabled = true;
- SetUpScheduler(make_scoped_ptr(client).Pass(), true);
+ SetUpScheduler(true);
+
+ scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1));
+ scheduler_->SetBeginMainFrameToCommitDurationEstimate(
+ base::TimeDelta::FromMilliseconds(32));
+ scheduler_->SetCommitToActivateDurationEstimate(
+ base::TimeDelta::FromMilliseconds(32));
// Disables automatic swap acks so this test can force swap ack throttling
// to simulate a blocked Browser ui thread.
@@ -1556,15 +1529,16 @@ TEST_F(
// Since we are simulating a long commit, set up a client with draw duration
// estimates that prevent skipping main frames to get to low latency mode.
- SchedulerClientWithFixedEstimates* client =
- new SchedulerClientWithFixedEstimates(
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromMilliseconds(32),
- base::TimeDelta::FromMilliseconds(32));
scheduler_settings_.use_external_begin_frame_source = true;
scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
scheduler_settings_.main_frame_before_activation_enabled = true;
- SetUpScheduler(make_scoped_ptr(client).Pass(), true);
+ SetUpScheduler(true);
+
+ scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1));
+ scheduler_->SetBeginMainFrameToCommitDurationEstimate(
+ base::TimeDelta::FromMilliseconds(32));
+ scheduler_->SetCommitToActivateDurationEstimate(
+ base::TimeDelta::FromMilliseconds(32));
// Disables automatic swap acks so this test can force swap ack throttling
// to simulate a blocked Browser ui thread.

Powered by Google App Engine
This is Rietveld 408576698