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 <gtest/gtest.h> | 12 #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 WebCore::CCTimeSourceClient { | 17 class FakeCCTimeSourceClient : public cc::CCTimeSourceClient { |
18 public: | 18 public: |
19 FakeCCTimeSourceClient() { reset(); } | 19 FakeCCTimeSourceClient() { 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 { m_tickCalled = true; } | 23 virtual void onTimerTick() OVERRIDE { m_tickCalled = true; } |
24 | 24 |
25 protected: | 25 protected: |
26 bool m_tickCalled; | 26 bool m_tickCalled; |
27 }; | 27 }; |
28 | 28 |
29 class FakeCCThread : public WebCore::CCThread { | 29 class FakeCCThread : public cc::CCThread { |
30 public: | 30 public: |
31 FakeCCThread() { reset(); } | 31 FakeCCThread() { reset(); } |
32 void reset() | 32 void reset() |
33 { | 33 { |
34 m_pendingTaskDelay = 0; | 34 m_pendingTaskDelay = 0; |
35 m_pendingTask.clear(); | 35 m_pendingTask.clear(); |
36 m_runPendingTaskOnOverwrite = false; | 36 m_runPendingTaskOnOverwrite = false; |
37 } | 37 } |
38 | 38 |
39 void runPendingTaskOnOverwrite(bool enable) | 39 void runPendingTaskOnOverwrite(bool enable) |
(...skipping 26 matching lines...) Expand all Loading... |
66 m_pendingTaskDelay = delay; | 66 m_pendingTaskDelay = delay; |
67 } | 67 } |
68 virtual base::PlatformThreadId threadID() const { return 0; } | 68 virtual base::PlatformThreadId threadID() const { return 0; } |
69 | 69 |
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 WebCore::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) | 80 , m_nextTickTime(0) |
81 , m_client(0) | 81 , m_client(0) |
82 { | 82 { |
83 turnOffVerifier(); | 83 turnOffVerifier(); |
84 } | 84 } |
85 | 85 |
86 virtual ~FakeCCTimeSource() { } | 86 virtual ~FakeCCTimeSource() { } |
87 | 87 |
88 virtual void setClient(WebCore::CCTimeSourceClient* client) OVERRIDE { m_cli
ent = client; } | 88 virtual void setClient(cc::CCTimeSourceClient* client) OVERRIDE { m_client =
client; } |
89 virtual void setActive(bool b) OVERRIDE { m_active = b; } | 89 virtual void setActive(bool b) OVERRIDE { m_active = b; } |
90 virtual bool active() const OVERRIDE { return m_active; } | 90 virtual bool active() const OVERRIDE { return m_active; } |
91 virtual void setTimebaseAndInterval(double timebase, double interval) OVERRI
DE { } | 91 virtual void setTimebaseAndInterval(double timebase, double interval) OVERRI
DE { } |
92 virtual double lastTickTime() OVERRIDE { return 0; } | 92 virtual double lastTickTime() OVERRIDE { return 0; } |
93 virtual double nextTickTimeIfActivated() OVERRIDE { return 0; } | 93 virtual double nextTickTimeIfActivated() OVERRIDE { return 0; } |
94 | 94 |
95 void tick() | 95 void tick() |
96 { | 96 { |
97 ASSERT(m_active); | 97 ASSERT(m_active); |
98 if (m_client) | 98 if (m_client) |
99 m_client->onTimerTick(); | 99 m_client->onTimerTick(); |
100 } | 100 } |
101 | 101 |
102 void setNextTickTime(double nextTickTime) { m_nextTickTime = nextTickTime; } | 102 void setNextTickTime(double nextTickTime) { m_nextTickTime = nextTickTime; } |
103 | 103 |
104 protected: | 104 protected: |
105 bool m_active; | 105 bool m_active; |
106 double m_nextTickTime; | 106 double m_nextTickTime; |
107 WebCore::CCTimeSourceClient* m_client; | 107 cc::CCTimeSourceClient* m_client; |
108 }; | 108 }; |
109 | 109 |
110 class FakeCCDelayBasedTimeSource : public WebCore::CCDelayBasedTimeSource { | 110 class FakeCCDelayBasedTimeSource : public cc::CCDelayBasedTimeSource { |
111 public: | 111 public: |
112 static PassRefPtr<FakeCCDelayBasedTimeSource> create(double interval, WebCor
e::CCThread* thread) | 112 static PassRefPtr<FakeCCDelayBasedTimeSource> create(double interval, cc::CC
Thread* thread) |
113 { | 113 { |
114 return adoptRef(new FakeCCDelayBasedTimeSource(interval, thread)); | 114 return adoptRef(new FakeCCDelayBasedTimeSource(interval, thread)); |
115 } | 115 } |
116 | 116 |
117 void setMonotonicTimeNow(double time) { m_monotonicTimeNow = time; } | 117 void setMonotonicTimeNow(double time) { m_monotonicTimeNow = time; } |
118 virtual double monotonicTimeNow() const OVERRIDE { return m_monotonicTimeNow
; } | 118 virtual double monotonicTimeNow() const OVERRIDE { return m_monotonicTimeNow
; } |
119 | 119 |
120 protected: | 120 protected: |
121 FakeCCDelayBasedTimeSource(double interval, WebCore::CCThread* thread) | 121 FakeCCDelayBasedTimeSource(double interval, cc::CCThread* thread) |
122 : CCDelayBasedTimeSource(interval, thread) | 122 : CCDelayBasedTimeSource(interval, thread) |
123 , m_monotonicTimeNow(0) { } | 123 , m_monotonicTimeNow(0) { } |
124 | 124 |
125 double m_monotonicTimeNow; | 125 double m_monotonicTimeNow; |
126 }; | 126 }; |
127 | 127 |
128 class FakeCCFrameRateController : public WebCore::CCFrameRateController { | 128 class FakeCCFrameRateController : public cc::CCFrameRateController { |
129 public: | 129 public: |
130 FakeCCFrameRateController(PassRefPtr<WebCore::CCTimeSource> timer) : WebCore
::CCFrameRateController(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 |