Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: cc/test/CCSchedulerTestCommon.h

Issue 10947047: Fix remaining cc files to compile with Clang (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix FakeCCDelayBasedTimeSource Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/test/CCSchedulerTestCommon.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 cc::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;
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 FakeCCThread : public cc::CCThread {
30 public: 30 public:
31 FakeCCThread() { reset(); } 31 FakeCCThread();
32 virtual ~FakeCCThread();
33
32 void reset() 34 void reset()
33 { 35 {
34 m_pendingTaskDelay = 0; 36 m_pendingTaskDelay = 0;
35 m_pendingTask.clear(); 37 m_pendingTask.clear();
36 m_runPendingTaskOnOverwrite = false; 38 m_runPendingTaskOnOverwrite = false;
37 } 39 }
38 40
39 void runPendingTaskOnOverwrite(bool enable) 41 void runPendingTaskOnOverwrite(bool enable)
40 { 42 {
41 m_runPendingTaskOnOverwrite = enable; 43 m_runPendingTaskOnOverwrite = enable;
42 } 44 }
43 45
44 bool hasPendingTask() const { return m_pendingTask; } 46 bool hasPendingTask() const { return m_pendingTask; }
45 void runPendingTask() 47 void runPendingTask()
46 { 48 {
47 ASSERT(m_pendingTask); 49 ASSERT(m_pendingTask);
48 OwnPtr<Task> task = m_pendingTask.release(); 50 OwnPtr<Task> task = m_pendingTask.release();
49 task->performTask(); 51 task->performTask();
50 } 52 }
51 53
52 long long pendingDelayMs() const 54 long long pendingDelayMs() const
53 { 55 {
54 EXPECT_TRUE(hasPendingTask()); 56 EXPECT_TRUE(hasPendingTask());
55 return m_pendingTaskDelay; 57 return m_pendingTaskDelay;
56 } 58 }
57 59
58 virtual void postTask(PassOwnPtr<Task>) { ASSERT_NOT_REACHED(); } 60 virtual void postTask(PassOwnPtr<Task>) OVERRIDE;
59 virtual void postDelayedTask(PassOwnPtr<Task> task, long long delay) 61 virtual void postDelayedTask(PassOwnPtr<Task> task, long long delay) OVERRID E;
60 { 62 virtual base::PlatformThreadId threadID() const OVERRIDE;
61 if (m_runPendingTaskOnOverwrite && hasPendingTask())
62 runPendingTask();
63
64 EXPECT_TRUE(!hasPendingTask());
65 m_pendingTask = task;
66 m_pendingTaskDelay = delay;
67 }
68 virtual base::PlatformThreadId threadID() const { return 0; }
69 63
70 protected: 64 protected:
71 OwnPtr<Task> m_pendingTask; 65 OwnPtr<Task> m_pendingTask;
72 long long m_pendingTaskDelay; 66 long long m_pendingTaskDelay;
73 bool m_runPendingTaskOnOverwrite; 67 bool m_runPendingTaskOnOverwrite;
74 }; 68 };
75 69
76 class FakeCCTimeSource : public cc::CCTimeSource { 70 class FakeCCTimeSource : public cc::CCTimeSource {
77 public: 71 public:
78 FakeCCTimeSource() 72 FakeCCTimeSource()
79 : m_active(false) 73 : m_active(false)
80 , m_client(0) 74 , m_client(0)
81 { 75 {
82 turnOffVerifier(); 76 turnOffVerifier();
83 } 77 }
84 78
85 virtual ~FakeCCTimeSource() { } 79 virtual ~FakeCCTimeSource() { }
86 80
87 virtual void setClient(cc::CCTimeSourceClient* client) OVERRIDE { m_client = client; } 81 virtual void setClient(cc::CCTimeSourceClient* client) OVERRIDE;
88 virtual void setActive(bool b) OVERRIDE { m_active = b; } 82 virtual void setActive(bool b) OVERRIDE;
89 virtual bool active() const OVERRIDE { return m_active; } 83 virtual bool active() const OVERRIDE;
90 virtual void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelt a interval) OVERRIDE { } 84 virtual void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelt a interval) OVERRIDE { }
91 virtual base::TimeTicks lastTickTime() OVERRIDE { return base::TimeTicks(); } 85 virtual base::TimeTicks lastTickTime() OVERRIDE;
92 virtual base::TimeTicks nextTickTimeIfActivated() OVERRIDE { return base::Ti meTicks(); } 86 virtual base::TimeTicks nextTickTimeIfActivated() OVERRIDE;
93 87
94 void tick() 88 void tick()
95 { 89 {
96 ASSERT(m_active); 90 ASSERT(m_active);
97 if (m_client) 91 if (m_client)
98 m_client->onTimerTick(); 92 m_client->onTimerTick();
99 } 93 }
100 94
101 void setNextTickTime(base::TimeTicks nextTickTime) { m_nextTickTime = nextTi ckTime; } 95 void setNextTickTime(base::TimeTicks nextTickTime) { m_nextTickTime = nextTi ckTime; }
102 96
103 protected: 97 protected:
104 bool m_active; 98 bool m_active;
105 base::TimeTicks m_nextTickTime; 99 base::TimeTicks m_nextTickTime;
106 cc::CCTimeSourceClient* m_client; 100 cc::CCTimeSourceClient* m_client;
107 }; 101 };
108 102
109 class FakeCCDelayBasedTimeSource : public cc::CCDelayBasedTimeSource { 103 class FakeCCDelayBasedTimeSource : public cc::CCDelayBasedTimeSource {
110 public: 104 public:
111 static PassRefPtr<FakeCCDelayBasedTimeSource> create(base::TimeDelta interva l, cc::CCThread* thread) 105 static PassRefPtr<FakeCCDelayBasedTimeSource> create(base::TimeDelta interva l, cc::CCThread* thread)
112 { 106 {
113 return adoptRef(new FakeCCDelayBasedTimeSource(interval, thread)); 107 return adoptRef(new FakeCCDelayBasedTimeSource(interval, thread));
114 } 108 }
115 109
116 void setNow(base::TimeTicks time) { m_now = time; } 110 void setNow(base::TimeTicks time) { m_now = time; }
117 virtual base::TimeTicks now() const OVERRIDE { return m_now; } 111 virtual base::TimeTicks now() const OVERRIDE;
118 112
119 protected: 113 protected:
120 FakeCCDelayBasedTimeSource(base::TimeDelta interval, cc::CCThread* thread) 114 FakeCCDelayBasedTimeSource(base::TimeDelta interval, cc::CCThread* thread)
121 : CCDelayBasedTimeSource(interval, thread) 115 : CCDelayBasedTimeSource(interval, thread)
122 { 116 {
123 } 117 }
124 118
125 base::TimeTicks m_now; 119 base::TimeTicks m_now;
126 }; 120 };
127 121
128 class FakeCCFrameRateController : public cc::CCFrameRateController { 122 class FakeCCFrameRateController : public cc::CCFrameRateController {
129 public: 123 public:
130 FakeCCFrameRateController(PassRefPtr<cc::CCTimeSource> timer) : cc::CCFrameR ateController(timer) { } 124 FakeCCFrameRateController(PassRefPtr<cc::CCTimeSource> timer) : cc::CCFrameR ateController(timer) { }
131 125
132 int numFramesPending() const { return m_numFramesPending; } 126 int numFramesPending() const { return m_numFramesPending; }
133 }; 127 };
134 128
135 } 129 }
136 130
137 #endif // CCSchedulerTestCommon_h 131 #endif // CCSchedulerTestCommon_h
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/test/CCSchedulerTestCommon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698