OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/gfx/animation/animation_delegate.h" | 6 #include "ui/gfx/animation/animation_delegate.h" |
7 #include "ui/gfx/animation/linear_animation.h" | 7 #include "ui/gfx/animation/linear_animation.h" |
8 #include "ui/gfx/animation/test_animation_delegate.h" | 8 #include "ui/gfx/animation/test_animation_delegate.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
24 // RunAnimation | 24 // RunAnimation |
25 | 25 |
26 class RunAnimation : public LinearAnimation { | 26 class RunAnimation : public LinearAnimation { |
27 public: | 27 public: |
28 RunAnimation(int frame_rate, AnimationDelegate* delegate) | 28 RunAnimation(int frame_rate, AnimationDelegate* delegate) |
29 : LinearAnimation(frame_rate, delegate) { | 29 : LinearAnimation(frame_rate, delegate) { |
30 } | 30 } |
31 | 31 |
32 virtual void AnimateToState(double state) OVERRIDE { | 32 virtual void AnimateToState(double state) override { |
33 EXPECT_LE(0.0, state); | 33 EXPECT_LE(0.0, state); |
34 EXPECT_GE(1.0, state); | 34 EXPECT_GE(1.0, state); |
35 } | 35 } |
36 }; | 36 }; |
37 | 37 |
38 /////////////////////////////////////////////////////////////////////////////// | 38 /////////////////////////////////////////////////////////////////////////////// |
39 // CancelAnimation | 39 // CancelAnimation |
40 | 40 |
41 class CancelAnimation : public LinearAnimation { | 41 class CancelAnimation : public LinearAnimation { |
42 public: | 42 public: |
43 CancelAnimation(int duration, int frame_rate, AnimationDelegate* delegate) | 43 CancelAnimation(int duration, int frame_rate, AnimationDelegate* delegate) |
44 : LinearAnimation(duration, frame_rate, delegate) { | 44 : LinearAnimation(duration, frame_rate, delegate) { |
45 } | 45 } |
46 | 46 |
47 virtual void AnimateToState(double state) OVERRIDE { | 47 virtual void AnimateToState(double state) override { |
48 if (state >= 0.5) | 48 if (state >= 0.5) |
49 Stop(); | 49 Stop(); |
50 } | 50 } |
51 }; | 51 }; |
52 | 52 |
53 /////////////////////////////////////////////////////////////////////////////// | 53 /////////////////////////////////////////////////////////////////////////////// |
54 // EndAnimation | 54 // EndAnimation |
55 | 55 |
56 class EndAnimation : public LinearAnimation { | 56 class EndAnimation : public LinearAnimation { |
57 public: | 57 public: |
58 EndAnimation(int duration, int frame_rate, AnimationDelegate* delegate) | 58 EndAnimation(int duration, int frame_rate, AnimationDelegate* delegate) |
59 : LinearAnimation(duration, frame_rate, delegate) { | 59 : LinearAnimation(duration, frame_rate, delegate) { |
60 } | 60 } |
61 | 61 |
62 virtual void AnimateToState(double state) OVERRIDE { | 62 virtual void AnimateToState(double state) override { |
63 if (state >= 0.5) | 63 if (state >= 0.5) |
64 End(); | 64 End(); |
65 } | 65 } |
66 }; | 66 }; |
67 | 67 |
68 /////////////////////////////////////////////////////////////////////////////// | 68 /////////////////////////////////////////////////////////////////////////////// |
69 // DeletingAnimationDelegate | 69 // DeletingAnimationDelegate |
70 | 70 |
71 // AnimationDelegate implementation that deletes the animation in ended. | 71 // AnimationDelegate implementation that deletes the animation in ended. |
72 class DeletingAnimationDelegate : public AnimationDelegate { | 72 class DeletingAnimationDelegate : public AnimationDelegate { |
73 public: | 73 public: |
74 virtual void AnimationEnded(const Animation* animation) OVERRIDE { | 74 virtual void AnimationEnded(const Animation* animation) override { |
75 delete animation; | 75 delete animation; |
76 base::MessageLoop::current()->Quit(); | 76 base::MessageLoop::current()->Quit(); |
77 } | 77 } |
78 }; | 78 }; |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 /////////////////////////////////////////////////////////////////////////////// | 82 /////////////////////////////////////////////////////////////////////////////// |
83 // LinearCase | 83 // LinearCase |
84 | 84 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 149 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
150 animation.Start(); | 150 animation.Start(); |
151 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 151 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
152 animation.End(); | 152 animation.End(); |
153 EXPECT_EQ(1.0, animation.GetCurrentValue()); | 153 EXPECT_EQ(1.0, animation.GetCurrentValue()); |
154 animation.Start(); | 154 animation.Start(); |
155 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 155 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
156 } | 156 } |
157 | 157 |
158 } // namespace gfx | 158 } // namespace gfx |
OLD | NEW |