| 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/test/proxy_impl_for_test.h" | |
| 12 #include "cc/test/proxy_main_for_test.h" | |
| 13 #include "cc/test/remote_proto_channel_bridge.h" | 11 #include "cc/test/remote_proto_channel_bridge.h" |
| 14 #include "cc/test/test_hooks.h" | 12 #include "cc/test/test_hooks.h" |
| 15 #include "cc/trees/layer_tree_host.h" | 13 #include "cc/trees/layer_tree_host.h" |
| 16 #include "cc/trees/layer_tree_host_impl.h" | 14 #include "cc/trees/layer_tree_host_impl.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 16 |
| 19 namespace cc { | 17 namespace cc { |
| 20 class AnimationPlayer; | 18 class AnimationPlayer; |
| 21 class FakeExternalBeginFrameSource; | 19 class FakeExternalBeginFrameSource; |
| 22 class FakeLayerTreeHostClient; | 20 class FakeLayerTreeHostClient; |
| 23 class FakeOutputSurface; | 21 class FakeOutputSurface; |
| 24 class LayerImpl; | 22 class LayerImpl; |
| 25 class LayerTreeHost; | 23 class LayerTreeHost; |
| 26 class LayerTreeHostForTesting; | 24 class LayerTreeHostForTesting; |
| 27 class LayerTreeHostClient; | 25 class LayerTreeHostClient; |
| 28 class LayerTreeHostImpl; | 26 class LayerTreeHostImpl; |
| 27 class ProxyImpl; |
| 28 class ProxyMain; |
| 29 class RemoteChannelImplForTest; | 29 class RemoteChannelImplForTest; |
| 30 class TestContextProvider; | 30 class TestContextProvider; |
| 31 class TestGpuMemoryBufferManager; | 31 class TestGpuMemoryBufferManager; |
| 32 class TestTaskGraphRunner; | 32 class TestTaskGraphRunner; |
| 33 class TestWebGraphicsContext3D; | 33 class TestWebGraphicsContext3D; |
| 34 class ThreadedChannelForTest; | |
| 35 | 34 |
| 36 // Creates the virtual viewport layer hierarchy under the given root_layer. | 35 // Creates the virtual viewport layer hierarchy under the given root_layer. |
| 37 // Convenient overload of the method below that creates a scrolling layer as | 36 // Convenient overload of the method below that creates a scrolling layer as |
| 38 // the outer viewport scroll layer. | 37 // the outer viewport scroll layer. |
| 39 void CreateVirtualViewportLayers(Layer* root_layer, | 38 void CreateVirtualViewportLayers(Layer* root_layer, |
| 40 const gfx::Size& inner_bounds, | 39 const gfx::Size& inner_bounds, |
| 41 const gfx::Size& outer_bounds, | 40 const gfx::Size& outer_bounds, |
| 42 const gfx::Size& scroll_bounds, | 41 const gfx::Size& scroll_bounds, |
| 43 LayerTreeHost* host); | 42 LayerTreeHost* host); |
| 44 | 43 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 120 |
| 122 virtual void AfterTest() = 0; | 121 virtual void AfterTest() = 0; |
| 123 virtual void WillBeginTest(); | 122 virtual void WillBeginTest(); |
| 124 virtual void BeginTest() = 0; | 123 virtual void BeginTest() = 0; |
| 125 virtual void SetupTree(); | 124 virtual void SetupTree(); |
| 126 | 125 |
| 127 virtual void RunTest(CompositorMode mode, bool delegating_renderer); | 126 virtual void RunTest(CompositorMode mode, bool delegating_renderer); |
| 128 | 127 |
| 129 bool HasImplThread() const { return !!impl_thread_; } | 128 bool HasImplThread() const { return !!impl_thread_; } |
| 130 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { | 129 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { |
| 131 DCHECK(task_runner_provider()); | 130 return impl_task_runner_.get(); |
| 132 base::SingleThreadTaskRunner* impl_thread_task_runner = | |
| 133 task_runner_provider()->ImplThreadTaskRunner(); | |
| 134 return impl_thread_task_runner ? impl_thread_task_runner | |
| 135 : main_task_runner_.get(); | |
| 136 } | 131 } |
| 137 base::SingleThreadTaskRunner* MainThreadTaskRunner() { | 132 base::SingleThreadTaskRunner* MainThreadTaskRunner() { |
| 138 return main_task_runner_.get(); | 133 return main_task_runner_.get(); |
| 139 } | 134 } |
| 140 Proxy* proxy() const { | 135 Proxy* proxy() const { |
| 141 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; | 136 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; |
| 142 } | 137 } |
| 143 Proxy* remote_client_proxy() const; | 138 Proxy* remote_client_proxy() const; |
| 144 TaskRunnerProvider* task_runner_provider() const; | 139 TaskRunnerProvider* task_runner_provider() const; |
| 145 TaskGraphRunner* task_graph_runner() const; | 140 TaskGraphRunner* task_graph_runner() const; |
| 146 bool TestEnded() const { return ended_; } | 141 bool TestEnded() const { return ended_; } |
| 147 | 142 |
| 148 LayerTreeHost* layer_tree_host(); | 143 LayerTreeHost* layer_tree_host(); |
| 149 LayerTreeHost* remote_client_layer_tree_host(); | 144 LayerTreeHost* remote_client_layer_tree_host(); |
| 150 bool delegating_renderer() const { return delegating_renderer_; } | 145 bool delegating_renderer() const { return delegating_renderer_; } |
| 151 SharedBitmapManager* shared_bitmap_manager() const { | 146 SharedBitmapManager* shared_bitmap_manager() const { |
| 152 return shared_bitmap_manager_.get(); | 147 return shared_bitmap_manager_.get(); |
| 153 } | 148 } |
| 154 TestGpuMemoryBufferManager* gpu_memory_buffer_manager() { | 149 TestGpuMemoryBufferManager* gpu_memory_buffer_manager() { |
| 155 return gpu_memory_buffer_manager_.get(); | 150 return gpu_memory_buffer_manager_.get(); |
| 156 } | 151 } |
| 157 | 152 |
| 158 // Use these only for tests in threaded or remote mode. | |
| 159 ProxyMainForTest* GetProxyMainForTest() const; | |
| 160 ProxyImplForTest* GetProxyImplForTest() const; | |
| 161 | |
| 162 // Use this only for tests in threaded mode. | |
| 163 ThreadedChannelForTest* GetThreadedChannelForTest() const; | |
| 164 | |
| 165 // Use this only for tests in remote mode. | |
| 166 RemoteChannelImplForTest* GetRemoteChannelImplForTest() const; | |
| 167 | |
| 168 void DestroyLayerTreeHost(); | 153 void DestroyLayerTreeHost(); |
| 169 void DestroyRemoteClientHost() override; | 154 void DestroyRemoteClientHost() override; |
| 170 | 155 |
| 171 void CreateRemoteClientHost( | 156 void CreateRemoteClientHost( |
| 172 const proto::CompositorMessageToImpl& proto) override; | 157 const proto::CompositorMessageToImpl& proto) override; |
| 173 | 158 |
| 174 // By default, output surface recreation is synchronous. | 159 // By default, output surface recreation is synchronous. |
| 175 void RequestNewOutputSurface() override; | 160 void RequestNewOutputSurface() override; |
| 176 // Override this for pixel tests, where you need a real output surface, or | 161 // Override this for pixel tests, where you need a real output surface, or |
| 177 // if you want to control the output surface used for drawing. | 162 // if you want to control the output surface used for drawing. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 201 bool end_when_begin_returns_; | 186 bool end_when_begin_returns_; |
| 202 bool timed_out_; | 187 bool timed_out_; |
| 203 bool scheduled_; | 188 bool scheduled_; |
| 204 bool started_; | 189 bool started_; |
| 205 bool ended_; | 190 bool ended_; |
| 206 bool delegating_renderer_; | 191 bool delegating_renderer_; |
| 207 | 192 |
| 208 int timeout_seconds_; | 193 int timeout_seconds_; |
| 209 | 194 |
| 210 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 195 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 196 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; |
| 211 std::unique_ptr<base::Thread> impl_thread_; | 197 std::unique_ptr<base::Thread> impl_thread_; |
| 212 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; | 198 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 213 std::unique_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 199 std::unique_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 214 std::unique_ptr<TestTaskGraphRunner> task_graph_runner_; | 200 std::unique_ptr<TestTaskGraphRunner> task_graph_runner_; |
| 215 base::CancelableClosure timeout_; | 201 base::CancelableClosure timeout_; |
| 216 scoped_refptr<TestContextProvider> compositor_contexts_; | 202 scoped_refptr<TestContextProvider> compositor_contexts_; |
| 217 base::WeakPtr<LayerTreeTest> main_thread_weak_ptr_; | 203 base::WeakPtr<LayerTreeTest> main_thread_weak_ptr_; |
| 218 base::WeakPtrFactory<LayerTreeTest> weak_factory_; | 204 base::WeakPtrFactory<LayerTreeTest> weak_factory_; |
| 219 }; | 205 }; |
| 220 | 206 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 256 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
| 271 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 257 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
| 272 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 258 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
| 273 | 259 |
| 274 // Some tests want to control when notify ready for activation occurs, | 260 // Some tests want to control when notify ready for activation occurs, |
| 275 // but this is not supported in the single-threaded case. | 261 // but this is not supported in the single-threaded case. |
| 276 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ | 262 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ |
| 277 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) | 263 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) |
| 278 | 264 |
| 279 #endif // CC_TEST_LAYER_TREE_TEST_H_ | 265 #endif // CC_TEST_LAYER_TREE_TEST_H_ |
| OLD | NEW |