Index: ui/base/animation/animation_container_test_helper.cc |
diff --git a/ui/base/animation/animation_container_test_helper.cc b/ui/base/animation/animation_container_test_helper.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..23f1e23180b155657c78fdc89bc1cb974be576fb |
--- /dev/null |
+++ b/ui/base/animation/animation_container_test_helper.cc |
@@ -0,0 +1,45 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/base/animation/animation_container_test_helper.h" |
+ |
+using base::TimeDelta; |
+using base::TimeTicks; |
+ |
+namespace ui { |
+namespace test { |
+ |
+AnimationContainerTestHelper::AnimationContainerTestHelper( |
+ AnimationContainer* container) |
+ : container_(container) { |
+ container_->test_timing_enabled_ = true; |
+ container_->test_time_ = TimeTicks::Now(); |
+} |
+ |
+AnimationContainerTestHelper::~AnimationContainerTestHelper() { |
+ container_->test_timing_enabled_ = false; |
+} |
+ |
+void AnimationContainerTestHelper::Forward(TimeDelta delta) { |
+ container_->test_time_ += delta; |
+ if (IsAnimating()) |
+ container_->Run(); |
+} |
+ |
+void AnimationContainerTestHelper::Ping() { |
+ if (IsAnimating()) |
+ container_->Run(); |
+} |
+ |
+void AnimationContainerTestHelper::ForwardWhileRunning() { |
+ while (IsAnimating()) |
+ Forward(TimeDelta::FromSeconds(1)); |
+} |
+ |
+bool AnimationContainerTestHelper::IsAnimating() { |
+ return container_->timer_.IsRunning(); |
+} |
+ |
+} // namespace test |
+} // namespace ui |