Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: ui/views/animation/bounds_animator_unittest.cc

Issue 11270042: Add non-member non-mutating methods for common gfx::Rect operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/animation/bounds_animator.cc ('k') | ui/views/widget/root_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/views/animation/bounds_animator.cc ('k') | ui/views/widget/root_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698