Index: cc/scheduler/scheduler_unittest.cc |
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc |
index 5d58d2a0be6195501488bbecd5d298ba0c601331..93a04aac6bddba985e0c99c546c3d047772a4a8c 100644 |
--- a/cc/scheduler/scheduler_unittest.cc |
+++ b/cc/scheduler/scheduler_unittest.cc |
@@ -51,7 +51,6 @@ class FakeSchedulerClient : public SchedulerClient { |
public: |
FakeSchedulerClient() |
: automatic_swap_ack_(true), |
- begin_frame_is_sent_to_children_(false), |
scheduler_(nullptr) { |
Reset(); |
} |
@@ -63,11 +62,9 @@ class FakeSchedulerClient : public SchedulerClient { |
swap_will_happen_if_draw_happens_ = true; |
num_draws_ = 0; |
log_anticipated_draw_time_change_ = false; |
- begin_frame_is_sent_to_children_ = false; |
} |
void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; } |
- |
// Most tests don't care about DidAnticipatedDrawTimeChange, so only record it |
// for tests that do. |
void set_log_anticipated_draw_time_change(bool log) { |
@@ -157,20 +154,12 @@ class FakeSchedulerClient : public SchedulerClient { |
void DidBeginImplFrameDeadline() override {} |
- void SendBeginFramesToChildren(const BeginFrameArgs& args) override { |
- begin_frame_is_sent_to_children_ = true; |
- } |
- |
base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { |
return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback, |
base::Unretained(this), |
state); |
} |
- bool begin_frame_is_sent_to_children() const { |
- return begin_frame_is_sent_to_children_; |
- } |
- |
void PushAction(const char* description) { |
actions_.push_back(description); |
states_.push_back(scheduler_->AsValue()); |
@@ -186,13 +175,28 @@ class FakeSchedulerClient : public SchedulerClient { |
bool automatic_swap_ack_; |
int num_draws_; |
bool log_anticipated_draw_time_change_; |
- bool begin_frame_is_sent_to_children_; |
base::TimeTicks posted_begin_impl_frame_deadline_; |
std::vector<const char*> actions_; |
std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat>> states_; |
TestScheduler* scheduler_; |
}; |
+class FakeProxyBeginFrameSource : public ProxyBeginFrameSource { |
+ public: |
+ FakeProxyBeginFrameSource() : begin_frame_is_sent_to_children_(false) {} |
+ ~FakeProxyBeginFrameSource() override {} |
+ |
+ bool begin_frame_is_sent_to_children() { |
+ return begin_frame_is_sent_to_children_; |
+ } |
+ |
+ void BeginFrames(const BeginFrameArgs& args) override { |
+ begin_frame_is_sent_to_children_ = true; |
+ } |
+ |
+ private: |
+ bool begin_frame_is_sent_to_children_; |
+}; |
class FakePowerMonitorSource : public base::PowerMonitorSource { |
public: |
FakePowerMonitorSource() {} |
@@ -256,9 +260,14 @@ class SchedulerTest : public testing::Test { |
fake_external_begin_frame_source_ = |
fake_external_begin_frame_source.get(); |
} |
+ |
+ if (scheduler_settings_.forward_begin_frames_to_children) { |
+ fake_proxy_begin_frame_source_.reset(new FakeProxyBeginFrameSource); |
+ } |
scheduler_ = TestScheduler::Create( |
now_src_, client_.get(), scheduler_settings_, 0, task_runner_, |
- &power_monitor_, fake_external_begin_frame_source.Pass()); |
+ &power_monitor_, fake_external_begin_frame_source.Pass(), |
+ fake_proxy_begin_frame_source_.get()); |
DCHECK(scheduler_); |
client_->set_scheduler(scheduler_.get()); |
return scheduler_.get(); |
@@ -282,6 +291,10 @@ class SchedulerTest : public testing::Test { |
CreateScheduler(); |
} |
+ bool begin_frame_is_sent_to_children() const { |
+ return fake_proxy_begin_frame_source_->begin_frame_is_sent_to_children(); |
+ } |
+ |
OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } |
TestNowSource* now_src() { return now_src_.get(); } |
@@ -409,6 +422,7 @@ class SchedulerTest : public testing::Test { |
FakeExternalBeginFrameSource* fake_external_begin_frame_source_; |
FakePowerMonitorSource* fake_power_monitor_source_; |
base::PowerMonitor power_monitor_; |
+ scoped_ptr<FakeProxyBeginFrameSource> fake_proxy_begin_frame_source_; |
SchedulerSettings scheduler_settings_; |
scoped_ptr<FakeSchedulerClient> client_; |
scoped_ptr<TestScheduler> scheduler_; |
@@ -432,7 +446,7 @@ TEST_F(SchedulerTest, SendBeginFramesToChildren) { |
scheduler_settings_.forward_begin_frames_to_children = true; |
SetUpScheduler(true); |
- EXPECT_FALSE(client_->begin_frame_is_sent_to_children()); |
+ EXPECT_FALSE(begin_frame_is_sent_to_children()); |
scheduler_->SetNeedsCommit(); |
EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
EXPECT_TRUE(client_->needs_begin_frames()); |
@@ -441,7 +455,7 @@ TEST_F(SchedulerTest, SendBeginFramesToChildren) { |
client_->Reset(); |
EXPECT_SCOPED(AdvanceFrame()); |
- EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
+ EXPECT_TRUE(begin_frame_is_sent_to_children()); |
EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
@@ -460,7 +474,7 @@ TEST_F(SchedulerTest, SendBeginFramesToChildrenWithoutCommit) { |
client_->Reset(); |
EXPECT_SCOPED(AdvanceFrame()); |
- EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
+ EXPECT_TRUE(begin_frame_is_sent_to_children()); |
} |
TEST_F(SchedulerTest, RequestCommit) { |