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

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

Issue 11344004: Remove WebKit::Platform dependencies from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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
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 "base/threading/platform_thread.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/delay_based_time_source.h" 9 #include "cc/delay_based_time_source.h"
10 #include "cc/frame_rate_controller.h" 10 #include "cc/frame_rate_controller.h"
11 #include "cc/thread.h" 11 #include "cc/thread.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include <wtf/OwnPtr.h>
14 13
15 namespace WebKitTests { 14 namespace WebKitTests {
16 15
17 class FakeTimeSourceClient : public cc::TimeSourceClient { 16 class FakeTimeSourceClient : public cc::TimeSourceClient {
18 public: 17 public:
19 FakeTimeSourceClient() { reset(); } 18 FakeTimeSourceClient() { reset(); }
20 void reset() { m_tickCalled = false; } 19 void reset() { m_tickCalled = false; }
21 bool tickCalled() const { return m_tickCalled; } 20 bool tickCalled() const { return m_tickCalled; }
22 21
23 virtual void onTimerTick() OVERRIDE; 22 virtual void onTimerTick() OVERRIDE;
24 23
25 protected: 24 protected:
26 bool m_tickCalled; 25 bool m_tickCalled;
27 }; 26 };
28 27
29 class FakeThread : public cc::Thread { 28 class FakeThread : public cc::Thread {
30 public: 29 public:
31 FakeThread(); 30 FakeThread();
32 virtual ~FakeThread(); 31 virtual ~FakeThread();
33 32
34 void reset() 33 void reset()
35 { 34 {
36 m_pendingTaskDelay = 0; 35 m_pendingTaskDelay = 0;
37 m_pendingTask.clear(); 36 m_pendingTask.reset();
38 m_runPendingTaskOnOverwrite = false; 37 m_runPendingTaskOnOverwrite = false;
39 } 38 }
40 39
41 void runPendingTaskOnOverwrite(bool enable) 40 void runPendingTaskOnOverwrite(bool enable)
42 { 41 {
43 m_runPendingTaskOnOverwrite = enable; 42 m_runPendingTaskOnOverwrite = enable;
44 } 43 }
45 44
46 bool hasPendingTask() const { return m_pendingTask; } 45 bool hasPendingTask() const { return m_pendingTask; }
47 void runPendingTask() 46 void runPendingTask();
48 {
49 ASSERT_TRUE(m_pendingTask);
50 OwnPtr<Task> task = m_pendingTask.release();
51 task->performTask();
52 }
53 47
54 long long pendingDelayMs() const 48 long long pendingDelayMs() const
55 { 49 {
56 EXPECT_TRUE(hasPendingTask()); 50 EXPECT_TRUE(hasPendingTask());
57 return m_pendingTaskDelay; 51 return m_pendingTaskDelay;
58 } 52 }
59 53
60 virtual void postTask(PassOwnPtr<Task>) OVERRIDE; 54 virtual void postTask(base::Closure cb) OVERRIDE;
61 virtual void postDelayedTask(PassOwnPtr<Task> task, long long delay) OVERRID E; 55 virtual void postDelayedTask(base::Closure cb, long long delay) OVERRIDE;
62 virtual base::PlatformThreadId threadID() const OVERRIDE; 56 virtual bool belongsToCurrentThread() const OVERRIDE;
63 57
64 protected: 58 protected:
65 OwnPtr<Task> m_pendingTask; 59 scoped_ptr<base::Closure> m_pendingTask;
66 long long m_pendingTaskDelay; 60 long long m_pendingTaskDelay;
67 bool m_runPendingTaskOnOverwrite; 61 bool m_runPendingTaskOnOverwrite;
68 }; 62 };
69 63
70 class FakeTimeSource : public cc::TimeSource { 64 class FakeTimeSource : public cc::TimeSource {
71 public: 65 public:
72 FakeTimeSource() 66 FakeTimeSource()
73 : m_active(false) 67 : m_active(false)
74 , m_client(0) 68 , m_client(0)
75 { 69 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 class FakeFrameRateController : public cc::FrameRateController { 116 class FakeFrameRateController : public cc::FrameRateController {
123 public: 117 public:
124 FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) : cc::FrameRate Controller(timer) { } 118 FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) : cc::FrameRate Controller(timer) { }
125 119
126 int numFramesPending() const { return m_numFramesPending; } 120 int numFramesPending() const { return m_numFramesPending; }
127 }; 121 };
128 122
129 } 123 }
130 124
131 #endif // CCSchedulerTestCommon_h 125 #endif // CCSchedulerTestCommon_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698