| 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 CCSchedulerTestCommon_h | 5 #ifndef CCSchedulerTestCommon_h |
| 6 #define CCSchedulerTestCommon_h | 6 #define CCSchedulerTestCommon_h |
| 7 | 7 |
| 8 #include "CCDelayBasedTimeSource.h" | 8 #include "CCDelayBasedTimeSource.h" |
| 9 #include "CCFrameRateController.h" | 9 #include "CCFrameRateController.h" |
| 10 #include "CCThread.h" | 10 #include "CCThread.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 protected: | 70 protected: |
| 71 OwnPtr<Task> m_pendingTask; | 71 OwnPtr<Task> m_pendingTask; |
| 72 long long m_pendingTaskDelay; | 72 long long m_pendingTaskDelay; |
| 73 bool m_runPendingTaskOnOverwrite; | 73 bool m_runPendingTaskOnOverwrite; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class FakeCCTimeSource : public cc::CCTimeSource { | 76 class FakeCCTimeSource : public cc::CCTimeSource { |
| 77 public: | 77 public: |
| 78 FakeCCTimeSource() | 78 FakeCCTimeSource() |
| 79 : m_active(false) | 79 : m_active(false) |
| 80 , m_nextTickTime(0) | |
| 81 , m_client(0) | 80 , m_client(0) |
| 82 { | 81 { |
| 83 turnOffVerifier(); | 82 turnOffVerifier(); |
| 84 } | 83 } |
| 85 | 84 |
| 86 virtual ~FakeCCTimeSource() { } | 85 virtual ~FakeCCTimeSource() { } |
| 87 | 86 |
| 88 virtual void setClient(cc::CCTimeSourceClient* client) OVERRIDE { m_client =
client; } | 87 virtual void setClient(cc::CCTimeSourceClient* client) OVERRIDE { m_client =
client; } |
| 89 virtual void setActive(bool b) OVERRIDE { m_active = b; } | 88 virtual void setActive(bool b) OVERRIDE { m_active = b; } |
| 90 virtual bool active() const OVERRIDE { return m_active; } | 89 virtual bool active() const OVERRIDE { return m_active; } |
| 91 virtual void setTimebaseAndInterval(double timebase, double interval) OVERRI
DE { } | 90 virtual void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelt
a interval) OVERRIDE { } |
| 92 virtual double lastTickTime() OVERRIDE { return 0; } | 91 virtual base::TimeTicks lastTickTime() OVERRIDE { return base::TimeTicks();
} |
| 93 virtual double nextTickTimeIfActivated() OVERRIDE { return 0; } | 92 virtual base::TimeTicks nextTickTimeIfActivated() OVERRIDE { return base::Ti
meTicks(); } |
| 94 | 93 |
| 95 void tick() | 94 void tick() |
| 96 { | 95 { |
| 97 ASSERT(m_active); | 96 ASSERT(m_active); |
| 98 if (m_client) | 97 if (m_client) |
| 99 m_client->onTimerTick(); | 98 m_client->onTimerTick(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 void setNextTickTime(double nextTickTime) { m_nextTickTime = nextTickTime; } | 101 void setNextTickTime(base::TimeTicks nextTickTime) { m_nextTickTime = nextTi
ckTime; } |
| 103 | 102 |
| 104 protected: | 103 protected: |
| 105 bool m_active; | 104 bool m_active; |
| 106 double m_nextTickTime; | 105 base::TimeTicks m_nextTickTime; |
| 107 cc::CCTimeSourceClient* m_client; | 106 cc::CCTimeSourceClient* m_client; |
| 108 }; | 107 }; |
| 109 | 108 |
| 110 class FakeCCDelayBasedTimeSource : public cc::CCDelayBasedTimeSource { | 109 class FakeCCDelayBasedTimeSource : public cc::CCDelayBasedTimeSource { |
| 111 public: | 110 public: |
| 112 static PassRefPtr<FakeCCDelayBasedTimeSource> create(double interval, cc::CC
Thread* thread) | 111 static PassRefPtr<FakeCCDelayBasedTimeSource> create(base::TimeDelta interva
l, cc::CCThread* thread) |
| 113 { | 112 { |
| 114 return adoptRef(new FakeCCDelayBasedTimeSource(interval, thread)); | 113 return adoptRef(new FakeCCDelayBasedTimeSource(interval, thread)); |
| 115 } | 114 } |
| 116 | 115 |
| 117 void setMonotonicTimeNow(double time) { m_monotonicTimeNow = time; } | 116 void setNow(base::TimeTicks time) { m_now = time; } |
| 118 virtual double monotonicTimeNow() const OVERRIDE { return m_monotonicTimeNow
; } | 117 virtual base::TimeTicks now() const OVERRIDE { return m_now; } |
| 119 | 118 |
| 120 protected: | 119 protected: |
| 121 FakeCCDelayBasedTimeSource(double interval, cc::CCThread* thread) | 120 FakeCCDelayBasedTimeSource(base::TimeDelta interval, cc::CCThread* thread) |
| 122 : CCDelayBasedTimeSource(interval, thread) | 121 : CCDelayBasedTimeSource(interval, thread) |
| 123 , m_monotonicTimeNow(0) { } | 122 { |
| 123 } |
| 124 | 124 |
| 125 double m_monotonicTimeNow; | 125 base::TimeTicks m_now; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class FakeCCFrameRateController : public cc::CCFrameRateController { | 128 class FakeCCFrameRateController : public cc::CCFrameRateController { |
| 129 public: | 129 public: |
| 130 FakeCCFrameRateController(PassRefPtr<cc::CCTimeSource> timer) : cc::CCFrameR
ateController(timer) { } | 130 FakeCCFrameRateController(PassRefPtr<cc::CCTimeSource> timer) : cc::CCFrameR
ateController(timer) { } |
| 131 | 131 |
| 132 int numFramesPending() const { return m_numFramesPending; } | 132 int numFramesPending() const { return m_numFramesPending; } |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } | 135 } |
| 136 | 136 |
| 137 #endif // CCSchedulerTestCommon_h | 137 #endif // CCSchedulerTestCommon_h |
| OLD | NEW |