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_LAYER_TREE_TEST_H_ | 5 #ifndef CC_TEST_LAYER_TREE_TEST_H_ |
6 #define CC_TEST_LAYER_TREE_TEST_H_ | 6 #define CC_TEST_LAYER_TREE_TEST_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "cc/animation/animation_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
11 #include "cc/layers/layer_settings.h" | 11 #include "cc/layers/layer_settings.h" |
12 #include "cc/test/proxy_impl_for_test.h" | 12 #include "cc/test/proxy_impl_for_test.h" |
13 #include "cc/test/proxy_main_for_test.h" | 13 #include "cc/test/proxy_main_for_test.h" |
| 14 #include "cc/test/remote_proto_channel_bridge.h" |
14 #include "cc/test/test_hooks.h" | 15 #include "cc/test/test_hooks.h" |
15 #include "cc/trees/layer_tree_host.h" | 16 #include "cc/trees/layer_tree_host.h" |
16 #include "cc/trees/layer_tree_host_impl.h" | 17 #include "cc/trees/layer_tree_host_impl.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 class AnimationPlayer; | 21 class AnimationPlayer; |
21 class FakeExternalBeginFrameSource; | 22 class FakeExternalBeginFrameSource; |
22 class FakeLayerTreeHostClient; | 23 class FakeLayerTreeHostClient; |
23 class FakeOutputSurface; | 24 class FakeOutputSurface; |
24 class LayerImpl; | 25 class LayerImpl; |
25 class LayerTreeHost; | 26 class LayerTreeHost; |
| 27 class LayerTreeHostForTesting; |
26 class LayerTreeHostClient; | 28 class LayerTreeHostClient; |
27 class LayerTreeHostImpl; | 29 class LayerTreeHostImpl; |
| 30 class RemoteChannelImplForTest; |
28 class TestContextProvider; | 31 class TestContextProvider; |
29 class TestGpuMemoryBufferManager; | 32 class TestGpuMemoryBufferManager; |
30 class TestTaskGraphRunner; | 33 class TestTaskGraphRunner; |
31 class TestWebGraphicsContext3D; | 34 class TestWebGraphicsContext3D; |
| 35 class ThreadedChannelForTest; |
32 | 36 |
33 // Creates the virtual viewport layer hierarchy under the given root_layer. | 37 // Creates the virtual viewport layer hierarchy under the given root_layer. |
34 // Convenient overload of the method below that creates a scrolling layer as | 38 // Convenient overload of the method below that creates a scrolling layer as |
35 // the outer viewport scroll layer. | 39 // the outer viewport scroll layer. |
36 void CreateVirtualViewportLayers(Layer* root_layer, | 40 void CreateVirtualViewportLayers(Layer* root_layer, |
37 const gfx::Size& inner_bounds, | 41 const gfx::Size& inner_bounds, |
38 const gfx::Size& outer_bounds, | 42 const gfx::Size& outer_bounds, |
39 const gfx::Size& scroll_bounds, | 43 const gfx::Size& scroll_bounds, |
40 LayerTreeHost* host, | 44 LayerTreeHost* host, |
41 const LayerSettings& layer_settings); | 45 const LayerSettings& layer_settings); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 void DispatchSetVisible(bool visible); | 126 void DispatchSetVisible(bool visible); |
123 void DispatchSetNextCommitForcesRedraw(); | 127 void DispatchSetNextCommitForcesRedraw(); |
124 void DispatchDidAddAnimation(); | 128 void DispatchDidAddAnimation(); |
125 void DispatchCompositeImmediately(); | 129 void DispatchCompositeImmediately(); |
126 | 130 |
127 virtual void AfterTest() = 0; | 131 virtual void AfterTest() = 0; |
128 virtual void WillBeginTest(); | 132 virtual void WillBeginTest(); |
129 virtual void BeginTest() = 0; | 133 virtual void BeginTest() = 0; |
130 virtual void SetupTree(); | 134 virtual void SetupTree(); |
131 | 135 |
132 // TODO(khushalsagar): Add mode for running remote channel tests. | |
133 virtual void RunTest(CompositorMode mode, bool delegating_renderer); | 136 virtual void RunTest(CompositorMode mode, bool delegating_renderer); |
134 | 137 |
135 bool HasImplThread() const { return !!impl_thread_; } | 138 bool HasImplThread() const { return !!impl_thread_; } |
136 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { | 139 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { |
137 DCHECK(task_runner_provider()); | 140 DCHECK(task_runner_provider()); |
138 base::SingleThreadTaskRunner* impl_thread_task_runner = | 141 base::SingleThreadTaskRunner* impl_thread_task_runner = |
139 task_runner_provider()->ImplThreadTaskRunner(); | 142 task_runner_provider()->ImplThreadTaskRunner(); |
140 return impl_thread_task_runner ? impl_thread_task_runner | 143 return impl_thread_task_runner ? impl_thread_task_runner |
141 : main_task_runner_.get(); | 144 : main_task_runner_.get(); |
142 } | 145 } |
143 base::SingleThreadTaskRunner* MainThreadTaskRunner() { | 146 base::SingleThreadTaskRunner* MainThreadTaskRunner() { |
144 return main_task_runner_.get(); | 147 return main_task_runner_.get(); |
145 } | 148 } |
146 Proxy* proxy() const { | 149 Proxy* proxy() const { |
147 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; | 150 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; |
148 } | 151 } |
| 152 Proxy* remote_client_proxy() const; |
149 TaskRunnerProvider* task_runner_provider() const { | 153 TaskRunnerProvider* task_runner_provider() const { |
150 return layer_tree_host_ ? layer_tree_host_->task_runner_provider() | 154 return layer_tree_host_ ? layer_tree_host_->task_runner_provider() |
151 : nullptr; | 155 : nullptr; |
152 } | 156 } |
153 TaskGraphRunner* task_graph_runner() const; | 157 TaskGraphRunner* task_graph_runner() const; |
154 bool TestEnded() const { return ended_; } | 158 bool TestEnded() const { return ended_; } |
155 | 159 |
156 LayerTreeHost* layer_tree_host(); | 160 LayerTreeHost* layer_tree_host(); |
157 bool delegating_renderer() const { return delegating_renderer_; } | 161 bool delegating_renderer() const { return delegating_renderer_; } |
158 FakeOutputSurface* output_surface() { return output_surface_; } | 162 FakeOutputSurface* output_surface() { return output_surface_; } |
159 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const; | 163 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const; |
160 | 164 |
161 // Use these only for ProxyMain tests in threaded mode. | 165 // Use these only for tests in threaded or remote mode. |
162 // TODO(khushalsagar): Update these when adding support for remote channel | |
163 // tests. | |
164 ProxyMainForTest* GetProxyMainForTest() const; | 166 ProxyMainForTest* GetProxyMainForTest() const; |
165 ProxyImplForTest* GetProxyImplForTest() const; | 167 ProxyImplForTest* GetProxyImplForTest() const; |
166 | 168 |
| 169 // Use this only for tests in threaded mode. |
| 170 ThreadedChannelForTest* GetThreadedChannelForTest() const; |
| 171 |
| 172 // Use this only for tests in remote mode. |
| 173 RemoteChannelImplForTest* GetRemoteChannelImplForTest() const; |
| 174 |
167 void DestroyLayerTreeHost(); | 175 void DestroyLayerTreeHost(); |
| 176 void DestroyRemoteClientHost() override; |
| 177 |
| 178 void CreateRemoteClientHost( |
| 179 const proto::CompositorMessageToImpl& proto) override; |
168 | 180 |
169 // By default, output surface recreation is synchronous. | 181 // By default, output surface recreation is synchronous. |
170 void RequestNewOutputSurface() override; | 182 void RequestNewOutputSurface() override; |
171 // Override this for pixel tests, where you need a real output surface. | 183 // Override this for pixel tests, where you need a real output surface. |
172 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); | 184 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); |
173 // Override this for unit tests, which should not produce pixel output. | 185 // Override this for unit tests, which should not produce pixel output. |
174 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); | 186 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); |
175 | 187 |
176 TestWebGraphicsContext3D* TestContext(); | 188 TestWebGraphicsContext3D* TestContext(); |
177 | 189 |
178 TestGpuMemoryBufferManager* GetTestGpuMemoryBufferManager() { | 190 TestGpuMemoryBufferManager* GetTestGpuMemoryBufferManager() { |
179 return gpu_memory_buffer_manager_.get(); | 191 return gpu_memory_buffer_manager_.get(); |
180 } | 192 } |
181 | 193 |
| 194 bool IsRemoteTest() const; |
| 195 |
182 private: | 196 private: |
183 LayerTreeSettings settings_; | 197 LayerTreeSettings settings_; |
184 LayerSettings layer_settings_; | 198 LayerSettings layer_settings_; |
185 | 199 |
186 CompositorMode mode_; | 200 CompositorMode mode_; |
187 | 201 |
188 scoped_ptr<LayerTreeHostClientForTesting> client_; | 202 scoped_ptr<LayerTreeHostClientForTesting> client_; |
189 scoped_ptr<LayerTreeHost> layer_tree_host_; | 203 scoped_ptr<LayerTreeHost> layer_tree_host_; |
| 204 |
| 205 // The LayerTreeHost created by the cc embedder on the client in remote mode. |
| 206 scoped_ptr<LayerTreeHostForTesting> remote_client_layer_tree_host_; |
| 207 |
190 FakeOutputSurface* output_surface_; | 208 FakeOutputSurface* output_surface_; |
191 FakeExternalBeginFrameSource* external_begin_frame_source_; | 209 FakeExternalBeginFrameSource* external_begin_frame_source_; |
| 210 RemoteProtoChannelBridge remote_proto_channel_bridge_; |
192 | 211 |
193 bool beginning_; | 212 bool beginning_; |
194 bool end_when_begin_returns_; | 213 bool end_when_begin_returns_; |
195 bool timed_out_; | 214 bool timed_out_; |
196 bool scheduled_; | 215 bool scheduled_; |
197 bool started_; | 216 bool started_; |
198 bool ended_; | 217 bool ended_; |
199 bool delegating_renderer_; | 218 bool delegating_renderer_; |
200 bool verify_property_trees_; | 219 bool verify_property_trees_; |
201 | 220 |
202 int timeout_seconds_; | 221 int timeout_seconds_; |
203 | 222 |
204 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 223 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
205 scoped_ptr<base::Thread> impl_thread_; | 224 scoped_ptr<base::Thread> impl_thread_; |
206 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 225 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
207 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 226 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
208 scoped_ptr<TestTaskGraphRunner> task_graph_runner_; | 227 scoped_ptr<TestTaskGraphRunner> task_graph_runner_; |
209 base::CancelableClosure timeout_; | 228 base::CancelableClosure timeout_; |
210 scoped_refptr<TestContextProvider> compositor_contexts_; | 229 scoped_refptr<TestContextProvider> compositor_contexts_; |
211 base::WeakPtr<LayerTreeTest> main_thread_weak_ptr_; | 230 base::WeakPtr<LayerTreeTest> main_thread_weak_ptr_; |
212 base::WeakPtrFactory<LayerTreeTest> weak_factory_; | 231 base::WeakPtrFactory<LayerTreeTest> weak_factory_; |
213 }; | 232 }; |
214 | 233 |
215 } // namespace cc | 234 } // namespace cc |
216 | 235 |
217 #define SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 236 #define SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
218 TEST_F(TEST_FIXTURE_NAME, RunSingleThread_DirectRenderer) { \ | 237 TEST_F(TEST_FIXTURE_NAME, RunSingleThread_DirectRenderer) { \ |
219 RunTest(CompositorMode::SingleThreaded, false); \ | 238 RunTest(CompositorMode::SINGLE_THREADED, false); \ |
220 } \ | 239 } \ |
221 class SingleThreadDirectImplNeedsSemicolon##TEST_FIXTURE_NAME {} | 240 class SingleThreadDirectImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
222 | 241 |
223 #define SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 242 #define SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
224 TEST_F(TEST_FIXTURE_NAME, RunSingleThread_DelegatingRenderer) { \ | 243 TEST_F(TEST_FIXTURE_NAME, RunSingleThread_DelegatingRenderer) { \ |
225 RunTest(CompositorMode::SingleThreaded, true); \ | 244 RunTest(CompositorMode::SINGLE_THREADED, true); \ |
226 } \ | 245 } \ |
227 class SingleThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} | 246 class SingleThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
228 | 247 |
229 #define SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 248 #define SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
230 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 249 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
231 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 250 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
232 | 251 |
233 #define MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 252 #define MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
234 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DirectRenderer) { \ | 253 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DirectRenderer) { \ |
235 RunTest(CompositorMode::Threaded, false); \ | 254 RunTest(CompositorMode::THREADED, false); \ |
236 } \ | 255 } \ |
237 class MultiThreadDirectImplNeedsSemicolon##TEST_FIXTURE_NAME {} | 256 class MultiThreadDirectImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
238 | 257 |
239 #define MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 258 #define MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
240 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DelegatingRenderer) { \ | 259 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DelegatingRenderer) { \ |
241 RunTest(CompositorMode::Threaded, true); \ | 260 RunTest(CompositorMode::THREADED, true); \ |
242 } \ | 261 } \ |
243 class MultiThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} | 262 class MultiThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
244 | 263 |
245 #define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 264 #define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
246 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 265 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
247 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 266 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
248 | 267 |
| 268 // The Remote mode tests don't need to run for delegated renderer. |
| 269 #define REMOTE_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
| 270 TEST_F(TEST_FIXTURE_NAME, RunRemote_DirectRenderer) { \ |
| 271 RunTest(CompositorMode::REMOTE, false); \ |
| 272 } \ |
| 273 class RemoteDirectImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
| 274 |
249 #define SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 275 #define SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
250 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 276 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
251 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 277 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
252 | 278 |
253 #define SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 279 #define SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
254 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 280 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
255 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 281 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
256 | 282 |
257 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 283 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
258 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 284 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
259 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 285 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
260 | 286 |
261 // Some tests want to control when notify ready for activation occurs, | 287 // Some tests want to control when notify ready for activation occurs, |
262 // but this is not supported in the single-threaded case. | 288 // but this is not supported in the single-threaded case. |
263 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ | 289 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ |
264 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) | 290 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) |
265 | 291 |
266 #endif // CC_TEST_LAYER_TREE_TEST_H_ | 292 #endif // CC_TEST_LAYER_TREE_TEST_H_ |
OLD | NEW |