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::UnionRects(target_bounds, initial_bounds), |
133 EXPECT_EQ(target_bounds, parent()->dirty_rect()); | 133 parent()->dirty_rect()); |
134 } | 134 } |
135 | 135 |
136 // Make sure an AnimationDelegate is deleted when canceled. | 136 // Make sure an AnimationDelegate is deleted when canceled. |
137 TEST_F(BoundsAnimatorTest, DeleteDelegateOnCancel) { | 137 TEST_F(BoundsAnimatorTest, DeleteDelegateOnCancel) { |
138 animator()->AnimateViewTo(child(), gfx::Rect(0, 0, 10, 10)); | 138 animator()->AnimateViewTo(child(), gfx::Rect(0, 0, 10, 10)); |
139 animator()->SetAnimationDelegate(child(), new OwnedDelegate(), true); | 139 animator()->SetAnimationDelegate(child(), new OwnedDelegate(), true); |
140 | 140 |
141 animator()->Cancel(); | 141 animator()->Cancel(); |
142 | 142 |
143 // The animator should no longer be animating. | 143 // The animator should no longer be animating. |
(...skipping 28 matching lines...) Expand all Loading... |
172 | 172 |
173 // Shouldn't be animating now. | 173 // Shouldn't be animating now. |
174 EXPECT_FALSE(animator()->IsAnimating()); | 174 EXPECT_FALSE(animator()->IsAnimating()); |
175 | 175 |
176 // Stopping should both cancel the delegate and delete it. | 176 // Stopping should both cancel the delegate and delete it. |
177 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); | 177 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); |
178 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); | 178 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); |
179 } | 179 } |
180 | 180 |
181 } // namespace views | 181 } // namespace views |
OLD | NEW |