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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/gfx/animation/test_animation_delegate.h" | 10 #include "ui/gfx/animation/test_animation_delegate.h" |
11 | 11 |
12 namespace gfx { | 12 namespace gfx { |
13 | 13 |
14 // Class to provide access to SlideAnimation internals for testing. | 14 // Class to provide access to SlideAnimation internals for testing. |
15 class SlideAnimation::TestApi { | 15 class SlideAnimation::TestApi { |
16 public: | 16 public: |
17 explicit TestApi(SlideAnimation* animation) : animation_(animation) {} | 17 explicit TestApi(SlideAnimation* animation) : animation_(animation) {} |
18 | 18 |
19 void SetStartTime(base::TimeTicks ticks) { | 19 void SetStartTime(gfx::FrameTime ticks) { |
20 animation_->SetStartTime(ticks); | 20 animation_->SetStartTime(ticks); |
21 } | 21 } |
22 | 22 |
23 void Step(base::TimeTicks ticks) { | 23 void Step(gfx::FrameTime ticks) { |
24 animation_->Step(ticks); | 24 animation_->Step(ticks); |
25 } | 25 } |
26 | 26 |
27 private: | 27 private: |
28 SlideAnimation* animation_; | 28 SlideAnimation* animation_; |
29 | 29 |
30 DISALLOW_COPY_AND_ASSIGN(TestApi); | 30 DISALLOW_COPY_AND_ASSIGN(TestApi); |
31 }; | 31 }; |
32 | 32 |
33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 28 matching lines...) Expand all Loading... |
62 // Duration can be set after construction. | 62 // Duration can be set after construction. |
63 animation.SetSlideDuration(100); | 63 animation.SetSlideDuration(100); |
64 EXPECT_EQ(100, animation.GetSlideDuration()); | 64 EXPECT_EQ(100, animation.GetSlideDuration()); |
65 | 65 |
66 // Show toggles the appropriate state. | 66 // Show toggles the appropriate state. |
67 animation.Show(); | 67 animation.Show(); |
68 EXPECT_TRUE(animation.IsShowing()); | 68 EXPECT_TRUE(animation.IsShowing()); |
69 EXPECT_FALSE(animation.IsClosing()); | 69 EXPECT_FALSE(animation.IsClosing()); |
70 | 70 |
71 // Simulate running the animation. | 71 // Simulate running the animation. |
72 test_api.SetStartTime(base::TimeTicks()); | 72 test_api.SetStartTime(gfx::FrameTime()); |
73 test_api.Step(base::TimeTicks() + base::TimeDelta::FromMilliseconds(50)); | 73 test_api.Step(gfx::FrameTime() + base::TimeDelta::FromMilliseconds(50)); |
74 EXPECT_EQ(0.5, animation.GetCurrentValue()); | 74 EXPECT_EQ(0.5, animation.GetCurrentValue()); |
75 | 75 |
76 // We can start hiding mid-way through the animation. | 76 // We can start hiding mid-way through the animation. |
77 animation.Hide(); | 77 animation.Hide(); |
78 EXPECT_FALSE(animation.IsShowing()); | 78 EXPECT_FALSE(animation.IsShowing()); |
79 EXPECT_TRUE(animation.IsClosing()); | 79 EXPECT_TRUE(animation.IsClosing()); |
80 | 80 |
81 // Reset stops the animation. | 81 // Reset stops the animation. |
82 animation.Reset(); | 82 animation.Reset(); |
83 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 83 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
(...skipping 12 matching lines...) Expand all Loading... |
96 | 96 |
97 // Delete the animation. | 97 // Delete the animation. |
98 animation.reset(); | 98 animation.reset(); |
99 | 99 |
100 // Make sure the delegate wasn't notified. | 100 // Make sure the delegate wasn't notified. |
101 EXPECT_FALSE(delegate.finished()); | 101 EXPECT_FALSE(delegate.finished()); |
102 EXPECT_FALSE(delegate.canceled()); | 102 EXPECT_FALSE(delegate.canceled()); |
103 } | 103 } |
104 | 104 |
105 } // namespace gfx | 105 } // namespace gfx |
OLD | NEW |