| 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> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/gfx/animation/test_animation_delegate.h" | 12 #include "ui/gfx/animation/test_animation_delegate.h" |
| 12 | 13 |
| 13 namespace gfx { | 14 namespace gfx { |
| 14 | 15 |
| 15 // Class to provide access to SlideAnimation internals for testing. | 16 // Class to provide access to SlideAnimation internals for testing. |
| 16 class SlideAnimation::TestApi { | 17 class SlideAnimation::TestApi { |
| 17 public: | 18 public: |
| 18 explicit TestApi(SlideAnimation* animation) : animation_(animation) {} | 19 explicit TestApi(SlideAnimation* animation) : animation_(animation) {} |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 animation.Reset(); | 84 animation.Reset(); |
| 84 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 85 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
| 85 EXPECT_FALSE(animation.IsShowing()); | 86 EXPECT_FALSE(animation.IsShowing()); |
| 86 EXPECT_FALSE(animation.IsClosing()); | 87 EXPECT_FALSE(animation.IsClosing()); |
| 87 } | 88 } |
| 88 | 89 |
| 89 // Tests that delegate is not notified when animation is running and is deleted. | 90 // Tests that delegate is not notified when animation is running and is deleted. |
| 90 // (Such a scenario would cause problems for BoundsAnimator). | 91 // (Such a scenario would cause problems for BoundsAnimator). |
| 91 TEST_F(SlideAnimationTest, DontNotifyOnDelete) { | 92 TEST_F(SlideAnimationTest, DontNotifyOnDelete) { |
| 92 TestAnimationDelegate delegate; | 93 TestAnimationDelegate delegate; |
| 93 scoped_ptr<SlideAnimation> animation(new SlideAnimation(&delegate)); | 94 std::unique_ptr<SlideAnimation> animation(new SlideAnimation(&delegate)); |
| 94 | 95 |
| 95 // Start the animation. | 96 // Start the animation. |
| 96 animation->Show(); | 97 animation->Show(); |
| 97 | 98 |
| 98 // Delete the animation. | 99 // Delete the animation. |
| 99 animation.reset(); | 100 animation.reset(); |
| 100 | 101 |
| 101 // Make sure the delegate wasn't notified. | 102 // Make sure the delegate wasn't notified. |
| 102 EXPECT_FALSE(delegate.finished()); | 103 EXPECT_FALSE(delegate.finished()); |
| 103 EXPECT_FALSE(delegate.canceled()); | 104 EXPECT_FALSE(delegate.canceled()); |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace gfx | 107 } // namespace gfx |
| OLD | NEW |