| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_ | 5 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_ |
| 6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_ | 6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 bool tick_called_; | 35 bool tick_called_; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSourceClient); | 38 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSourceClient); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 class FakeDelayBasedTimeSource : public DelayBasedTimeSource { | 41 class FakeDelayBasedTimeSource : public DelayBasedTimeSource { |
| 42 public: | 42 public: |
| 43 static std::unique_ptr<FakeDelayBasedTimeSource> Create( | 43 explicit FakeDelayBasedTimeSource(base::SingleThreadTaskRunner* task_runner) |
| 44 base::TimeDelta interval, | 44 : DelayBasedTimeSource(task_runner) {} |
| 45 base::SingleThreadTaskRunner* task_runner) { | |
| 46 return base::WrapUnique( | |
| 47 new FakeDelayBasedTimeSource(interval, task_runner)); | |
| 48 } | |
| 49 | |
| 50 ~FakeDelayBasedTimeSource() override {} | 45 ~FakeDelayBasedTimeSource() override {} |
| 51 | 46 |
| 52 void SetNow(base::TimeTicks time) { now_ = time; } | 47 void SetNow(base::TimeTicks time) { now_ = time; } |
| 53 base::TimeTicks Now() const override; | 48 base::TimeTicks Now() const override; |
| 54 | 49 |
| 55 protected: | 50 protected: |
| 56 FakeDelayBasedTimeSource(base::TimeDelta interval, | |
| 57 base::SingleThreadTaskRunner* task_runner) | |
| 58 : DelayBasedTimeSource(interval, task_runner) {} | |
| 59 | |
| 60 base::TimeTicks now_; | 51 base::TimeTicks now_; |
| 61 | 52 |
| 62 private: | 53 private: |
| 63 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSource); | 54 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSource); |
| 64 }; | 55 }; |
| 65 | 56 |
| 66 class TestDelayBasedTimeSource : public DelayBasedTimeSource { | 57 class TestDelayBasedTimeSource : public DelayBasedTimeSource { |
| 67 public: | 58 public: |
| 68 static std::unique_ptr<TestDelayBasedTimeSource> Create( | 59 TestDelayBasedTimeSource(base::SimpleTestTickClock* now_src, |
| 69 base::SimpleTestTickClock* now_src, | 60 OrderedSimpleTaskRunner* task_runner); |
| 70 base::TimeDelta interval, | |
| 71 OrderedSimpleTaskRunner* task_runner) { | |
| 72 return base::WrapUnique( | |
| 73 new TestDelayBasedTimeSource(now_src, interval, task_runner)); | |
| 74 } | |
| 75 | |
| 76 ~TestDelayBasedTimeSource() override; | 61 ~TestDelayBasedTimeSource() override; |
| 77 | 62 |
| 78 protected: | 63 protected: |
| 79 TestDelayBasedTimeSource(base::SimpleTestTickClock* now_src, | |
| 80 base::TimeDelta interval, | |
| 81 OrderedSimpleTaskRunner* task_runner); | |
| 82 | |
| 83 // Overridden from DelayBasedTimeSource | 64 // Overridden from DelayBasedTimeSource |
| 84 base::TimeTicks Now() const override; | 65 base::TimeTicks Now() const override; |
| 85 std::string TypeString() const override; | 66 std::string TypeString() const override; |
| 86 | 67 |
| 87 // Not owned. | 68 // Not owned. |
| 88 base::SimpleTestTickClock* now_src_; | 69 base::SimpleTestTickClock* now_src_; |
| 89 | 70 |
| 90 private: | 71 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(TestDelayBasedTimeSource); | 72 DISALLOW_COPY_AND_ASSIGN(TestDelayBasedTimeSource); |
| 92 }; | 73 }; |
| 93 | 74 |
| 94 class FakeBeginFrameSource : public BeginFrameSourceBase { | |
| 95 public: | |
| 96 FakeBeginFrameSource(); | |
| 97 ~FakeBeginFrameSource() override; | |
| 98 | |
| 99 // TODO(sunnyps): Use using BeginFrameSourceBase::CallOnBeginFrame instead. | |
| 100 void TestOnBeginFrame(const BeginFrameArgs& args) { | |
| 101 return CallOnBeginFrame(args); | |
| 102 } | |
| 103 | |
| 104 BeginFrameArgs TestLastUsedBeginFrameArgs() { | |
| 105 if (!observers_.empty()) | |
| 106 return (*observers_.begin())->LastUsedBeginFrameArgs(); | |
| 107 return BeginFrameArgs(); | |
| 108 } | |
| 109 | |
| 110 bool has_observers() const { return !observers_.empty(); } | |
| 111 | |
| 112 using BeginFrameSourceBase::SetBeginFrameSourcePaused; | |
| 113 | |
| 114 private: | |
| 115 DISALLOW_COPY_AND_ASSIGN(FakeBeginFrameSource); | |
| 116 }; | |
| 117 | |
| 118 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { | |
| 119 public: | |
| 120 TestBackToBackBeginFrameSource(base::SimpleTestTickClock* now_src, | |
| 121 base::SingleThreadTaskRunner* task_runner); | |
| 122 ~TestBackToBackBeginFrameSource() override; | |
| 123 | |
| 124 protected: | |
| 125 base::TimeTicks Now() override; | |
| 126 // Not owned. | |
| 127 base::SimpleTestTickClock* now_src_; | |
| 128 | |
| 129 private: | |
| 130 DISALLOW_COPY_AND_ASSIGN(TestBackToBackBeginFrameSource); | |
| 131 }; | |
| 132 | |
| 133 class TestSyntheticBeginFrameSource : public SyntheticBeginFrameSource { | |
| 134 public: | |
| 135 explicit TestSyntheticBeginFrameSource(base::SimpleTestTickClock* now_src, | |
| 136 OrderedSimpleTaskRunner* task_runner, | |
| 137 base::TimeDelta initial_interval); | |
| 138 ~TestSyntheticBeginFrameSource() override; | |
| 139 | |
| 140 private: | |
| 141 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource); | |
| 142 }; | |
| 143 | |
| 144 class FakeCompositorTimingHistory : public CompositorTimingHistory { | 75 class FakeCompositorTimingHistory : public CompositorTimingHistory { |
| 145 public: | 76 public: |
| 146 static std::unique_ptr<FakeCompositorTimingHistory> Create( | 77 static std::unique_ptr<FakeCompositorTimingHistory> Create( |
| 147 bool using_synchronous_renderer_compositor); | 78 bool using_synchronous_renderer_compositor); |
| 148 ~FakeCompositorTimingHistory() override; | 79 ~FakeCompositorTimingHistory() override; |
| 149 | 80 |
| 150 void SetAllEstimatesTo(base::TimeDelta duration); | 81 void SetAllEstimatesTo(base::TimeDelta duration); |
| 151 | 82 |
| 152 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); | 83 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); |
| 153 void SetBeginMainFrameQueueDurationCriticalEstimate(base::TimeDelta duration); | 84 void SetBeginMainFrameQueueDurationCriticalEstimate(base::TimeDelta duration); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 173 |
| 243 private: | 174 private: |
| 244 base::SimpleTestTickClock* now_src_; | 175 base::SimpleTestTickClock* now_src_; |
| 245 | 176 |
| 246 DISALLOW_COPY_AND_ASSIGN(TestScheduler); | 177 DISALLOW_COPY_AND_ASSIGN(TestScheduler); |
| 247 }; | 178 }; |
| 248 | 179 |
| 249 } // namespace cc | 180 } // namespace cc |
| 250 | 181 |
| 251 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 182 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
| OLD | NEW |