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 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/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/time.h" | 10 #include "base/time.h" |
10 #include "cc/base/thread.h" | 11 #include "cc/base/thread.h" |
11 #include "cc/scheduler/delay_based_time_source.h" | 12 #include "cc/scheduler/delay_based_time_source.h" |
12 #include "cc/scheduler/frame_rate_controller.h" | 13 #include "cc/scheduler/frame_rate_controller.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 | 17 |
17 class FakeTimeSourceClient : public cc::TimeSourceClient { | 18 class FakeTimeSourceClient : public cc::TimeSourceClient { |
(...skipping 20 matching lines...) Expand all Loading... |
38 run_pending_task_on_overwrite_ = false; | 39 run_pending_task_on_overwrite_ = false; |
39 } | 40 } |
40 | 41 |
41 void RunPendingTaskOnOverwrite(bool enable) { | 42 void RunPendingTaskOnOverwrite(bool enable) { |
42 run_pending_task_on_overwrite_ = enable; | 43 run_pending_task_on_overwrite_ = enable; |
43 } | 44 } |
44 | 45 |
45 bool HasPendingTask() const { return pending_task_; } | 46 bool HasPendingTask() const { return pending_task_; } |
46 void RunPendingTask(); | 47 void RunPendingTask(); |
47 | 48 |
48 long long PendingDelayMs() const { | 49 int64 PendingDelayMs() const { |
49 EXPECT_TRUE(HasPendingTask()); | 50 EXPECT_TRUE(HasPendingTask()); |
50 return pending_task_delay_; | 51 return pending_task_delay_; |
51 } | 52 } |
52 | 53 |
53 virtual void PostTask(base::Closure cb) OVERRIDE; | 54 virtual void PostTask(base::Closure cb) OVERRIDE; |
54 virtual void PostDelayedTask(base::Closure cb, base::TimeDelta delay) | 55 virtual void PostDelayedTask(base::Closure cb, base::TimeDelta delay) |
55 OVERRIDE; | 56 OVERRIDE; |
56 virtual bool BelongsToCurrentThread() const OVERRIDE; | 57 virtual bool BelongsToCurrentThread() const OVERRIDE; |
57 | 58 |
58 protected: | 59 protected: |
59 scoped_ptr<base::Closure> pending_task_; | 60 scoped_ptr<base::Closure> pending_task_; |
60 long long pending_task_delay_; | 61 int64 pending_task_delay_; |
61 bool run_pending_task_on_overwrite_; | 62 bool run_pending_task_on_overwrite_; |
62 }; | 63 }; |
63 | 64 |
64 class FakeTimeSource : public cc::TimeSource { | 65 class FakeTimeSource : public cc::TimeSource { |
65 public: | 66 public: |
66 FakeTimeSource() : active_(false), client_(0) {} | 67 FakeTimeSource() : active_(false), client_(0) {} |
67 | 68 |
68 virtual void SetClient(cc::TimeSourceClient* client) OVERRIDE; | 69 virtual void SetClient(cc::TimeSourceClient* client) OVERRIDE; |
69 virtual void SetActive(bool b) OVERRIDE; | 70 virtual void SetActive(bool b) OVERRIDE; |
70 virtual bool Active() const OVERRIDE; | 71 virtual bool Active() const OVERRIDE; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 protected: | 105 protected: |
105 FakeDelayBasedTimeSource(base::TimeDelta interval, cc::Thread* thread) | 106 FakeDelayBasedTimeSource(base::TimeDelta interval, cc::Thread* thread) |
106 : DelayBasedTimeSource(interval, thread) {} | 107 : DelayBasedTimeSource(interval, thread) {} |
107 virtual ~FakeDelayBasedTimeSource() {} | 108 virtual ~FakeDelayBasedTimeSource() {} |
108 | 109 |
109 base::TimeTicks now_; | 110 base::TimeTicks now_; |
110 }; | 111 }; |
111 | 112 |
112 class FakeFrameRateController : public cc::FrameRateController { | 113 class FakeFrameRateController : public cc::FrameRateController { |
113 public: | 114 public: |
114 FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) | 115 explicit FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) |
115 : cc::FrameRateController(timer) {} | 116 : cc::FrameRateController(timer) {} |
116 | 117 |
117 int NumFramesPending() const { return num_frames_pending_; } | 118 int NumFramesPending() const { return num_frames_pending_; } |
118 }; | 119 }; |
119 | 120 |
120 } // namespace cc | 121 } // namespace cc |
121 | 122 |
122 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 123 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
OLD | NEW |