Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: ash/test/test_session_state_animator.h

Issue 326813004: Added quick lock mechanism while in Touchview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add docs for TestSessionStateAnimator::AnimationSequence. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_
6 #define ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "ash/ash_export.h"
12 #include "ash/wm/session_state_animator.h"
13 #include "base/basictypes.h"
14
15 namespace ash {
16 namespace test {
17
18 // A SessionStateAnimator that offers control over the lifetime of active
19 // animations.
20 // NOTE: The TestSessionStateAnimator limits each
21 // SessionStateAnimator::Container to a single active animation at any one time.
22 // If a new animation is started on a container the existing one will be
23 // aborted.
24 class ASH_EXPORT TestSessionStateAnimator : public SessionStateAnimator {
25 public:
26 TestSessionStateAnimator();
27 virtual ~TestSessionStateAnimator();
28
29 int last_animation_epoch() {
30 return last_animation_epoch_;
31 }
32
33 // Resets the current animation epoch back to 0 and aborts all currently
34 // active animations.
35 void ResetAnimationEpoch();
36
37 // Advances all contained animations by the specified |duration|. Any
38 // animations that will have completed after |duration| will have it's
Daniel Erat 2014/09/08 16:16:02 nit: remove extra space before "will"; s/it's/its/
bruthig 2014/09/09 17:32:33 Done.
39 // callback called.
40 void Advance(const base::TimeDelta& duration);
41
42 // Simulates running all of the contained animations to completion. Each
43 // contained AnimationSequence will have OnAnimationCompleted if
Daniel Erat 2014/09/08 16:16:01 s/have/run/?
bruthig 2014/09/09 17:32:33 Done.
44 // |completed_successfully| is true and OnAnimationAborted if false.
45 void CompleteAnimations(int animation_epoch, bool completed_successfully);
46
47 // Convenience method that calls CompleteAnimations with the last
48 // |animation_epoch|. In effect this will complete all animations.
49 // See CompleteAnimations for more documenation on |completed_succesffully|.
50 void CompleteAllAnimations(bool completed_successfully);
51
52 // Returns true if there is an animation active with |type| for the given
53 // |container|.
54 bool IsContainerAnimated(SessionStateAnimator::Container container,
55 SessionStateAnimator::AnimationType type) const;
56
57 // Returns true if there is an animation active with |type| for all the given
58 // containers specified by |container_mask|.
59 bool AreContainersAnimated(int container_mask,
60 SessionStateAnimator::AnimationType type) const;
61
62 // Returns the number of active animations.
63 size_t GetAnimationCount() const;
64
65 // ash::SessionStateAnimator:
66 virtual void StartAnimation(int container_mask,
67 AnimationType type,
68 AnimationSpeed speed) OVERRIDE;
69 virtual void StartAnimationWithCallback(
70 int container_mask,
71 AnimationType type,
72 AnimationSpeed speed,
73 base::Closure callback) OVERRIDE;
74 virtual AnimationSequence* BeginAnimationSequence(
75 base::Closure callback) OVERRIDE;
76
77 private:
78 class AnimationSequence;
79 friend class AnimationSequence;
80
81 // Data structure to track the currently active animations and their
82 // callbacks.
83 struct ActiveAnimation {
84 ActiveAnimation(
85 int animation_epoch,
86 base::TimeDelta duration,
87 SessionStateAnimator::Container container,
88 AnimationType type,
89 AnimationSpeed speed,
90 base::Closure success_callback,
91 base::Closure failed_callback);
92 virtual ~ActiveAnimation();
93
94 // The time epoch that this animation was scheduled.
95 int animation_epoch;
96
97 // The time remaining for this animation.
98 base::TimeDelta remaining_duration;
99
100 // The container which is being animated.
101 SessionStateAnimator::Container container;
102
103 // The animation type that is being done.
104 AnimationType type;
105
106 // The speed at which the animation is being done.
107 AnimationSpeed speed;
108
109 // The callback to be invoked upon a successful completion.
110 base::Closure success_callback;
111
112 // The callback to be invoked upon an unsuccessful completion.
113 base::Closure failed_callback;
114 };
115
116 typedef std::vector<ActiveAnimation> AnimationList;
117 typedef std::map<SessionStateAnimator::Container, AnimationList>
118 ActiveAnimationsMap;
119
120 // Starts an animation in the |animation_sequence| for each container
121 // specified by |container_mask| with the given |type| and |speed|.
122 virtual void StartAnimationInSequence(int container_mask,
Daniel Erat 2014/09/08 16:16:02 nit: move "int container_mask" to the next line, i
bruthig 2014/09/09 17:32:34 Done.
123 AnimationType type,
124 AnimationSpeed speed,
125 AnimationSequence* animation_sequence);
126
127 // Adds a single animation to the currently active animations. If an
128 // animation is already active for the given |container| then it will be
129 // replaced by the new one. The existing animation will be aborted by calling
130 // OnAnimationAborted.
131 void AddAnimation(SessionStateAnimator::Container container,
132 AnimationType type,
133 AnimationSpeed speed,
134 base::Closure success_callback,
135 base::Closure failed_callback);
136
137 // If an animation is currently active for the given |container| it will be
138 // aborted by invoking OnAnimationAborted and removed from the list of active
139 // animations.
140 void AbortAnimation(SessionStateAnimator::Container container);
141
142 // Used for easy iteration over all the containers.
143 static const SessionStateAnimator::Container kAllContainers[];
144
145 // A map of currently active animations.
146 ActiveAnimationsMap active_animations_;
147
148 // A time counter that tracks the last shecudled animation or animation
Daniel Erat 2014/09/08 16:16:02 nit: s/shecudled/scheduled/
bruthig 2014/09/09 17:32:33 Done.
149 // sequence.
150 int last_animation_epoch_;
151
152 DISALLOW_COPY_AND_ASSIGN(TestSessionStateAnimator);
153 };
154
155 } // namespace test
156 } // namespace ash
157
158 #endif // ASH_TEST_TEST_SESSION_STATE_ANIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698