| 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 "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 bool AnimateLayers(base::TimeTicks monotonic_time) override { | 313 bool AnimateLayers(base::TimeTicks monotonic_time) override { |
| 314 test_hooks_->WillAnimateLayers(this, monotonic_time); | 314 test_hooks_->WillAnimateLayers(this, monotonic_time); |
| 315 bool result = LayerTreeHostImpl::AnimateLayers(monotonic_time); | 315 bool result = LayerTreeHostImpl::AnimateLayers(monotonic_time); |
| 316 test_hooks_->AnimateLayers(this, monotonic_time); | 316 test_hooks_->AnimateLayers(this, monotonic_time); |
| 317 return result; | 317 return result; |
| 318 } | 318 } |
| 319 | 319 |
| 320 void UpdateAnimationState(bool start_ready_animations) override { | 320 void UpdateAnimationState(bool start_ready_animations) override { |
| 321 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations); | 321 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations); |
| 322 bool has_unfinished_animation = false; | 322 bool has_unfinished_animation = false; |
| 323 AnimationRegistrar* registrar = | 323 AnimationRegistrar* registrar = animation_host()->animation_registrar(); |
| 324 animation_registrar() ? animation_registrar() | |
| 325 : animation_host()->animation_registrar(); | |
| 326 for (const auto& it : | 324 for (const auto& it : |
| 327 registrar->active_animation_controllers_for_testing()) { | 325 registrar->active_animation_controllers_for_testing()) { |
| 328 if (it.second->HasActiveAnimation()) { | 326 if (it.second->HasActiveAnimation()) { |
| 329 has_unfinished_animation = true; | 327 has_unfinished_animation = true; |
| 330 break; | 328 break; |
| 331 } | 329 } |
| 332 } | 330 } |
| 333 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); | 331 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); |
| 334 } | 332 } |
| 335 | 333 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 } | 567 } |
| 570 } | 568 } |
| 571 | 569 |
| 572 void LayerTreeTest::EndTestAfterDelayMs(int delay_milliseconds) { | 570 void LayerTreeTest::EndTestAfterDelayMs(int delay_milliseconds) { |
| 573 main_task_runner_->PostDelayedTask( | 571 main_task_runner_->PostDelayedTask( |
| 574 FROM_HERE, | 572 FROM_HERE, |
| 575 base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_), | 573 base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_), |
| 576 base::TimeDelta::FromMilliseconds(delay_milliseconds)); | 574 base::TimeDelta::FromMilliseconds(delay_milliseconds)); |
| 577 } | 575 } |
| 578 | 576 |
| 579 void LayerTreeTest::PostAddAnimationToMainThread( | |
| 580 Layer* layer_to_receive_animation) { | |
| 581 main_task_runner_->PostTask( | |
| 582 FROM_HERE, | |
| 583 base::Bind(&LayerTreeTest::DispatchAddAnimation, main_thread_weak_ptr_, | |
| 584 base::Unretained(layer_to_receive_animation), 0.000004)); | |
| 585 } | |
| 586 | |
| 587 void LayerTreeTest::PostAddInstantAnimationToMainThread( | |
| 588 Layer* layer_to_receive_animation) { | |
| 589 main_task_runner_->PostTask( | |
| 590 FROM_HERE, | |
| 591 base::Bind(&LayerTreeTest::DispatchAddAnimation, | |
| 592 main_thread_weak_ptr_, | |
| 593 base::Unretained(layer_to_receive_animation), | |
| 594 0.0)); | |
| 595 } | |
| 596 | |
| 597 void LayerTreeTest::PostAddLongAnimationToMainThread( | |
| 598 Layer* layer_to_receive_animation) { | |
| 599 main_task_runner_->PostTask( | |
| 600 FROM_HERE, | |
| 601 base::Bind(&LayerTreeTest::DispatchAddAnimation, | |
| 602 main_thread_weak_ptr_, | |
| 603 base::Unretained(layer_to_receive_animation), | |
| 604 1.0)); | |
| 605 } | |
| 606 | |
| 607 void LayerTreeTest::PostAddAnimationToMainThreadPlayer( | 577 void LayerTreeTest::PostAddAnimationToMainThreadPlayer( |
| 608 AnimationPlayer* player_to_receive_animation) { | 578 AnimationPlayer* player_to_receive_animation) { |
| 609 main_task_runner_->PostTask( | 579 main_task_runner_->PostTask( |
| 610 FROM_HERE, | 580 FROM_HERE, |
| 611 base::Bind(&LayerTreeTest::DispatchAddAnimationToPlayer, | 581 base::Bind(&LayerTreeTest::DispatchAddAnimationToPlayer, |
| 612 main_thread_weak_ptr_, | 582 main_thread_weak_ptr_, |
| 613 base::Unretained(player_to_receive_animation), 0.000004)); | 583 base::Unretained(player_to_receive_animation), 0.000004)); |
| 614 } | 584 } |
| 615 | 585 |
| 616 void LayerTreeTest::PostAddInstantAnimationToMainThreadPlayer( | 586 void LayerTreeTest::PostAddInstantAnimationToMainThreadPlayer( |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 if (main_frame_will_happen && !timed_out_) { | 779 if (main_frame_will_happen && !timed_out_) { |
| 810 main_task_runner_->PostTask( | 780 main_task_runner_->PostTask( |
| 811 FROM_HERE, | 781 FROM_HERE, |
| 812 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); | 782 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); |
| 813 return; | 783 return; |
| 814 } | 784 } |
| 815 | 785 |
| 816 base::MessageLoop::current()->QuitWhenIdle(); | 786 base::MessageLoop::current()->QuitWhenIdle(); |
| 817 } | 787 } |
| 818 | 788 |
| 819 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, | |
| 820 double animation_duration) { | |
| 821 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread()); | |
| 822 | |
| 823 if (layer_to_receive_animation) { | |
| 824 AddOpacityTransitionToLayer( | |
| 825 layer_to_receive_animation, animation_duration, 0, 0.5, true); | |
| 826 } | |
| 827 } | |
| 828 | |
| 829 void LayerTreeTest::DispatchAddAnimationToPlayer( | 789 void LayerTreeTest::DispatchAddAnimationToPlayer( |
| 830 AnimationPlayer* player_to_receive_animation, | 790 AnimationPlayer* player_to_receive_animation, |
| 831 double animation_duration) { | 791 double animation_duration) { |
| 832 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread()); | 792 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread()); |
| 833 | 793 |
| 834 if (player_to_receive_animation) { | 794 if (player_to_receive_animation) { |
| 835 AddOpacityTransitionToPlayer(player_to_receive_animation, | 795 AddOpacityTransitionToPlayer(player_to_receive_animation, |
| 836 animation_duration, 0, 0.5, true); | 796 animation_duration, 0, 0.5, true); |
| 837 } | 797 } |
| 838 } | 798 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 | 1033 |
| 1074 RemoteChannelImplForTest* LayerTreeTest::GetRemoteChannelImplForTest() const { | 1034 RemoteChannelImplForTest* LayerTreeTest::GetRemoteChannelImplForTest() const { |
| 1075 DCHECK(IsRemoteTest()); | 1035 DCHECK(IsRemoteTest()); |
| 1076 DCHECK(remote_client_layer_tree_host_); | 1036 DCHECK(remote_client_layer_tree_host_); |
| 1077 | 1037 |
| 1078 return static_cast<RemoteChannelImplForTest*>( | 1038 return static_cast<RemoteChannelImplForTest*>( |
| 1079 remote_client_layer_tree_host_->proxy()); | 1039 remote_client_layer_tree_host_->proxy()); |
| 1080 } | 1040 } |
| 1081 | 1041 |
| 1082 } // namespace cc | 1042 } // namespace cc |
| OLD | NEW |