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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 add50ca6b0ffe013d3ab31c0cd41328bb331d902..a34ed1d750d56cac211e3d4d2569d6e35f8066ca 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -45,11 +45,10 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
class FakeSchedulerClient : public SchedulerClient {
public:
- struct FakeBeginFrameSourceForFakeSchedulerClient
- : public FakeBeginFrameSource {
- FakeSchedulerClient* client_;
-
- explicit FakeBeginFrameSourceForFakeSchedulerClient(
+ class FakeExternalBeginFrameSourceForFakeSchedulerClient
+ : public ExternalBeginFrameSource {
+ public:
+ explicit FakeExternalBeginFrameSourceForFakeSchedulerClient(
FakeSchedulerClient* client)
: client_(client) {}
@@ -61,14 +60,22 @@ class FakeSchedulerClient : public SchedulerClient {
}
client_->states_.push_back(client_->scheduler_->AsValue());
}
+
+ void TestOnBeginFrame(const BeginFrameArgs& args) {
+ return CallOnBeginFrame(args);
+ }
+
+ private:
+ virtual ~FakeExternalBeginFrameSourceForFakeSchedulerClient() {}
+
+ FakeSchedulerClient* client_;
};
FakeSchedulerClient()
: automatic_swap_ack_(true),
swap_contains_incomplete_tile_(false),
redraw_will_happen_if_update_visible_tiles_happens_(false),
- now_src_(TestNowSource::Create()),
- fake_frame_source_(this) {
+ now_src_(TestNowSource::Create()) {
Reset();
}
@@ -82,7 +89,12 @@ class FakeSchedulerClient : public SchedulerClient {
}
TestScheduler* CreateScheduler(const SchedulerSettings& settings) {
- scheduler_ = TestScheduler::Create(now_src_, this, settings, 0);
+ if (settings.begin_frame_scheduling_enabled) {
+ fake_external_frame_source_ =
+ new FakeExternalBeginFrameSourceForFakeSchedulerClient(this);
+ }
+ scheduler_ = TestScheduler::Create(
+ now_src_, this, settings, 0, fake_external_frame_source_);
DCHECK(scheduler_);
// Fail if we need to run 100 tasks in a row.
task_runner().SetRunTaskLimit(100);
@@ -94,7 +106,7 @@ class FakeSchedulerClient : public SchedulerClient {
void set_log_anticipated_draw_time_change(bool log) {
log_anticipated_draw_time_change_ = log;
}
- bool needs_begin_frames() { return fake_frame_source_.NeedsBeginFrames(); }
+ bool needs_begin_frames() { return scheduler_->NeedsBeginFrames(); }
int num_draws() const { return num_draws_; }
int num_actions_() const { return static_cast<int>(actions_.size()); }
const char* Action(int i) const { return actions_[i]; }
@@ -107,19 +119,21 @@ class FakeSchedulerClient : public SchedulerClient {
return scheduler_->settings().begin_frame_scheduling_enabled &&
scheduler_->settings().throttle_frame_production;
}
- virtual FakeBeginFrameSource* ExternalBeginFrameSource() override {
- return &fake_frame_source_;
+
+ FakeExternalBeginFrameSourceForFakeSchedulerClient*
+ ExternalBeginFrameSource() {
+ DCHECK(ExternalBeginFrame());
+ return fake_external_frame_source_.get();
}
void AdvanceFrame() {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
"FakeSchedulerClient::AdvanceFrame");
- // EXPECT_TRUE(needs_begin_frames());
if (ExternalBeginFrame()) {
// Creep the time forward so that any BeginFrameArgs is not equal to the
// last one otherwise we violate the BeginFrameSource contract.
now_src_->AdvanceNowMicroseconds(1);
- fake_frame_source_.TestOnBeginFrame(
+ fake_external_frame_source_->TestOnBeginFrame(
CreateBeginFrameArgsForTesting(now_src_));
EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
}
@@ -259,7 +273,8 @@ class FakeSchedulerClient : public SchedulerClient {
std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_;
scoped_ptr<TestScheduler> scheduler_;
scoped_refptr<TestNowSource> now_src_;
- FakeBeginFrameSourceForFakeSchedulerClient fake_frame_source_;
+ scoped_refptr<FakeExternalBeginFrameSourceForFakeSchedulerClient>
+ fake_external_frame_source_;
};
void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
@@ -295,8 +310,6 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
client->task_runner().RunTasksWhile(client->ImplFrameDeadlinePending(true));
EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
-
- // EXPECT_FALSE(client->needs_begin_frames());
}
TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
@@ -1385,7 +1398,7 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled,
// without calling SetNeedsBeginFrame.
client.Reset();
scheduler->SetNeedsCommit();
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
EXPECT_NO_ACTION(client);
client.Reset();
@@ -1395,21 +1408,21 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled,
EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// If we don't swap on the deadline, we wait for the next BeginFrame.
client.task_runner().RunPendingTasks(); // Run posted deadline.
EXPECT_NO_ACTION(client);
EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// NotifyReadyToCommit should trigger the commit.
scheduler->NotifyBeginMainFrameStarted();
scheduler->NotifyReadyToCommit();
EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// BeginImplFrame should prepare the draw.
@@ -1417,14 +1430,14 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled,
EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// BeginImplFrame deadline should draw.
client.task_runner().RunTasksWhile(client.ImplFrameDeadlinePending(true));
EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
@@ -1483,7 +1496,7 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled,
// SetNeedsCommit should begin the frame on the next BeginImplFrame.
client.Reset();
scheduler->SetNeedsCommit();
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
EXPECT_NO_ACTION(client);
client.Reset();
@@ -1492,14 +1505,14 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled,
EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// NotifyReadyToCommit should trigger the pending commit and draw.
scheduler->NotifyBeginMainFrameStarted();
scheduler->NotifyReadyToCommit();
EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// Swapping will put us into a swap throttled state.
@@ -1507,7 +1520,7 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled,
EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// While swap throttled, BeginFrames should trigger BeginImplFrames,
@@ -1516,14 +1529,14 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled,
client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
EXPECT_ACTION("WillBeginImplFrame", client, 0, 1);
EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// Take us out of a swap throttled state.
scheduler->DidSwapBuffersComplete();
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1);
EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
// BeginImplFrame deadline should draw.
@@ -1532,7 +1545,7 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled,
EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
- EXPECT_FALSE(client.needs_begin_frames());
+ EXPECT_TRUE(client.needs_begin_frames());
client.Reset();
}

Powered by Google App Engine
This is Rietveld 408576698