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

Side by Side Diff: cc/threaded_unittest.h

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
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 CCThreadedTest_h 5 #ifndef CCThreadedTest_h
6 #define CCThreadedTest_h 6 #define CCThreadedTest_h
7 7
8 #include "CCLayerTreeHost.h" 8 #include "CCLayerTreeHost.h"
9 #include "CCLayerTreeHostImpl.h" 9 #include "CCLayerTreeHostImpl.h"
10 #include "CCScopedThreadProxy.h" 10 #include "CCScopedThreadProxy.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "cc/test/compositor_fake_web_graphics_context_3d.h" 12 #include "cc/test/compositor_fake_web_graphics_context_3d.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include <public/WebAnimationDelegate.h> 14 #include <public/WebAnimationDelegate.h>
15 #include <public/WebThread.h> 15 #include <public/WebThread.h>
16 16
17 namespace cc { 17 namespace cc {
18 class CCLayerImpl; 18 class LayerImpl;
19 class CCLayerTreeHost; 19 class LayerTreeHost;
20 class CCLayerTreeHostClient; 20 class LayerTreeHostClient;
21 class CCLayerTreeHostImpl; 21 class LayerTreeHostImpl;
22 class GraphicsContext3D; 22 class GraphicsContext3D;
23 } 23 }
24 24
25 namespace WebKitTests { 25 namespace WebKitTests {
26 26
27 // Used by test stubs to notify the test when something interesting happens. 27 // Used by test stubs to notify the test when something interesting happens.
28 class TestHooks : public WebKit::WebAnimationDelegate { 28 class TestHooks : public WebKit::WebAnimationDelegate {
29 public: 29 public:
30 virtual void beginCommitOnCCThread(cc::CCLayerTreeHostImpl*) { } 30 virtual void beginCommitOnThread(cc::LayerTreeHostImpl*) { }
31 virtual void commitCompleteOnCCThread(cc::CCLayerTreeHostImpl*) { } 31 virtual void commitCompleteOnThread(cc::LayerTreeHostImpl*) { }
32 virtual bool prepareToDrawOnCCThread(cc::CCLayerTreeHostImpl*); 32 virtual bool prepareToDrawOnThread(cc::LayerTreeHostImpl*);
33 virtual void drawLayersOnCCThread(cc::CCLayerTreeHostImpl*) { } 33 virtual void drawLayersOnThread(cc::LayerTreeHostImpl*) { }
34 virtual void animateLayers(cc::CCLayerTreeHostImpl*, double monotonicTime) { } 34 virtual void animateLayers(cc::LayerTreeHostImpl*, double monotonicTime) { }
35 virtual void willAnimateLayers(cc::CCLayerTreeHostImpl*, double monotonicTim e) { } 35 virtual void willAnimateLayers(cc::LayerTreeHostImpl*, double monotonicTime) { }
36 virtual void applyScrollAndScale(const cc::IntSize&, float) { } 36 virtual void applyScrollAndScale(const cc::IntSize&, float) { }
37 virtual void animate(double monotonicTime) { } 37 virtual void animate(double monotonicTime) { }
38 virtual void layout() { } 38 virtual void layout() { }
39 virtual void didRecreateOutputSurface(bool succeeded) { } 39 virtual void didRecreateOutputSurface(bool succeeded) { }
40 virtual void didAddAnimation() { } 40 virtual void didAddAnimation() { }
41 virtual void didCommit() { } 41 virtual void didCommit() { }
42 virtual void didCommitAndDrawFrame() { } 42 virtual void didCommitAndDrawFrame() { }
43 virtual void scheduleComposite() { } 43 virtual void scheduleComposite() { }
44 44
45 // Implementation of WebAnimationDelegate 45 // Implementation of WebAnimationDelegate
46 virtual void notifyAnimationStarted(double time) OVERRIDE { } 46 virtual void notifyAnimationStarted(double time) OVERRIDE { }
47 virtual void notifyAnimationFinished(double time) OVERRIDE { } 47 virtual void notifyAnimationFinished(double time) OVERRIDE { }
48 48
49 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() ; 49 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() ;
50 }; 50 };
51 51
52 class TimeoutTask; 52 class TimeoutTask;
53 class BeginTask; 53 class BeginTask;
54 54
55 class MockCCLayerTreeHostClient : public cc::CCLayerTreeHostClient { 55 class MockLayerImplTreeHostClient : public cc::LayerTreeHostClient {
56 }; 56 };
57 57
58 // The CCThreadedTests runs with the main loop running. It instantiates a single MockLayerTreeHost and associated 58 // The ThreadedTests runs with the main loop running. It instantiates a single M ockLayerTreeHost and associated
59 // MockLayerTreeHostImpl/MockLayerTreeHostClient. 59 // MockLayerTreeHostImpl/ThreadedMockLayerTreeHostClient.
60 // 60 //
61 // beginTest() is called once the main message loop is running and the layer tre e host is initialized. 61 // beginTest() is called once the main message loop is running and the layer tre e host is initialized.
62 // 62 //
63 // Key stages of the drawing loop, e.g. drawing or commiting, redirect to CCThre adedTest methods of similar names. 63 // Key stages of the drawing loop, e.g. drawing or commiting, redirect to Thread edTest methods of similar names.
64 // To track the commit process, override these functions. 64 // To track the commit process, override these functions.
65 // 65 //
66 // The test continues until someone calls endTest. endTest can be called on any thread, but be aware that 66 // The test continues until someone calls endTest. endTest can be called on any thread, but be aware that
67 // ending the test is an asynchronous process. 67 // ending the test is an asynchronous process.
68 class CCThreadedTest : public testing::Test, public TestHooks { 68 class ThreadedTest : public testing::Test, public TestHooks {
69 public: 69 public:
70 virtual ~CCThreadedTest(); 70 virtual ~ThreadedTest();
71 71
72 virtual void afterTest() = 0; 72 virtual void afterTest() = 0;
73 virtual void beginTest() = 0; 73 virtual void beginTest() = 0;
74 74
75 void endTest(); 75 void endTest();
76 void endTestAfterDelay(int delayMilliseconds); 76 void endTestAfterDelay(int delayMilliseconds);
77 77
78 void postSetNeedsAnimateToMainThread(); 78 void postSetNeedsAnimateToMainThread();
79 void postAddAnimationToMainThread(); 79 void postAddAnimationToMainThread();
80 void postAddInstantAnimationToMainThread(); 80 void postAddInstantAnimationToMainThread();
81 void postSetNeedsCommitToMainThread(); 81 void postSetNeedsCommitToMainThread();
82 void postAcquireLayerTextures(); 82 void postAcquireLayerTextures();
83 void postSetNeedsRedrawToMainThread(); 83 void postSetNeedsRedrawToMainThread();
84 void postSetNeedsAnimateAndCommitToMainThread(); 84 void postSetNeedsAnimateAndCommitToMainThread();
85 void postSetVisibleToMainThread(bool visible); 85 void postSetVisibleToMainThread(bool visible);
86 void postDidAddAnimationToMainThread(); 86 void postDidAddAnimationToMainThread();
87 87
88 void doBeginTest(); 88 void doBeginTest();
89 void timeout(); 89 void timeout();
90 90
91 void clearTimeout() { m_timeoutTask = 0; } 91 void clearTimeout() { m_timeoutTask = 0; }
92 92
93 cc::CCLayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); } 93 cc::LayerTreeHost* layerTreeHost() { return m_layerTreeHost.get(); }
94 94
95 protected: 95 protected:
96 CCThreadedTest(); 96 ThreadedTest();
97 97
98 virtual void initializeSettings(cc::CCLayerTreeSettings&) { } 98 virtual void initializeSettings(cc::LayerTreeSettings&) { }
99 99
100 virtual void scheduleComposite() OVERRIDE; 100 virtual void scheduleComposite() OVERRIDE;
101 101
102 void realEndTest(); 102 void realEndTest();
103 103
104 void dispatchSetNeedsAnimate(); 104 void dispatchSetNeedsAnimate();
105 void dispatchAddInstantAnimation(); 105 void dispatchAddInstantAnimation();
106 void dispatchAddAnimation(); 106 void dispatchAddAnimation();
107 void dispatchSetNeedsAnimateAndCommit(); 107 void dispatchSetNeedsAnimateAndCommit();
108 void dispatchSetNeedsCommit(); 108 void dispatchSetNeedsCommit();
109 void dispatchAcquireLayerTextures(); 109 void dispatchAcquireLayerTextures();
110 void dispatchSetNeedsRedraw(); 110 void dispatchSetNeedsRedraw();
111 void dispatchSetVisible(bool); 111 void dispatchSetVisible(bool);
112 void dispatchComposite(); 112 void dispatchComposite();
113 void dispatchDidAddAnimation(); 113 void dispatchDidAddAnimation();
114 114
115 virtual void runTest(bool threaded); 115 virtual void runTest(bool threaded);
116 WebKit::WebThread* webThread() const { return m_webThread.get(); } 116 WebKit::WebThread* webThread() const { return m_webThread.get(); }
117 117
118 cc::CCLayerTreeSettings m_settings; 118 cc::LayerTreeSettings m_settings;
119 scoped_ptr<MockCCLayerTreeHostClient> m_client; 119 scoped_ptr<MockLayerImplTreeHostClient> m_client;
120 scoped_ptr<cc::CCLayerTreeHost> m_layerTreeHost; 120 scoped_ptr<cc::LayerTreeHost> m_layerTreeHost;
121 121
122 protected: 122 protected:
123 RefPtr<cc::CCScopedThreadProxy> m_mainThreadProxy; 123 RefPtr<cc::ScopedThreadProxy> m_mainThreadProxy;
124 124
125 private: 125 private:
126 bool m_beginning; 126 bool m_beginning;
127 bool m_endWhenBeginReturns; 127 bool m_endWhenBeginReturns;
128 bool m_timedOut; 128 bool m_timedOut;
129 bool m_finished; 129 bool m_finished;
130 bool m_scheduled; 130 bool m_scheduled;
131 bool m_started; 131 bool m_started;
132 132
133 scoped_ptr<WebKit::WebThread> m_webThread; 133 scoped_ptr<WebKit::WebThread> m_webThread;
134 TimeoutTask* m_timeoutTask; 134 TimeoutTask* m_timeoutTask;
135 BeginTask* m_beginTask; 135 BeginTask* m_beginTask;
136 }; 136 };
137 137
138 class CCThreadedTestThreadOnly : public CCThreadedTest { 138 class ThreadedTestThreadOnly : public ThreadedTest {
139 public: 139 public:
140 void runTestThreaded() 140 void runTestThreaded()
141 { 141 {
142 CCThreadedTest::runTest(true); 142 ThreadedTest::runTest(true);
143 } 143 }
144 }; 144 };
145 145
146 // Adapts CCLayerTreeHostImpl for test. Runs real code, then invokes test hooks. 146 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
147 class MockLayerTreeHostImpl : public cc::CCLayerTreeHostImpl { 147 class MockLayerTreeHostImpl : public cc::LayerTreeHostImpl {
148 public: 148 public:
149 static scoped_ptr<MockLayerTreeHostImpl> create(TestHooks*, const cc::CCLaye rTreeSettings&, cc::CCLayerTreeHostImplClient*); 149 static scoped_ptr<MockLayerTreeHostImpl> create(TestHooks*, const cc::LayerT reeSettings&, cc::LayerTreeHostImplClient*);
150 150
151 virtual void beginCommit() OVERRIDE; 151 virtual void beginCommit() OVERRIDE;
152 virtual void commitComplete() OVERRIDE; 152 virtual void commitComplete() OVERRIDE;
153 virtual bool prepareToDraw(FrameData&) OVERRIDE; 153 virtual bool prepareToDraw(FrameData&) OVERRIDE;
154 virtual void drawLayers(const FrameData&) OVERRIDE; 154 virtual void drawLayers(const FrameData&) OVERRIDE;
155 155
156 // Make these public. 156 // Make these public.
157 typedef std::vector<cc::CCLayerImpl*> CCLayerList; 157 typedef std::vector<cc::LayerImpl*> LayerList;
158 using CCLayerTreeHostImpl::calculateRenderSurfaceLayerList; 158 using LayerTreeHostImpl::calculateRenderSurfaceLayerList;
159 159
160 protected: 160 protected:
161 virtual void animateLayers(double monotonicTime, double wallClockTime) OVERR IDE; 161 virtual void animateLayers(double monotonicTime, double wallClockTime) OVERR IDE;
162 virtual base::TimeDelta lowFrequencyAnimationInterval() const OVERRIDE; 162 virtual base::TimeDelta lowFrequencyAnimationInterval() const OVERRIDE;
163 163
164 private: 164 private:
165 MockLayerTreeHostImpl(TestHooks*, const cc::CCLayerTreeSettings&, cc::CCLaye rTreeHostImplClient*); 165 MockLayerTreeHostImpl(TestHooks*, const cc::LayerTreeSettings&, cc::LayerTre eHostImplClient*);
166 166
167 TestHooks* m_testHooks; 167 TestHooks* m_testHooks;
168 }; 168 };
169 169
170 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public WebKit::Com positorFakeWebGraphicsContext3D { 170 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public WebKit::Com positorFakeWebGraphicsContext3D {
171 public: 171 public:
172 static scoped_ptr<CompositorFakeWebGraphicsContext3DWithTextureTracking> cre ate(Attributes); 172 static scoped_ptr<CompositorFakeWebGraphicsContext3DWithTextureTracking> cre ate(Attributes);
173 virtual ~CompositorFakeWebGraphicsContext3DWithTextureTracking(); 173 virtual ~CompositorFakeWebGraphicsContext3DWithTextureTracking();
174 174
175 virtual WebKit::WebGLId createTexture(); 175 virtual WebKit::WebGLId createTexture();
(...skipping 23 matching lines...) Expand all
199 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ 199 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \
200 { \ 200 { \
201 runTest(false); \ 201 runTest(false); \
202 } \ 202 } \
203 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ 203 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \
204 { \ 204 { \
205 runTest(true); \ 205 runTest(true); \
206 } 206 }
207 207
208 #endif // CCThreadedTest_h 208 #endif // CCThreadedTest_h
OLDNEW
« cc/active_animation.h ('K') | « cc/thread_task_unittest.cc ('k') | cc/threaded_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698