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" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include <wtf/OwnPtr.h> | 13 #include <wtf/OwnPtr.h> |
14 | 14 |
15 namespace WebKitTests { | 15 namespace WebKitTests { |
16 | 16 |
17 class FakeCCTimeSourceClient : public cc::CCTimeSourceClient { | 17 class FakeTimeSourceClient : public cc::TimeSourceClient { |
18 public: | 18 public: |
19 FakeCCTimeSourceClient() { reset(); } | 19 FakeTimeSourceClient() { reset(); } |
20 void reset() { m_tickCalled = false; } | 20 void reset() { m_tickCalled = false; } |
21 bool tickCalled() const { return m_tickCalled; } | 21 bool tickCalled() const { return m_tickCalled; } |
22 | 22 |
23 virtual void onTimerTick() OVERRIDE; | 23 virtual void onTimerTick() OVERRIDE; |
24 | 24 |
25 protected: | 25 protected: |
26 bool m_tickCalled; | 26 bool m_tickCalled; |
27 }; | 27 }; |
28 | 28 |
29 class FakeCCThread : public cc::CCThread { | 29 class FakeThread : public cc::Thread { |
30 public: | 30 public: |
31 FakeCCThread(); | 31 FakeThread(); |
32 virtual ~FakeCCThread(); | 32 virtual ~FakeThread(); |
33 | 33 |
34 void reset() | 34 void reset() |
35 { | 35 { |
36 m_pendingTaskDelay = 0; | 36 m_pendingTaskDelay = 0; |
37 m_pendingTask.clear(); | 37 m_pendingTask.clear(); |
38 m_runPendingTaskOnOverwrite = false; | 38 m_runPendingTaskOnOverwrite = false; |
39 } | 39 } |
40 | 40 |
41 void runPendingTaskOnOverwrite(bool enable) | 41 void runPendingTaskOnOverwrite(bool enable) |
42 { | 42 { |
(...skipping 17 matching lines...) Expand all Loading... |
60 virtual void postTask(PassOwnPtr<Task>) OVERRIDE; | 60 virtual void postTask(PassOwnPtr<Task>) OVERRIDE; |
61 virtual void postDelayedTask(PassOwnPtr<Task> task, long long delay) OVERRID
E; | 61 virtual void postDelayedTask(PassOwnPtr<Task> task, long long delay) OVERRID
E; |
62 virtual base::PlatformThreadId threadID() const OVERRIDE; | 62 virtual base::PlatformThreadId threadID() const OVERRIDE; |
63 | 63 |
64 protected: | 64 protected: |
65 OwnPtr<Task> m_pendingTask; | 65 OwnPtr<Task> m_pendingTask; |
66 long long m_pendingTaskDelay; | 66 long long m_pendingTaskDelay; |
67 bool m_runPendingTaskOnOverwrite; | 67 bool m_runPendingTaskOnOverwrite; |
68 }; | 68 }; |
69 | 69 |
70 class FakeCCTimeSource : public cc::CCTimeSource { | 70 class FakeTimeSource : public cc::TimeSource { |
71 public: | 71 public: |
72 FakeCCTimeSource() | 72 FakeTimeSource() |
73 : m_active(false) | 73 : m_active(false) |
74 , m_client(0) | 74 , m_client(0) |
75 { | 75 { |
76 } | 76 } |
77 | 77 |
78 virtual void setClient(cc::CCTimeSourceClient* client) OVERRIDE; | 78 virtual void setClient(cc::TimeSourceClient* client) OVERRIDE; |
79 virtual void setActive(bool b) OVERRIDE; | 79 virtual void setActive(bool b) OVERRIDE; |
80 virtual bool active() const OVERRIDE; | 80 virtual bool active() const OVERRIDE; |
81 virtual void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelt
a interval) OVERRIDE { } | 81 virtual void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelt
a interval) OVERRIDE { } |
82 virtual base::TimeTicks lastTickTime() OVERRIDE; | 82 virtual base::TimeTicks lastTickTime() OVERRIDE; |
83 virtual base::TimeTicks nextTickTime() OVERRIDE; | 83 virtual base::TimeTicks nextTickTime() OVERRIDE; |
84 | 84 |
85 void tick() | 85 void tick() |
86 { | 86 { |
87 ASSERT(m_active); | 87 ASSERT(m_active); |
88 if (m_client) | 88 if (m_client) |
89 m_client->onTimerTick(); | 89 m_client->onTimerTick(); |
90 } | 90 } |
91 | 91 |
92 void setNextTickTime(base::TimeTicks nextTickTime) { m_nextTickTime = nextTi
ckTime; } | 92 void setNextTickTime(base::TimeTicks nextTickTime) { m_nextTickTime = nextTi
ckTime; } |
93 | 93 |
94 protected: | 94 protected: |
95 virtual ~FakeCCTimeSource() { } | 95 virtual ~FakeTimeSource() { } |
96 | 96 |
97 bool m_active; | 97 bool m_active; |
98 base::TimeTicks m_nextTickTime; | 98 base::TimeTicks m_nextTickTime; |
99 cc::CCTimeSourceClient* m_client; | 99 cc::TimeSourceClient* m_client; |
100 }; | 100 }; |
101 | 101 |
102 class FakeCCDelayBasedTimeSource : public cc::CCDelayBasedTimeSource { | 102 class FakeDelayBasedTimeSource : public cc::DelayBasedTimeSource { |
103 public: | 103 public: |
104 static scoped_refptr<FakeCCDelayBasedTimeSource> create(base::TimeDelta inte
rval, cc::CCThread* thread) | 104 static scoped_refptr<FakeDelayBasedTimeSource> create(base::TimeDelta interv
al, cc::Thread* thread) |
105 { | 105 { |
106 return make_scoped_refptr(new FakeCCDelayBasedTimeSource(interval, threa
d)); | 106 return make_scoped_refptr(new FakeDelayBasedTimeSource(interval, thread)
); |
107 } | 107 } |
108 | 108 |
109 void setNow(base::TimeTicks time) { m_now = time; } | 109 void setNow(base::TimeTicks time) { m_now = time; } |
110 virtual base::TimeTicks now() const OVERRIDE; | 110 virtual base::TimeTicks now() const OVERRIDE; |
111 | 111 |
112 protected: | 112 protected: |
113 FakeCCDelayBasedTimeSource(base::TimeDelta interval, cc::CCThread* thread) | 113 FakeDelayBasedTimeSource(base::TimeDelta interval, cc::Thread* thread) |
114 : CCDelayBasedTimeSource(interval, thread) | 114 : DelayBasedTimeSource(interval, thread) |
115 { | 115 { |
116 } | 116 } |
117 virtual ~FakeCCDelayBasedTimeSource() { } | 117 virtual ~FakeDelayBasedTimeSource() { } |
118 | 118 |
119 base::TimeTicks m_now; | 119 base::TimeTicks m_now; |
120 }; | 120 }; |
121 | 121 |
122 class FakeCCFrameRateController : public cc::CCFrameRateController { | 122 class FakeFrameRateController : public cc::FrameRateController { |
123 public: | 123 public: |
124 FakeCCFrameRateController(scoped_refptr<cc::CCTimeSource> timer) : cc::CCFra
meRateController(timer) { } | 124 FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) : cc::FrameRate
Controller(timer) { } |
125 | 125 |
126 int numFramesPending() const { return m_numFramesPending; } | 126 int numFramesPending() const { return m_numFramesPending; } |
127 }; | 127 }; |
128 | 128 |
129 } | 129 } |
130 | 130 |
131 #endif // CCSchedulerTestCommon_h | 131 #endif // CCSchedulerTestCommon_h |
OLD | NEW |