| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/animation/test/ink_drop_animation_test_api.h" | 5 #include "ui/views/animation/test/ink_drop_animation_test_api.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
| 9 #include "ui/compositor/layer_animator.h" | 9 #include "ui/compositor/layer_animator.h" |
| 10 #include "ui/compositor/test/layer_animator_test_controller.h" | 10 #include "ui/compositor/test/layer_animator_test_controller.h" |
| 11 #include "ui/views/animation/ink_drop_animation.h" | 11 #include "ui/views/animation/ink_drop_animation.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 namespace test { | 14 namespace test { |
| 15 | 15 |
| 16 InkDropAnimationTestApi::InkDropAnimationTestApi( | 16 InkDropAnimationTestApi::InkDropAnimationTestApi( |
| 17 InkDropAnimation* ink_drop_animation) | 17 InkDropAnimation* ink_drop_animation) |
| 18 : ink_drop_animation_(ink_drop_animation) {} | 18 : ui::test::MultiLayerAnimatorTestController(this), |
| 19 ink_drop_animation_(ink_drop_animation) {} |
| 19 | 20 |
| 20 InkDropAnimationTestApi::~InkDropAnimationTestApi() {} | 21 InkDropAnimationTestApi::~InkDropAnimationTestApi() {} |
| 21 | 22 |
| 22 void InkDropAnimationTestApi::SetDisableAnimationTimers(bool disable_timers) { | |
| 23 for (ui::LayerAnimator* animator : GetLayerAnimators()) | |
| 24 animator->set_disable_timer_for_test(disable_timers); | |
| 25 } | |
| 26 | |
| 27 bool InkDropAnimationTestApi::HasActiveAnimations() const { | |
| 28 for (ui::LayerAnimator* animator : GetLayerAnimators()) { | |
| 29 if (animator->is_animating()) | |
| 30 return true; | |
| 31 } | |
| 32 return false; | |
| 33 } | |
| 34 | |
| 35 void InkDropAnimationTestApi::CompleteAnimations() { | |
| 36 while (HasActiveAnimations()) { | |
| 37 // StepAnimations() will only progress the current running animations. Thus | |
| 38 // each queued animation will require at least one 'Step' call and we cannot | |
| 39 // just use a large duration here. | |
| 40 StepAnimations(base::TimeDelta::FromMilliseconds(20)); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 std::vector<ui::LayerAnimator*> InkDropAnimationTestApi::GetLayerAnimators() { | 23 std::vector<ui::LayerAnimator*> InkDropAnimationTestApi::GetLayerAnimators() { |
| 45 return static_cast<const InkDropAnimationTestApi*>(this)->GetLayerAnimators(); | |
| 46 } | |
| 47 | |
| 48 std::vector<ui::LayerAnimator*> InkDropAnimationTestApi::GetLayerAnimators() | |
| 49 const { | |
| 50 return std::vector<ui::LayerAnimator*>(); | 24 return std::vector<ui::LayerAnimator*>(); |
| 51 } | 25 } |
| 52 | 26 |
| 53 void InkDropAnimationTestApi::StepAnimations(const base::TimeDelta& duration) { | |
| 54 for (ui::LayerAnimator* animator : GetLayerAnimators()) { | |
| 55 ui::LayerAnimatorTestController controller(animator); | |
| 56 controller.StartThreadedAnimationsIfNeeded(); | |
| 57 controller.Step(duration); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 } // namespace test | 27 } // namespace test |
| 62 } // namespace views | 28 } // namespace views |
| OLD | NEW |