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