| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 void TestHooks::CreateResourceAndRasterWorkerPool( | 47 void TestHooks::CreateResourceAndRasterWorkerPool( |
| 48 LayerTreeHostImpl* host_impl, | 48 LayerTreeHostImpl* host_impl, |
| 49 scoped_ptr<RasterWorkerPool>* raster_worker_pool, | 49 scoped_ptr<RasterWorkerPool>* raster_worker_pool, |
| 50 scoped_ptr<ResourcePool>* resource_pool, | 50 scoped_ptr<ResourcePool>* resource_pool, |
| 51 scoped_ptr<ResourcePool>* staging_resource_pool) { | 51 scoped_ptr<ResourcePool>* staging_resource_pool) { |
| 52 host_impl->LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( | 52 host_impl->LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( |
| 53 raster_worker_pool, resource_pool, staging_resource_pool); | 53 raster_worker_pool, resource_pool, staging_resource_pool); |
| 54 } | 54 } |
| 55 | 55 |
| 56 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { |
| 57 return base::TimeDelta::FromMilliseconds(16); |
| 58 } |
| 59 |
| 56 // Adapts ThreadProxy for test. Injects test hooks for testing. | 60 // Adapts ThreadProxy for test. Injects test hooks for testing. |
| 57 class ThreadProxyForTest : public ThreadProxy { | 61 class ThreadProxyForTest : public ThreadProxy { |
| 58 public: | 62 public: |
| 59 static scoped_ptr<Proxy> Create( | 63 static scoped_ptr<Proxy> Create( |
| 60 TestHooks* test_hooks, | 64 TestHooks* test_hooks, |
| 61 LayerTreeHost* host, | 65 LayerTreeHost* host, |
| 62 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 66 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 63 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 67 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 64 return make_scoped_ptr(new ThreadProxyForTest( | 68 return make_scoped_ptr(new ThreadProxyForTest( |
| 65 test_hooks, host, main_task_runner, impl_task_runner)); | 69 test_hooks, host, main_task_runner, impl_task_runner)); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 active_animation_controllers().begin(); | 262 active_animation_controllers().begin(); |
| 259 for (; iter != active_animation_controllers().end(); ++iter) { | 263 for (; iter != active_animation_controllers().end(); ++iter) { |
| 260 if (iter->second->HasActiveAnimation()) { | 264 if (iter->second->HasActiveAnimation()) { |
| 261 has_unfinished_animation = true; | 265 has_unfinished_animation = true; |
| 262 break; | 266 break; |
| 263 } | 267 } |
| 264 } | 268 } |
| 265 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); | 269 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); |
| 266 } | 270 } |
| 267 | 271 |
| 272 base::TimeDelta LowFrequencyAnimationInterval() const override { |
| 273 return test_hooks_->LowFrequencyAnimationInterval(); |
| 274 } |
| 275 |
| 268 private: | 276 private: |
| 269 TestHooks* test_hooks_; | 277 TestHooks* test_hooks_; |
| 270 bool block_notify_ready_to_activate_for_testing_; | 278 bool block_notify_ready_to_activate_for_testing_; |
| 271 bool notify_ready_to_activate_was_blocked_; | 279 bool notify_ready_to_activate_was_blocked_; |
| 272 }; | 280 }; |
| 273 | 281 |
| 274 // Implementation of LayerTreeHost callback interface. | 282 // Implementation of LayerTreeHost callback interface. |
| 275 class LayerTreeHostClientForTesting : public LayerTreeHostClient, | 283 class LayerTreeHostClientForTesting : public LayerTreeHostClient, |
| 276 public LayerTreeHostSingleThreadClient { | 284 public LayerTreeHostSingleThreadClient { |
| 277 public: | 285 public: |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 ASSERT_TRUE(impl_thread_->Start()); | 668 ASSERT_TRUE(impl_thread_->Start()); |
| 661 } | 669 } |
| 662 | 670 |
| 663 main_task_runner_ = base::MessageLoopProxy::current(); | 671 main_task_runner_ = base::MessageLoopProxy::current(); |
| 664 | 672 |
| 665 delegating_renderer_ = delegating_renderer; | 673 delegating_renderer_ = delegating_renderer; |
| 666 | 674 |
| 667 // Spend less time waiting for BeginFrame because the output is | 675 // Spend less time waiting for BeginFrame because the output is |
| 668 // mocked out. | 676 // mocked out. |
| 669 settings_.refresh_rate = 200.0; | 677 settings_.refresh_rate = 200.0; |
| 670 settings_.background_animation_rate = 200.0; | |
| 671 settings_.impl_side_painting = impl_side_painting; | 678 settings_.impl_side_painting = impl_side_painting; |
| 672 InitializeSettings(&settings_); | 679 InitializeSettings(&settings_); |
| 673 | 680 |
| 674 main_task_runner_->PostTask( | 681 main_task_runner_->PostTask( |
| 675 FROM_HERE, | 682 FROM_HERE, |
| 676 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); | 683 base::Bind(&LayerTreeTest::DoBeginTest, base::Unretained(this))); |
| 677 | 684 |
| 678 if (timeout_seconds_) { | 685 if (timeout_seconds_) { |
| 679 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); | 686 timeout_.Reset(base::Bind(&LayerTreeTest::Timeout, base::Unretained(this))); |
| 680 main_task_runner_->PostDelayedTask( | 687 main_task_runner_->PostDelayedTask( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 return -1; | 746 return -1; |
| 740 } | 747 } |
| 741 | 748 |
| 742 void LayerTreeTest::DestroyLayerTreeHost() { | 749 void LayerTreeTest::DestroyLayerTreeHost() { |
| 743 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 750 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
| 744 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 751 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
| 745 layer_tree_host_ = nullptr; | 752 layer_tree_host_ = nullptr; |
| 746 } | 753 } |
| 747 | 754 |
| 748 } // namespace cc | 755 } // namespace cc |
| OLD | NEW |