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; |
26 class LayerTreeHostClient; | 27 class LayerTreeHostClient; |
27 class LayerTreeHostImpl; | 28 class LayerTreeHostImpl; |
| 29 class RemoteChannelHostClientForTesting; |
| 30 class RemoteChannelHostForTesting; |
| 31 class RemoteChannelImplForTest; |
28 class TestContextProvider; | 32 class TestContextProvider; |
29 class TestGpuMemoryBufferManager; | 33 class TestGpuMemoryBufferManager; |
30 class TestTaskGraphRunner; | 34 class TestTaskGraphRunner; |
31 class TestWebGraphicsContext3D; | 35 class TestWebGraphicsContext3D; |
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, |
(...skipping 84 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 } |
149 TaskRunnerProvider* task_runner_provider() const { | 152 TaskRunnerProvider* task_runner_provider() const { |
150 return layer_tree_host_ ? layer_tree_host_->task_runner_provider() | 153 return layer_tree_host_ ? layer_tree_host_->task_runner_provider() |
151 : nullptr; | 154 : nullptr; |
152 } | 155 } |
153 TaskGraphRunner* task_graph_runner() const; | 156 TaskGraphRunner* task_graph_runner() const; |
154 bool TestEnded() const { return ended_; } | 157 bool TestEnded() const { return ended_; } |
155 | 158 |
156 LayerTreeHost* layer_tree_host(); | 159 LayerTreeHost* layer_tree_host(); |
157 bool delegating_renderer() const { return delegating_renderer_; } | 160 bool delegating_renderer() const { return delegating_renderer_; } |
158 FakeOutputSurface* output_surface() { return output_surface_; } | 161 FakeOutputSurface* output_surface() { return output_surface_; } |
159 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const; | 162 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const; |
160 | 163 |
161 // Use these only for ProxyMain tests in threaded mode. | 164 // 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; | 165 ProxyMainForTest* GetProxyMainForTest() const; |
165 ProxyImplForTest* GetProxyImplForTest() const; | 166 ProxyImplForTest* GetProxyImplForTest() const; |
166 | 167 |
| 168 // Use this only for tests in remote mode. |
| 169 RemoteChannelImplForTest* GetRemoteChannelImplForTest() const; |
| 170 |
167 void DestroyLayerTreeHost(); | 171 void DestroyLayerTreeHost(); |
168 | 172 |
169 // By default, output surface recreation is synchronous. | 173 // By default, output surface recreation is synchronous. |
170 void RequestNewOutputSurface() override; | 174 void RequestNewOutputSurface() override; |
171 // Override this for pixel tests, where you need a real output surface. | 175 // Override this for pixel tests, where you need a real output surface. |
172 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); | 176 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); |
173 // Override this for unit tests, which should not produce pixel output. | 177 // Override this for unit tests, which should not produce pixel output. |
174 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); | 178 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); |
175 | 179 |
| 180 void DidShutdown() override; |
| 181 |
176 TestWebGraphicsContext3D* TestContext(); | 182 TestWebGraphicsContext3D* TestContext(); |
177 | 183 |
178 TestGpuMemoryBufferManager* GetTestGpuMemoryBufferManager() { | 184 TestGpuMemoryBufferManager* GetTestGpuMemoryBufferManager() { |
179 return gpu_memory_buffer_manager_.get(); | 185 return gpu_memory_buffer_manager_.get(); |
180 } | 186 } |
181 | 187 |
| 188 bool IsRemoteTest() const; |
| 189 |
182 private: | 190 private: |
183 LayerTreeSettings settings_; | 191 LayerTreeSettings settings_; |
184 LayerSettings layer_settings_; | 192 LayerSettings layer_settings_; |
185 | 193 |
186 CompositorMode mode_; | 194 CompositorMode mode_; |
187 | 195 |
188 scoped_ptr<LayerTreeHostClientForTesting> client_; | 196 scoped_ptr<LayerTreeHostClientForTesting> client_; |
189 scoped_ptr<LayerTreeHost> layer_tree_host_; | 197 scoped_ptr<LayerTreeHost> layer_tree_host_; |
| 198 scoped_ptr<RemoteChannelHostClientForTesting> remote_channel_host_client_; |
| 199 scoped_ptr<RemoteChannelHostForTesting> remote_channel_host_for_testing_; |
190 FakeOutputSurface* output_surface_; | 200 FakeOutputSurface* output_surface_; |
191 FakeExternalBeginFrameSource* external_begin_frame_source_; | 201 FakeExternalBeginFrameSource* external_begin_frame_source_; |
| 202 RemoteProtoChannelBridge remote_proto_channel_bridge_; |
192 | 203 |
193 bool beginning_; | 204 bool beginning_; |
194 bool end_when_begin_returns_; | 205 bool end_when_begin_returns_; |
195 bool timed_out_; | 206 bool timed_out_; |
196 bool scheduled_; | 207 bool scheduled_; |
197 bool started_; | 208 bool started_; |
198 bool ended_; | 209 bool ended_; |
199 bool delegating_renderer_; | 210 bool delegating_renderer_; |
200 bool verify_property_trees_; | 211 bool verify_property_trees_; |
201 | 212 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 #define MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 250 #define MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
240 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DelegatingRenderer) { \ | 251 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DelegatingRenderer) { \ |
241 RunTest(CompositorMode::Threaded, true); \ | 252 RunTest(CompositorMode::Threaded, true); \ |
242 } \ | 253 } \ |
243 class MultiThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} | 254 class MultiThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
244 | 255 |
245 #define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 256 #define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
246 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 257 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
247 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 258 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
248 | 259 |
| 260 #define REMOTE_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
| 261 TEST_F(TEST_FIXTURE_NAME, RunRemote_DirectRenderer) { \ |
| 262 RunTest(CompositorMode::Remote, false); \ |
| 263 } \ |
| 264 class RemoteDirectImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
| 265 |
249 #define SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 266 #define SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
250 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 267 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
251 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 268 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
252 | 269 |
253 #define SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 270 #define SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
254 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 271 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
255 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 272 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
256 | 273 |
257 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 274 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
258 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 275 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
259 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 276 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
260 | 277 |
261 // Some tests want to control when notify ready for activation occurs, | 278 // Some tests want to control when notify ready for activation occurs, |
262 // but this is not supported in the single-threaded case. | 279 // but this is not supported in the single-threaded case. |
263 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ | 280 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ |
264 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) | 281 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) |
265 | 282 |
266 #endif // CC_TEST_LAYER_TREE_TEST_H_ | 283 #endif // CC_TEST_LAYER_TREE_TEST_H_ |
OLD | NEW |