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

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

Issue 14061025: ui: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months 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/surface/accelerated_surface_win.cc ('k') | ui/views/controls/button/button_dropdown.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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 public: 93 public:
94 BoundsAnimatorTest() : child_(new TestView()), animator_(&parent_) { 94 BoundsAnimatorTest() : child_(new TestView()), animator_(&parent_) {
95 parent_.AddChildView(child_); 95 parent_.AddChildView(child_);
96 } 96 }
97 97
98 TestView* parent() { return &parent_; } 98 TestView* parent() { return &parent_; }
99 TestView* child() { return child_; } 99 TestView* child() { return child_; }
100 TestBoundsAnimator* animator() { return &animator_; } 100 TestBoundsAnimator* animator() { return &animator_; }
101 101
102 private: 102 private:
103 MessageLoopForUI message_loop_; 103 base::MessageLoopForUI message_loop_;
104 TestView parent_; 104 TestView parent_;
105 TestView* child_; // Owned by |parent_|. 105 TestView* child_; // Owned by |parent_|.
106 TestBoundsAnimator animator_; 106 TestBoundsAnimator animator_;
107 107
108 DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorTest); 108 DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorTest);
109 }; 109 };
110 110
111 // Checks animate view to. 111 // Checks animate view to.
112 TEST_F(BoundsAnimatorTest, AnimateViewTo) { 112 TEST_F(BoundsAnimatorTest, AnimateViewTo) {
113 TestAnimationDelegate delegate; 113 TestAnimationDelegate delegate;
114 gfx::Rect initial_bounds(0, 0, 10, 10); 114 gfx::Rect initial_bounds(0, 0, 10, 10);
115 child()->SetBoundsRect(initial_bounds); 115 child()->SetBoundsRect(initial_bounds);
116 gfx::Rect target_bounds(10, 10, 20, 20); 116 gfx::Rect target_bounds(10, 10, 20, 20);
117 animator()->AnimateViewTo(child(), target_bounds); 117 animator()->AnimateViewTo(child(), target_bounds);
118 animator()->SetAnimationDelegate(child(), &delegate, false); 118 animator()->SetAnimationDelegate(child(), &delegate, false);
119 119
120 // The animator should be animating now. 120 // The animator should be animating now.
121 EXPECT_TRUE(animator()->IsAnimating()); 121 EXPECT_TRUE(animator()->IsAnimating());
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 base::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 EXPECT_EQ(gfx::UnionRects(target_bounds, initial_bounds), 132 EXPECT_EQ(gfx::UnionRects(target_bounds, initial_bounds),
133 parent()->dirty_rect()); 133 parent()->dirty_rect());
134 } 134 }
135 135
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/surface/accelerated_surface_win.cc ('k') | ui/views/controls/button/button_dropdown.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698