| 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 #include "cc/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
| 9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 280 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
| 281 class LayerTreeHostForTesting : public LayerTreeHost { | 281 class LayerTreeHostForTesting : public LayerTreeHost { |
| 282 public: | 282 public: |
| 283 static scoped_ptr<LayerTreeHostForTesting> Create( | 283 static scoped_ptr<LayerTreeHostForTesting> Create( |
| 284 TestHooks* test_hooks, | 284 TestHooks* test_hooks, |
| 285 LayerTreeHostClientForTesting* client, | 285 LayerTreeHostClientForTesting* client, |
| 286 const LayerTreeSettings& settings, | 286 const LayerTreeSettings& settings, |
| 287 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 287 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 288 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( | 288 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( |
| 289 new LayerTreeHostForTesting(test_hooks, client, settings)); | 289 new LayerTreeHostForTesting(test_hooks, client, settings)); |
| 290 bool success; | |
| 291 if (impl_task_runner.get()) | 290 if (impl_task_runner.get()) |
| 292 success = layer_tree_host->InitializeThreaded(impl_task_runner); | 291 layer_tree_host->InitializeThreaded(impl_task_runner); |
| 293 else | 292 else |
| 294 success = layer_tree_host->InitializeSingleThreaded(client); | 293 layer_tree_host->InitializeSingleThreaded(client); |
| 295 EXPECT_TRUE(success); | |
| 296 return layer_tree_host.Pass(); | 294 return layer_tree_host.Pass(); |
| 297 } | 295 } |
| 298 | 296 |
| 299 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 297 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 300 LayerTreeHostImplClient* host_impl_client) OVERRIDE { | 298 LayerTreeHostImplClient* host_impl_client) OVERRIDE { |
| 301 return LayerTreeHostImplForTesting::Create( | 299 return LayerTreeHostImplForTesting::Create( |
| 302 test_hooks_, | 300 test_hooks_, |
| 303 settings(), | 301 settings(), |
| 304 host_impl_client, | 302 host_impl_client, |
| 305 proxy(), | 303 proxy(), |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 layer_tree_host_ = LayerTreeHostForTesting::Create( | 455 layer_tree_host_ = LayerTreeHostForTesting::Create( |
| 458 this, | 456 this, |
| 459 client_.get(), | 457 client_.get(), |
| 460 settings_, | 458 settings_, |
| 461 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); | 459 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); |
| 462 ASSERT_TRUE(layer_tree_host_); | 460 ASSERT_TRUE(layer_tree_host_); |
| 463 | 461 |
| 464 started_ = true; | 462 started_ = true; |
| 465 beginning_ = true; | 463 beginning_ = true; |
| 466 SetupTree(); | 464 SetupTree(); |
| 467 layer_tree_host_->SetLayerTreeHostClientReady(); | 465 layer_tree_host_->SetLayerTreeHostClientReady( |
| 466 client_->CreateOutputSurface(false)); |
| 468 BeginTest(); | 467 BeginTest(); |
| 469 beginning_ = false; | 468 beginning_ = false; |
| 470 if (end_when_begin_returns_) | 469 if (end_when_begin_returns_) |
| 471 RealEndTest(); | 470 RealEndTest(); |
| 472 | 471 |
| 473 // Allow commits to happen once BeginTest() has had a chance to post tasks | 472 // Allow commits to happen once BeginTest() has had a chance to post tasks |
| 474 // so that those tasks will happen before the first commit. | 473 // so that those tasks will happen before the first commit. |
| 475 if (layer_tree_host_) { | 474 if (layer_tree_host_) { |
| 476 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> | 475 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> |
| 477 set_test_started(true); | 476 set_test_started(true); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 } | 671 } |
| 673 | 672 |
| 674 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { | 673 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { |
| 675 if (!compositor_contexts_.get() || | 674 if (!compositor_contexts_.get() || |
| 676 compositor_contexts_->DestroyedOnMainThread()) | 675 compositor_contexts_->DestroyedOnMainThread()) |
| 677 compositor_contexts_ = TestContextProvider::Create(); | 676 compositor_contexts_ = TestContextProvider::Create(); |
| 678 return compositor_contexts_; | 677 return compositor_contexts_; |
| 679 } | 678 } |
| 680 | 679 |
| 681 } // namespace cc | 680 } // namespace cc |
| OLD | NEW |