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 #ifndef UI_BASE_ANIMATION_ANIMATION_CONTAINER_TEST_HELPER_H_ | |
6 #define UI_BASE_ANIMATION_ANIMATION_CONTAINER_TEST_HELPER_H_ | |
7 | |
8 #include "base/test/scoped_time_controller.h" | |
9 #include "base/time.h" | |
10 #include "ui/base/animation/animation_container.h" | |
11 #include "ui/base/ui_export.h" | |
12 | |
13 namespace ui { | |
14 namespace test { | |
15 | |
16 // This class can be used in tests for fine control over animations. | |
17 | |
18 class UI_EXPORT AnimationContainerTestHelper { | |
19 public: | |
20 // Creates helper for given container. Container is now driven by this | |
21 // helper rather than by internal timer. | |
22 explicit AnimationContainerTestHelper(AnimationContainer* container); | |
23 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.
| |
24 | |
25 // Advances AnimationContainer for |delta|. | |
26 void Advance(base::TimeDelta delta); | |
27 | |
28 // Returns if AnimationContainer is animating. | |
29 bool IsAnimating(); | |
30 | |
31 // Forwards in large steps (1 second) while there are any animations running. | |
32 // Use it before deleting Helper to avoid negative time delta in animations | |
33 // once timer gets cleaned up. | |
34 void AdvanceWhileRunning(); | |
sky
2012/12/10 22:20:16
How about AdvanceUntilDone.
Denis Kuznetsov (DE-MUC)
2012/12/11 13:27:57
Done.
| |
35 | |
36 // Calls Run method of Container without advancing time. Call this method once | |
37 // some animations were added to container so that any immediate animations | |
38 // get processed. | |
39 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.
| |
40 | |
41 private: | |
42 AnimationContainer* container_; | |
43 | |
44 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.
| |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(AnimationContainerTestHelper); | |
47 }; | |
48 | |
49 } // namespace test | |
50 } // namespace ui | |
51 | |
52 #endif // UI_BASE_ANIMATION_ANIMATION_CONTAINER_TEST_HELPER_H_ | |
OLD | NEW |