OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/animation/slide_animation.h" | 5 #include "ui/gfx/animation/slide_animation.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 //////////////////////////////////////////////////////////////////////////////// | 35 //////////////////////////////////////////////////////////////////////////////// |
36 // SlideAnimationTest | 36 // SlideAnimationTest |
37 class SlideAnimationTest: public testing::Test { | 37 class SlideAnimationTest: public testing::Test { |
38 private: | 38 private: |
39 base::MessageLoopForUI message_loop_; | 39 base::MessageLoopForUI message_loop_; |
40 }; | 40 }; |
41 | 41 |
42 // Tests animation construction. | 42 // Tests animation construction. |
43 TEST_F(SlideAnimationTest, InitialState) { | 43 TEST_F(SlideAnimationTest, InitialState) { |
44 SlideAnimation animation(NULL); | 44 SlideAnimation animation(nullptr); |
45 // By default, slide animations are 60 Hz, so the timer interval should be | 45 // By default, slide animations are 60 Hz, so the timer interval should be |
46 // 1/60th of a second. | 46 // 1/60th of a second. |
47 EXPECT_EQ(1000 / 60, animation.timer_interval().InMilliseconds()); | 47 EXPECT_EQ(1000 / 60, animation.timer_interval().InMilliseconds()); |
48 // Duration defaults to 120 ms. | 48 // Duration defaults to 120 ms. |
49 EXPECT_EQ(120, animation.GetSlideDuration()); | 49 EXPECT_EQ(120, animation.GetSlideDuration()); |
50 // Slide is neither showing nor closing. | 50 // Slide is neither showing nor closing. |
51 EXPECT_FALSE(animation.IsShowing()); | 51 EXPECT_FALSE(animation.IsShowing()); |
52 EXPECT_FALSE(animation.IsClosing()); | 52 EXPECT_FALSE(animation.IsClosing()); |
53 // Starts at 0. | 53 // Starts at 0. |
54 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 54 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
55 } | 55 } |
56 | 56 |
57 TEST_F(SlideAnimationTest, Basics) { | 57 TEST_F(SlideAnimationTest, Basics) { |
58 SlideAnimation animation(NULL); | 58 SlideAnimation animation(nullptr); |
59 SlideAnimation::TestApi test_api(&animation); | 59 SlideAnimation::TestApi test_api(&animation); |
60 | 60 |
61 // Use linear tweening to make the math easier below. | 61 // Use linear tweening to make the math easier below. |
62 animation.SetTweenType(Tween::LINEAR); | 62 animation.SetTweenType(Tween::LINEAR); |
63 | 63 |
64 // Duration can be set after construction. | 64 // Duration can be set after construction. |
65 animation.SetSlideDuration(100); | 65 animation.SetSlideDuration(100); |
66 EXPECT_EQ(100, animation.GetSlideDuration()); | 66 EXPECT_EQ(100, animation.GetSlideDuration()); |
67 | 67 |
68 // Show toggles the appropriate state. | 68 // Show toggles the appropriate state. |
(...skipping 29 matching lines...) Expand all Loading... |
98 | 98 |
99 // Delete the animation. | 99 // Delete the animation. |
100 animation.reset(); | 100 animation.reset(); |
101 | 101 |
102 // Make sure the delegate wasn't notified. | 102 // Make sure the delegate wasn't notified. |
103 EXPECT_FALSE(delegate.finished()); | 103 EXPECT_FALSE(delegate.finished()); |
104 EXPECT_FALSE(delegate.canceled()); | 104 EXPECT_FALSE(delegate.canceled()); |
105 } | 105 } |
106 | 106 |
107 } // namespace gfx | 107 } // namespace gfx |
OLD | NEW |