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

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

Issue 12623026: cc: Chromify TimeSource, DelayBasedTimeSource and test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Back to doubles Created 7 years, 9 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/scheduler/vsync_time_source_unittest.cc ('k') | cc/test/scheduler_test_common.cc » ('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 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 "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "cc/base/thread.h" 10 #include "cc/base/thread.h"
11 #include "cc/scheduler/delay_based_time_source.h" 11 #include "cc/scheduler/delay_based_time_source.h"
12 #include "cc/scheduler/frame_rate_controller.h" 12 #include "cc/scheduler/frame_rate_controller.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 class FakeTimeSourceClient : public cc::TimeSourceClient { 17 class FakeTimeSourceClient : public cc::TimeSourceClient {
18 public: 18 public:
19 FakeTimeSourceClient() { 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 // TimeSourceClient implementation.
24 virtual void OnTimerTick() OVERRIDE;
24 25
25 protected: 26 protected:
26 bool m_tickCalled; 27 bool m_tickCalled;
27 }; 28 };
28 29
29 class FakeThread : public cc::Thread { 30 class FakeThread : public cc::Thread {
30 public: 31 public:
31 FakeThread(); 32 FakeThread();
32 virtual ~FakeThread(); 33 virtual ~FakeThread();
33 34
(...skipping 30 matching lines...) Expand all
64 }; 65 };
65 66
66 class FakeTimeSource : public cc::TimeSource { 67 class FakeTimeSource : public cc::TimeSource {
67 public: 68 public:
68 FakeTimeSource() 69 FakeTimeSource()
69 : m_active(false) 70 : m_active(false)
70 , m_client(0) 71 , m_client(0)
71 { 72 {
72 } 73 }
73 74
74 virtual void setClient(cc::TimeSourceClient* client) OVERRIDE; 75 virtual void SetClient(cc::TimeSourceClient* client) OVERRIDE;
75 virtual void setActive(bool b) OVERRIDE; 76 virtual void SetActive(bool b) OVERRIDE;
76 virtual bool active() const OVERRIDE; 77 virtual bool Active() const OVERRIDE;
77 virtual void setTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelt a interval) OVERRIDE { } 78 virtual void SetTimebaseAndInterval(base::TimeTicks timebase, base::TimeDelt a interval) OVERRIDE { }
78 virtual base::TimeTicks lastTickTime() OVERRIDE; 79 virtual base::TimeTicks LastTickTime() OVERRIDE;
79 virtual base::TimeTicks nextTickTime() OVERRIDE; 80 virtual base::TimeTicks NextTickTime() OVERRIDE;
80 81
81 void tick() 82 void tick()
82 { 83 {
83 ASSERT_TRUE(m_active); 84 ASSERT_TRUE(m_active);
84 if (m_client) 85 if (m_client)
85 m_client->onTimerTick(); 86 m_client->OnTimerTick();
86 } 87 }
87 88
88 void setNextTickTime(base::TimeTicks nextTickTime) { m_nextTickTime = nextTi ckTime; } 89 void setNextTickTime(base::TimeTicks nextTickTime) { m_nextTickTime = nextTi ckTime; }
89 90
90 protected: 91 protected:
91 virtual ~FakeTimeSource() { } 92 virtual ~FakeTimeSource() { }
92 93
93 bool m_active; 94 bool m_active;
94 base::TimeTicks m_nextTickTime; 95 base::TimeTicks m_nextTickTime;
95 cc::TimeSourceClient* m_client; 96 cc::TimeSourceClient* m_client;
96 }; 97 };
97 98
98 class FakeDelayBasedTimeSource : public cc::DelayBasedTimeSource { 99 class FakeDelayBasedTimeSource : public cc::DelayBasedTimeSource {
99 public: 100 public:
100 static scoped_refptr<FakeDelayBasedTimeSource> create(base::TimeDelta interv al, cc::Thread* thread) 101 static scoped_refptr<FakeDelayBasedTimeSource> create(base::TimeDelta interv al, cc::Thread* thread)
101 { 102 {
102 return make_scoped_refptr(new FakeDelayBasedTimeSource(interval, thread) ); 103 return make_scoped_refptr(new FakeDelayBasedTimeSource(interval, thread) );
103 } 104 }
104 105
105 void setNow(base::TimeTicks time) { m_now = time; } 106 void setNow(base::TimeTicks time) { m_now = time; }
106 virtual base::TimeTicks now() const OVERRIDE; 107 virtual base::TimeTicks Now() const OVERRIDE;
107 108
108 protected: 109 protected:
109 FakeDelayBasedTimeSource(base::TimeDelta interval, cc::Thread* thread) 110 FakeDelayBasedTimeSource(base::TimeDelta interval, cc::Thread* thread)
110 : DelayBasedTimeSource(interval, thread) 111 : DelayBasedTimeSource(interval, thread)
111 { 112 {
112 } 113 }
113 virtual ~FakeDelayBasedTimeSource() { } 114 virtual ~FakeDelayBasedTimeSource() { }
114 115
115 base::TimeTicks m_now; 116 base::TimeTicks m_now;
116 }; 117 };
117 118
118 class FakeFrameRateController : public cc::FrameRateController { 119 class FakeFrameRateController : public cc::FrameRateController {
119 public: 120 public:
120 FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) : cc::FrameRate Controller(timer) { } 121 FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) : cc::FrameRate Controller(timer) { }
121 122
122 int numFramesPending() const { return num_frames_pending_; } 123 int numFramesPending() const { return num_frames_pending_; }
123 }; 124 };
124 125
125 } // namespace cc 126 } // namespace cc
126 127
127 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ 128 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_
OLDNEW
« no previous file with comments | « cc/scheduler/vsync_time_source_unittest.cc ('k') | cc/test/scheduler_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698