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; |
36 class ThreadedChannelForTest; | |
32 | 37 |
33 // Creates the virtual viewport layer hierarchy under the given root_layer. | 38 // Creates the virtual viewport layer hierarchy under the given root_layer. |
34 // Convenient overload of the method below that creates a scrolling layer as | 39 // Convenient overload of the method below that creates a scrolling layer as |
35 // the outer viewport scroll layer. | 40 // the outer viewport scroll layer. |
36 void CreateVirtualViewportLayers(Layer* root_layer, | 41 void CreateVirtualViewportLayers(Layer* root_layer, |
37 const gfx::Size& inner_bounds, | 42 const gfx::Size& inner_bounds, |
38 const gfx::Size& outer_bounds, | 43 const gfx::Size& outer_bounds, |
39 const gfx::Size& scroll_bounds, | 44 const gfx::Size& scroll_bounds, |
40 LayerTreeHost* host, | 45 LayerTreeHost* host, |
41 const LayerSettings& layer_settings); | 46 const LayerSettings& layer_settings); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 void DispatchSetVisible(bool visible); | 127 void DispatchSetVisible(bool visible); |
123 void DispatchSetNextCommitForcesRedraw(); | 128 void DispatchSetNextCommitForcesRedraw(); |
124 void DispatchDidAddAnimation(); | 129 void DispatchDidAddAnimation(); |
125 void DispatchCompositeImmediately(); | 130 void DispatchCompositeImmediately(); |
126 | 131 |
127 virtual void AfterTest() = 0; | 132 virtual void AfterTest() = 0; |
128 virtual void WillBeginTest(); | 133 virtual void WillBeginTest(); |
129 virtual void BeginTest() = 0; | 134 virtual void BeginTest() = 0; |
130 virtual void SetupTree(); | 135 virtual void SetupTree(); |
131 | 136 |
132 // TODO(khushalsagar): Add mode for running remote channel tests. | |
133 virtual void RunTest(CompositorMode mode, bool delegating_renderer); | 137 virtual void RunTest(CompositorMode mode, bool delegating_renderer); |
134 | 138 |
135 bool HasImplThread() const { return !!impl_thread_; } | 139 bool HasImplThread() const { return !!impl_thread_; } |
136 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { | 140 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { |
137 DCHECK(task_runner_provider()); | 141 DCHECK(task_runner_provider()); |
138 base::SingleThreadTaskRunner* impl_thread_task_runner = | 142 base::SingleThreadTaskRunner* impl_thread_task_runner = |
139 task_runner_provider()->ImplThreadTaskRunner(); | 143 task_runner_provider()->ImplThreadTaskRunner(); |
140 return impl_thread_task_runner ? impl_thread_task_runner | 144 return impl_thread_task_runner ? impl_thread_task_runner |
141 : main_task_runner_.get(); | 145 : main_task_runner_.get(); |
142 } | 146 } |
143 base::SingleThreadTaskRunner* MainThreadTaskRunner() { | 147 base::SingleThreadTaskRunner* MainThreadTaskRunner() { |
144 return main_task_runner_.get(); | 148 return main_task_runner_.get(); |
145 } | 149 } |
146 Proxy* proxy() const { | 150 Proxy* proxy() const { |
147 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; | 151 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; |
148 } | 152 } |
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 DestroyRemoteChannelHost(); | |
168 | 177 |
169 // By default, output surface recreation is synchronous. | 178 // By default, output surface recreation is synchronous. |
170 void RequestNewOutputSurface() override; | 179 void RequestNewOutputSurface() override; |
171 // Override this for pixel tests, where you need a real output surface. | 180 // Override this for pixel tests, where you need a real output surface. |
172 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); | 181 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); |
173 // Override this for unit tests, which should not produce pixel output. | 182 // Override this for unit tests, which should not produce pixel output. |
174 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); | 183 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); |
175 | 184 |
176 TestWebGraphicsContext3D* TestContext(); | 185 TestWebGraphicsContext3D* TestContext(); |
177 | 186 |
178 TestGpuMemoryBufferManager* GetTestGpuMemoryBufferManager() { | 187 TestGpuMemoryBufferManager* GetTestGpuMemoryBufferManager() { |
179 return gpu_memory_buffer_manager_.get(); | 188 return gpu_memory_buffer_manager_.get(); |
180 } | 189 } |
181 | 190 |
191 bool IsRemoteTest() const; | |
192 | |
182 private: | 193 private: |
194 void DidShutdown() override; | |
195 | |
183 LayerTreeSettings settings_; | 196 LayerTreeSettings settings_; |
184 LayerSettings layer_settings_; | 197 LayerSettings layer_settings_; |
185 | 198 |
186 CompositorMode mode_; | 199 CompositorMode mode_; |
187 | 200 |
188 scoped_ptr<LayerTreeHostClientForTesting> client_; | 201 scoped_ptr<LayerTreeHostClientForTesting> client_; |
189 scoped_ptr<LayerTreeHost> layer_tree_host_; | 202 scoped_ptr<LayerTreeHost> layer_tree_host_; |
203 scoped_ptr<RemoteChannelHostClientForTesting> remote_channel_host_client_; | |
204 scoped_ptr<RemoteChannelHostForTesting> remote_channel_host_for_testing_; | |
190 FakeOutputSurface* output_surface_; | 205 FakeOutputSurface* output_surface_; |
191 FakeExternalBeginFrameSource* external_begin_frame_source_; | 206 FakeExternalBeginFrameSource* external_begin_frame_source_; |
207 RemoteProtoChannelBridge remote_proto_channel_bridge_; | |
vmpstr
2016/01/07 19:08:12
What's this?
Khushal
2016/01/08 21:17:19
Its just a helper class to send protos directly be
| |
192 | 208 |
193 bool beginning_; | 209 bool beginning_; |
194 bool end_when_begin_returns_; | 210 bool end_when_begin_returns_; |
195 bool timed_out_; | 211 bool timed_out_; |
196 bool scheduled_; | 212 bool scheduled_; |
197 bool started_; | 213 bool started_; |
198 bool ended_; | 214 bool ended_; |
199 bool delegating_renderer_; | 215 bool delegating_renderer_; |
200 bool verify_property_trees_; | 216 bool verify_property_trees_; |
201 | 217 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 #define MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 255 #define MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
240 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DelegatingRenderer) { \ | 256 TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DelegatingRenderer) { \ |
241 RunTest(CompositorMode::Threaded, true); \ | 257 RunTest(CompositorMode::Threaded, true); \ |
242 } \ | 258 } \ |
243 class MultiThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} | 259 class MultiThreadDelegatingImplNeedsSemicolon##TEST_FIXTURE_NAME {} |
244 | 260 |
245 #define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 261 #define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
246 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 262 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
247 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 263 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
248 | 264 |
265 // The Remote mode tests don't need to run for delegated renderer. | |
266 #define REMOTE_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | |
267 TEST_F(TEST_FIXTURE_NAME, RunRemote_DirectRenderer) { \ | |
268 RunTest(CompositorMode::Remote, false); \ | |
269 } \ | |
270 class RemoteDirectImplNeedsSemicolon##TEST_FIXTURE_NAME {} | |
271 | |
249 #define SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 272 #define SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
250 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 273 SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
251 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 274 MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
252 | 275 |
253 #define SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ | 276 #define SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \ |
254 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 277 SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
255 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 278 MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
256 | 279 |
257 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 280 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
258 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 281 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
259 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 282 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
260 | 283 |
261 // Some tests want to control when notify ready for activation occurs, | 284 // Some tests want to control when notify ready for activation occurs, |
262 // but this is not supported in the single-threaded case. | 285 // but this is not supported in the single-threaded case. |
263 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ | 286 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ |
264 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) | 287 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) |
265 | 288 |
266 #endif // CC_TEST_LAYER_TREE_TEST_H_ | 289 #endif // CC_TEST_LAYER_TREE_TEST_H_ |
OLD | NEW |