| 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/views/animation/bounds_animator.h" | 5 #include "ui/views/animation/bounds_animator.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/base/animation/slide_animation.h" | 8 #include "ui/base/animation/slide_animation.h" |
| 9 #include "ui/base/animation/test_animation_delegate.h" | 9 #include "ui/base/animation/test_animation_delegate.h" |
| 10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 // Run the message loop; the delegate exits the loop when the animation is | 123 // Run the message loop; the delegate exits the loop when the animation is |
| 124 // done. | 124 // done. |
| 125 MessageLoop::current()->Run(); | 125 MessageLoop::current()->Run(); |
| 126 | 126 |
| 127 // Make sure the bounds match of the view that was animated match. | 127 // Make sure the bounds match of the view that was animated match. |
| 128 EXPECT_EQ(target_bounds, child()->bounds()); | 128 EXPECT_EQ(target_bounds, child()->bounds()); |
| 129 | 129 |
| 130 // The parent should have been told to repaint as the animation progressed. | 130 // The parent should have been told to repaint as the animation progressed. |
| 131 // The resulting rect is the union of the original and target bounds. | 131 // The resulting rect is the union of the original and target bounds. |
| 132 target_bounds.Union(initial_bounds); | 132 EXPECT_EQ(gfx::Union(target_bounds, initial_bounds), parent()->dirty_rect()); |
| 133 EXPECT_EQ(target_bounds, parent()->dirty_rect()); | |
| 134 } | 133 } |
| 135 | 134 |
| 136 // Make sure an AnimationDelegate is deleted when canceled. | 135 // Make sure an AnimationDelegate is deleted when canceled. |
| 137 TEST_F(BoundsAnimatorTest, DeleteDelegateOnCancel) { | 136 TEST_F(BoundsAnimatorTest, DeleteDelegateOnCancel) { |
| 138 animator()->AnimateViewTo(child(), gfx::Rect(0, 0, 10, 10)); | 137 animator()->AnimateViewTo(child(), gfx::Rect(0, 0, 10, 10)); |
| 139 animator()->SetAnimationDelegate(child(), new OwnedDelegate(), true); | 138 animator()->SetAnimationDelegate(child(), new OwnedDelegate(), true); |
| 140 | 139 |
| 141 animator()->Cancel(); | 140 animator()->Cancel(); |
| 142 | 141 |
| 143 // The animator should no longer be animating. | 142 // The animator should no longer be animating. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 172 | 171 |
| 173 // Shouldn't be animating now. | 172 // Shouldn't be animating now. |
| 174 EXPECT_FALSE(animator()->IsAnimating()); | 173 EXPECT_FALSE(animator()->IsAnimating()); |
| 175 | 174 |
| 176 // Stopping should both cancel the delegate and delete it. | 175 // Stopping should both cancel the delegate and delete it. |
| 177 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); | 176 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); |
| 178 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); | 177 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); |
| 179 } | 178 } |
| 180 | 179 |
| 181 } // namespace views | 180 } // namespace views |
| OLD | NEW |