Chromium Code Reviews| Index: cc/test/scheduler_test_common.h |
| diff --git a/cc/test/scheduler_test_common.h b/cc/test/scheduler_test_common.h |
| index a50233653410836c44189d5d53381dfaf0d6d3b3..aa0076524e3de08a95182a2c7c2da6c54ef536da 100644 |
| --- a/cc/test/scheduler_test_common.h |
| +++ b/cc/test/scheduler_test_common.h |
| @@ -27,7 +27,7 @@ class FakeTimeSourceClient : public TimeSourceClient { |
| virtual void OnTimerTick() OVERRIDE; |
| protected: |
| - bool tick_called_; |
| + bool tick_called_ = false; |
|
Sami
2014/09/18 13:55:09
I think this is a C++11-ism which we don't allow y
mithro-old
2014/09/19 02:45:39
As Chrome style doesn't seem to used this, I've re
Sami
2014/09/19 13:44:22
Interesting, I didn't know that.
mithro-old
2014/09/23 12:43:54
It has the nice feature that if you forget to init
|
| }; |
| class FakeDelayBasedTimeSource : public DelayBasedTimeSource { |
| @@ -73,6 +73,68 @@ class TestDelayBasedTimeSource : public DelayBasedTimeSource { |
| scoped_refptr<TestNowSource> now_src_; |
| }; |
| +struct FakeBeginFrameSource : public BeginFrameSource { |
| + bool needs_begin_frames_ = false; |
|
Sami
2014/09/18 13:55:09
Ditto.
mithro-old
2014/09/19 02:45:39
Done.
|
| + bool remaining_frames_ = false; |
| + |
| + BeginFrameObserver* GetObserver() { return observer_; } |
| + |
| + void TestSendBeginFrame(const BeginFrameArgs& args) { |
|
brianderson
2014/09/18 21:54:19
TestOnBeginFrame.
mithro-old
2014/09/19 02:45:39
Done.
|
| + CallOnBeginFrame(args); |
| + } |
| + |
| + // BeginFrameSource |
| + virtual bool NeedsBeginFrames() const OVERRIDE; |
| + virtual void SetNeedsBeginFrames(bool needs_begin_frames) OVERRIDE; |
| + virtual void DidFinishFrame(size_t remaining_frames) OVERRIDE; |
| + |
| + virtual void AsValueInto(base::debug::TracedValue* dict) const OVERRIDE; |
| + |
| + virtual ~FakeBeginFrameSource() {} |
| +}; |
| + |
| +class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { |
| + public: |
| + virtual ~TestBackToBackBeginFrameSource(); |
| + |
| + static scoped_ptr<TestBackToBackBeginFrameSource> Create( |
| + scoped_refptr<TestNowSource> now_src, |
| + base::SingleThreadTaskRunner* task_runner) { |
| + return make_scoped_ptr( |
| + new TestBackToBackBeginFrameSource(now_src, task_runner)); |
| + } |
| + |
| + protected: |
| + TestBackToBackBeginFrameSource(scoped_refptr<TestNowSource> now_src, |
| + base::SingleThreadTaskRunner* task_runner); |
| + |
| + virtual base::TimeTicks Now() OVERRIDE; |
| + |
| + scoped_refptr<TestNowSource> now_src_; |
| +}; |
| + |
| +class TestSyntheticBeginFrameSource : public SyntheticBeginFrameSource { |
| + public: |
| + virtual ~TestSyntheticBeginFrameSource(); |
| + |
| + static scoped_ptr<TestSyntheticBeginFrameSource> Create( |
| + scoped_refptr<TestNowSource> now_src, |
| + OrderedSimpleTaskRunner* task_runner, |
| + base::TimeDelta initial_interval) { |
| + base::TimeTicks initial_timebase = now_src->Now(); |
| + return make_scoped_ptr(new TestSyntheticBeginFrameSource( |
| + TestDelayBasedTimeSource::Create( |
| + now_src, initial_interval, task_runner), |
| + initial_timebase, |
| + initial_interval)); |
| + } |
| + |
| + protected: |
| + TestSyntheticBeginFrameSource(scoped_refptr<DelayBasedTimeSource> time_source, |
| + base::TimeTicks initial_timebase, |
| + base::TimeDelta initial_interval); |
| +}; |
| + |
| class TestScheduler : public Scheduler { |
| public: |
| static scoped_ptr<TestScheduler> Create( |
| @@ -85,11 +147,14 @@ class TestScheduler : public Scheduler { |
| scoped_refptr<OrderedSimpleTaskRunner> test_task_runner = |
| new OrderedSimpleTaskRunner(now_src, true); |
| - return make_scoped_ptr(new TestScheduler(now_src, |
| - client, |
| - scheduler_settings, |
| - layer_tree_host_id, |
| - test_task_runner)); |
| + scoped_ptr<TestScheduler> scheduler = |
| + make_scoped_ptr(new TestScheduler(now_src, |
| + client, |
| + scheduler_settings, |
| + layer_tree_host_id, |
| + test_task_runner)); |
| + scheduler->FinalizeSetup(); |
| + return scheduler.Pass(); |
| } |
| // Extra test helper functionality |
| @@ -97,10 +162,7 @@ class TestScheduler : public Scheduler { |
| return begin_retro_frame_args_.empty(); |
| } |
| - bool IsSyntheticBeginFrameSourceActive() const { |
| - return synthetic_begin_frame_source_->IsActive(); |
| - } |
| - |
| + BeginFrameSource& frame_source() { return *frame_source_; } |
| OrderedSimpleTaskRunner& task_runner() { return *test_task_runner_; } |
| virtual ~TestScheduler(); |
| @@ -108,6 +170,8 @@ class TestScheduler : public Scheduler { |
| protected: |
| // Overridden from Scheduler. |
| virtual base::TimeTicks Now() const OVERRIDE; |
| + virtual BeginFrameSource* GetPrimaryBeginFrameSource() OVERRIDE; |
| + virtual BeginFrameSource* GetBackgroundBeginFrameSource() OVERRIDE; |
| private: |
| TestScheduler(scoped_refptr<TestNowSource> now_src, |