OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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/base/animation/animation_container_test_helper.h" |
| 6 |
| 7 using base::TimeDelta; |
| 8 using base::TimeTicks; |
| 9 |
| 10 namespace ui { |
| 11 namespace test { |
| 12 |
| 13 AnimationContainerTestHelper::AnimationContainerTestHelper( |
| 14 AnimationContainer* container) |
| 15 : container_(container) { |
| 16 container_->test_timing_enabled_ = true; |
| 17 container_->test_time_ = TimeTicks::Now(); |
| 18 } |
| 19 |
| 20 AnimationContainerTestHelper::~AnimationContainerTestHelper() { |
| 21 container_->test_timing_enabled_ = false; |
| 22 } |
| 23 |
| 24 void AnimationContainerTestHelper::Forward(TimeDelta delta) { |
| 25 container_->test_time_ += delta; |
| 26 if (IsAnimating()) |
| 27 container_->Run(); |
| 28 } |
| 29 |
| 30 void AnimationContainerTestHelper::Ping() { |
| 31 if (IsAnimating()) |
| 32 container_->Run(); |
| 33 } |
| 34 |
| 35 void AnimationContainerTestHelper::ForwardWhileRunning() { |
| 36 while (IsAnimating()) |
| 37 Forward(TimeDelta::FromSeconds(1)); |
| 38 } |
| 39 |
| 40 bool AnimationContainerTestHelper::IsAnimating() { |
| 41 return container_->timer_.IsRunning(); |
| 42 } |
| 43 |
| 44 } // namespace test |
| 45 } // namespace ui |
OLD | NEW |