OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_ | 5 #ifndef ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_ |
6 #define ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_ | 6 #define ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 11 matching lines...) Expand all Loading... |
22 // animations. | 22 // animations. |
23 // NOTE: The TestSessionStateAnimator limits each | 23 // NOTE: The TestSessionStateAnimator limits each |
24 // SessionStateAnimator::Container to a single active animation at any one time. | 24 // SessionStateAnimator::Container to a single active animation at any one time. |
25 // If a new animation is started on a container the existing one will be | 25 // If a new animation is started on a container the existing one will be |
26 // aborted. | 26 // aborted. |
27 class TestSessionStateAnimator : public SessionStateAnimator { | 27 class TestSessionStateAnimator : public SessionStateAnimator { |
28 public: | 28 public: |
29 TestSessionStateAnimator(); | 29 TestSessionStateAnimator(); |
30 ~TestSessionStateAnimator() override; | 30 ~TestSessionStateAnimator() override; |
31 | 31 |
32 int last_animation_epoch() { | 32 int last_animation_epoch() { return last_animation_epoch_; } |
33 return last_animation_epoch_; | |
34 } | |
35 | 33 |
36 // Resets the current animation epoch back to 0 and aborts all currently | 34 // Resets the current animation epoch back to 0 and aborts all currently |
37 // active animations. | 35 // active animations. |
38 void ResetAnimationEpoch(); | 36 void ResetAnimationEpoch(); |
39 | 37 |
40 // Advances all contained animations by the specified |duration|. Any | 38 // Advances all contained animations by the specified |duration|. Any |
41 // animations that will have completed after |duration| will have its | 39 // animations that will have completed after |duration| will have its |
42 // callback called. | 40 // callback called. |
43 void Advance(const base::TimeDelta& duration); | 41 void Advance(const base::TimeDelta& duration); |
44 | 42 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void ShowBackground() override; | 76 void ShowBackground() override; |
79 void HideBackground() override; | 77 void HideBackground() override; |
80 | 78 |
81 private: | 79 private: |
82 class AnimationSequence; | 80 class AnimationSequence; |
83 friend class AnimationSequence; | 81 friend class AnimationSequence; |
84 | 82 |
85 // Data structure to track the currently active animations and their | 83 // Data structure to track the currently active animations and their |
86 // callbacks. | 84 // callbacks. |
87 struct ActiveAnimation { | 85 struct ActiveAnimation { |
88 ActiveAnimation( | 86 ActiveAnimation(int animation_epoch, |
89 int animation_epoch, | 87 base::TimeDelta duration, |
90 base::TimeDelta duration, | 88 SessionStateAnimator::Container container, |
91 SessionStateAnimator::Container container, | 89 AnimationType type, |
92 AnimationType type, | 90 AnimationSpeed speed, |
93 AnimationSpeed speed, | 91 base::Closure success_callback, |
94 base::Closure success_callback, | 92 base::Closure failed_callback); |
95 base::Closure failed_callback); | |
96 ActiveAnimation(const ActiveAnimation& other); | 93 ActiveAnimation(const ActiveAnimation& other); |
97 virtual ~ActiveAnimation(); | 94 virtual ~ActiveAnimation(); |
98 | 95 |
99 // The time epoch that this animation was scheduled. | 96 // The time epoch that this animation was scheduled. |
100 int animation_epoch; | 97 int animation_epoch; |
101 | 98 |
102 // The time remaining for this animation. | 99 // The time remaining for this animation. |
103 base::TimeDelta remaining_duration; | 100 base::TimeDelta remaining_duration; |
104 | 101 |
105 // The container which is being animated. | 102 // The container which is being animated. |
(...skipping 11 matching lines...) Expand all Loading... |
117 // The callback to be invoked upon an unsuccessful completion. | 114 // The callback to be invoked upon an unsuccessful completion. |
118 base::Closure failed_callback; | 115 base::Closure failed_callback; |
119 }; | 116 }; |
120 | 117 |
121 typedef std::vector<ActiveAnimation> AnimationList; | 118 typedef std::vector<ActiveAnimation> AnimationList; |
122 typedef std::map<SessionStateAnimator::Container, AnimationList> | 119 typedef std::map<SessionStateAnimator::Container, AnimationList> |
123 ActiveAnimationsMap; | 120 ActiveAnimationsMap; |
124 | 121 |
125 // Starts an animation in the |animation_sequence| for each container | 122 // Starts an animation in the |animation_sequence| for each container |
126 // specified by |container_mask| with the given |type| and |speed|. | 123 // specified by |container_mask| with the given |type| and |speed|. |
127 virtual void StartAnimationInSequence( | 124 virtual void StartAnimationInSequence(int container_mask, |
128 int container_mask, | 125 AnimationType type, |
129 AnimationType type, | 126 AnimationSpeed speed, |
130 AnimationSpeed speed, | 127 AnimationSequence* animation_sequence); |
131 AnimationSequence* animation_sequence); | |
132 | 128 |
133 // Adds a single animation to the currently active animations. If an | 129 // Adds a single animation to the currently active animations. If an |
134 // animation is already active for the given |container| then it will be | 130 // animation is already active for the given |container| then it will be |
135 // replaced by the new one. The existing animation will be aborted by calling | 131 // replaced by the new one. The existing animation will be aborted by calling |
136 // OnAnimationAborted. | 132 // OnAnimationAborted. |
137 void AddAnimation(SessionStateAnimator::Container container, | 133 void AddAnimation(SessionStateAnimator::Container container, |
138 AnimationType type, | 134 AnimationType type, |
139 AnimationSpeed speed, | 135 AnimationSpeed speed, |
140 base::Closure success_callback, | 136 base::Closure success_callback, |
141 base::Closure failed_callback); | 137 base::Closure failed_callback); |
(...skipping 16 matching lines...) Expand all Loading... |
158 // Tracks whether the background is hidden or not. | 154 // Tracks whether the background is hidden or not. |
159 bool is_background_hidden_; | 155 bool is_background_hidden_; |
160 | 156 |
161 DISALLOW_COPY_AND_ASSIGN(TestSessionStateAnimator); | 157 DISALLOW_COPY_AND_ASSIGN(TestSessionStateAnimator); |
162 }; | 158 }; |
163 | 159 |
164 } // namespace test | 160 } // namespace test |
165 } // namespace ash | 161 } // namespace ash |
166 | 162 |
167 #endif // ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_ | 163 #endif // ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_ |
OLD | NEW |