| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 281 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
| 282 class LayerTreeHostForTesting : public LayerTreeHost { | 282 class LayerTreeHostForTesting : public LayerTreeHost { |
| 283 public: | 283 public: |
| 284 static scoped_ptr<LayerTreeHostForTesting> Create( | 284 static scoped_ptr<LayerTreeHostForTesting> Create( |
| 285 TestHooks* test_hooks, | 285 TestHooks* test_hooks, |
| 286 LayerTreeHostClientForTesting* client, | 286 LayerTreeHostClientForTesting* client, |
| 287 const LayerTreeSettings& settings, | 287 const LayerTreeSettings& settings, |
| 288 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 288 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 289 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( | 289 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( |
| 290 new LayerTreeHostForTesting(test_hooks, client, settings)); | 290 new LayerTreeHostForTesting(test_hooks, client, settings)); |
| 291 bool success; |
| 291 if (impl_task_runner.get()) | 292 if (impl_task_runner.get()) |
| 292 layer_tree_host->InitializeThreaded(impl_task_runner); | 293 success = layer_tree_host->InitializeThreaded(impl_task_runner); |
| 293 else | 294 else |
| 294 layer_tree_host->InitializeSingleThreaded(client); | 295 success = layer_tree_host->InitializeSingleThreaded(client); |
| 296 EXPECT_TRUE(success); |
| 295 return layer_tree_host.Pass(); | 297 return layer_tree_host.Pass(); |
| 296 } | 298 } |
| 297 | 299 |
| 298 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 300 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 299 LayerTreeHostImplClient* host_impl_client) OVERRIDE { | 301 LayerTreeHostImplClient* host_impl_client) OVERRIDE { |
| 300 return LayerTreeHostImplForTesting::Create( | 302 return LayerTreeHostImplForTesting::Create( |
| 301 test_hooks_, | 303 test_hooks_, |
| 302 settings(), | 304 settings(), |
| 303 host_impl_client, | 305 host_impl_client, |
| 304 proxy(), | 306 proxy(), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 &LayerTreeTest::DispatchSetVisible, main_thread_weak_ptr_, visible)); | 451 &LayerTreeTest::DispatchSetVisible, main_thread_weak_ptr_, visible)); |
| 450 } | 452 } |
| 451 | 453 |
| 452 void LayerTreeTest::PostSetNextCommitForcesRedrawToMainThread() { | 454 void LayerTreeTest::PostSetNextCommitForcesRedrawToMainThread() { |
| 453 main_task_runner_->PostTask( | 455 main_task_runner_->PostTask( |
| 454 FROM_HERE, | 456 FROM_HERE, |
| 455 base::Bind(&LayerTreeTest::DispatchSetNextCommitForcesRedraw, | 457 base::Bind(&LayerTreeTest::DispatchSetNextCommitForcesRedraw, |
| 456 main_thread_weak_ptr_)); | 458 main_thread_weak_ptr_)); |
| 457 } | 459 } |
| 458 | 460 |
| 459 void LayerTreeTest::WillBeginTest() { | |
| 460 layer_tree_host_->SetLayerTreeHostClientReady(); | |
| 461 } | |
| 462 | |
| 463 void LayerTreeTest::DoBeginTest() { | 461 void LayerTreeTest::DoBeginTest() { |
| 464 client_ = LayerTreeHostClientForTesting::Create(this); | 462 client_ = LayerTreeHostClientForTesting::Create(this); |
| 465 | 463 |
| 466 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); | 464 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); |
| 467 layer_tree_host_ = LayerTreeHostForTesting::Create( | 465 layer_tree_host_ = LayerTreeHostForTesting::Create( |
| 468 this, | 466 this, |
| 469 client_.get(), | 467 client_.get(), |
| 470 settings_, | 468 settings_, |
| 471 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); | 469 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); |
| 472 ASSERT_TRUE(layer_tree_host_); | 470 ASSERT_TRUE(layer_tree_host_); |
| 473 | 471 |
| 474 started_ = true; | 472 started_ = true; |
| 475 beginning_ = true; | 473 beginning_ = true; |
| 476 SetupTree(); | 474 SetupTree(); |
| 477 WillBeginTest(); | 475 layer_tree_host_->SetLayerTreeHostClientReady(); |
| 478 BeginTest(); | 476 BeginTest(); |
| 479 beginning_ = false; | 477 beginning_ = false; |
| 480 if (end_when_begin_returns_) | 478 if (end_when_begin_returns_) |
| 481 RealEndTest(); | 479 RealEndTest(); |
| 482 | 480 |
| 483 // Allow commits to happen once BeginTest() has had a chance to post tasks | 481 // Allow commits to happen once BeginTest() has had a chance to post tasks |
| 484 // so that those tasks will happen before the first commit. | 482 // so that those tasks will happen before the first commit. |
| 485 if (layer_tree_host_) { | 483 if (layer_tree_host_) { |
| 486 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> | 484 static_cast<LayerTreeHostForTesting*>(layer_tree_host_.get())-> |
| 487 set_test_started(true); | 485 set_test_started(true); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 } | 687 } |
| 690 | 688 |
| 691 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { | 689 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { |
| 692 if (!compositor_contexts_.get() || | 690 if (!compositor_contexts_.get() || |
| 693 compositor_contexts_->DestroyedOnMainThread()) | 691 compositor_contexts_->DestroyedOnMainThread()) |
| 694 compositor_contexts_ = TestContextProvider::Create(); | 692 compositor_contexts_ = TestContextProvider::Create(); |
| 695 return compositor_contexts_; | 693 return compositor_contexts_; |
| 696 } | 694 } |
| 697 | 695 |
| 698 } // namespace cc | 696 } // namespace cc |
| OLD | NEW |