Index: ui/base/animation/animation_container_test_helper.h |
diff --git a/ui/base/animation/animation_container_test_helper.h b/ui/base/animation/animation_container_test_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fd833de4f3a43c71c9fe08d00a66a06b2a6429f1 |
--- /dev/null |
+++ b/ui/base/animation/animation_container_test_helper.h |
@@ -0,0 +1,52 @@ |
+// 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. |
+ |
+#ifndef UI_BASE_ANIMATION_ANIMATION_CONTAINER_TEST_HELPER_H_ |
+#define UI_BASE_ANIMATION_ANIMATION_CONTAINER_TEST_HELPER_H_ |
+ |
+#include "base/test/scoped_time_controller.h" |
+#include "base/time.h" |
+#include "ui/base/animation/animation_container.h" |
+#include "ui/base/ui_export.h" |
+ |
+namespace ui { |
+namespace test { |
+ |
+// This class can be used in tests for fine control over animations. |
+ |
+class UI_EXPORT AnimationContainerTestHelper { |
+ public: |
+ // Creates helper for given container. Container is now driven by this |
+ // helper rather than by internal timer. |
+ explicit AnimationContainerTestHelper(AnimationContainer* container); |
+ virtual ~AnimationContainerTestHelper() {}; |
sky
2012/12/10 22:20:16
Why the virtual? And don't inline and remove ;
Denis Kuznetsov (DE-MUC)
2012/12/11 13:27:57
So that there are no warnings if it is used with s
sky
2012/12/11 16:44:17
scoped_ptr shouldn't require a virtual destructor.
|
+ |
+ // Advances AnimationContainer for |delta|. |
+ void Advance(base::TimeDelta delta); |
+ |
+ // Returns if AnimationContainer is animating. |
+ bool IsAnimating(); |
+ |
+ // Forwards in large steps (1 second) while there are any animations running. |
+ // Use it before deleting Helper to avoid negative time delta in animations |
+ // once timer gets cleaned up. |
+ void AdvanceWhileRunning(); |
sky
2012/12/10 22:20:16
How about AdvanceUntilDone.
Denis Kuznetsov (DE-MUC)
2012/12/11 13:27:57
Done.
|
+ |
+ // Calls Run method of Container without advancing time. Call this method once |
+ // some animations were added to container so that any immediate animations |
+ // get processed. |
+ void Ping(); |
sky
2012/12/10 22:20:16
Is there a reason this is needed instead of Advanc
Denis Kuznetsov (DE-MUC)
2012/12/11 13:27:57
Done.
|
+ |
+ private: |
+ AnimationContainer* container_; |
+ |
+ scoped_ptr<base::test::ScopedTimeController> time_controller_; |
sky
2012/12/10 22:20:16
Declare this by value (eg not in a scoped_ptr).
Denis Kuznetsov (DE-MUC)
2012/12/11 13:27:57
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(AnimationContainerTestHelper); |
+}; |
+ |
+} // namespace test |
+} // namespace ui |
+ |
+#endif // UI_BASE_ANIMATION_ANIMATION_CONTAINER_TEST_HELPER_H_ |