| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/compositor/test/multi_layer_animator_test_controller.h" |
| 6 |
| 7 #include "base/time/time.h" |
| 8 #include "ui/compositor/layer.h" |
| 9 #include "ui/compositor/layer_animator.h" |
| 10 #include "ui/compositor/test/layer_animator_test_controller.h" |
| 11 #include "ui/compositor/test/multi_layer_animator_test_controller_delegate.h" |
| 12 |
| 13 namespace ui { |
| 14 namespace test { |
| 15 |
| 16 MultiLayerAnimatorTestController::MultiLayerAnimatorTestController( |
| 17 MultiLayerAnimatorTestControllerDelegate* delegate) |
| 18 : delegate_(delegate) {} |
| 19 |
| 20 MultiLayerAnimatorTestController::~MultiLayerAnimatorTestController() {} |
| 21 |
| 22 void MultiLayerAnimatorTestController::SetDisableAnimationTimers( |
| 23 bool disable_timers) { |
| 24 for (LayerAnimator* animator : GetLayerAnimators()) |
| 25 animator->set_disable_timer_for_test(disable_timers); |
| 26 } |
| 27 |
| 28 bool MultiLayerAnimatorTestController::HasActiveAnimations() const { |
| 29 for (LayerAnimator* animator : GetLayerAnimators()) { |
| 30 if (animator->is_animating()) |
| 31 return true; |
| 32 } |
| 33 return false; |
| 34 } |
| 35 |
| 36 void MultiLayerAnimatorTestController::CompleteAnimations() { |
| 37 while (HasActiveAnimations()) { |
| 38 // StepAnimations() will only progress the current running animations. Thus |
| 39 // each queued animation will require at least one 'Step' call and we cannot |
| 40 // just use a large duration here. |
| 41 StepAnimations(base::TimeDelta::FromMilliseconds(20)); |
| 42 } |
| 43 } |
| 44 |
| 45 std::vector<LayerAnimator*> |
| 46 MultiLayerAnimatorTestController::GetLayerAnimators() { |
| 47 return static_cast<const MultiLayerAnimatorTestController*>(this) |
| 48 ->GetLayerAnimators(); |
| 49 } |
| 50 |
| 51 std::vector<LayerAnimator*> |
| 52 MultiLayerAnimatorTestController::GetLayerAnimators() const { |
| 53 return delegate_->GetLayerAnimators(); |
| 54 } |
| 55 |
| 56 void MultiLayerAnimatorTestController::StepAnimations( |
| 57 const base::TimeDelta& duration) { |
| 58 for (ui::LayerAnimator* animator : GetLayerAnimators()) { |
| 59 LayerAnimatorTestController controller(animator); |
| 60 controller.StartThreadedAnimationsIfNeeded(); |
| 61 controller.Step(duration); |
| 62 } |
| 63 } |
| 64 |
| 65 } // namespace test |
| 66 } // namespace ui |
| OLD | NEW |