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 "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/scoped_task_environment.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/gfx/animation/slide_animation.h" | 11 #include "ui/gfx/animation/slide_animation.h" |
11 #include "ui/gfx/animation/test_animation_delegate.h" | 12 #include "ui/gfx/animation/test_animation_delegate.h" |
12 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
13 | 14 |
14 using gfx::Animation; | 15 using gfx::Animation; |
15 using gfx::SlideAnimation; | 16 using gfx::SlideAnimation; |
16 using gfx::TestAnimationDelegate; | 17 using gfx::TestAnimationDelegate; |
17 | 18 |
18 namespace views { | 19 namespace views { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 private: | 85 private: |
85 gfx::Rect dirty_rect_; | 86 gfx::Rect dirty_rect_; |
86 | 87 |
87 DISALLOW_COPY_AND_ASSIGN(TestView); | 88 DISALLOW_COPY_AND_ASSIGN(TestView); |
88 }; | 89 }; |
89 | 90 |
90 } // namespace | 91 } // namespace |
91 | 92 |
92 class BoundsAnimatorTest : public testing::Test { | 93 class BoundsAnimatorTest : public testing::Test { |
93 public: | 94 public: |
94 BoundsAnimatorTest() : child_(new TestView()), animator_(&parent_) { | 95 BoundsAnimatorTest() |
| 96 : scoped_task_environment_( |
| 97 base::test::ScopedTaskEnvironment::MainThreadType::UI), |
| 98 child_(new TestView()), |
| 99 animator_(&parent_) { |
95 parent_.AddChildView(child_); | 100 parent_.AddChildView(child_); |
96 } | 101 } |
97 | 102 |
98 TestView* parent() { return &parent_; } | 103 TestView* parent() { return &parent_; } |
99 TestView* child() { return child_; } | 104 TestView* child() { return child_; } |
100 TestBoundsAnimator* animator() { return &animator_; } | 105 TestBoundsAnimator* animator() { return &animator_; } |
101 | 106 |
102 private: | 107 private: |
103 base::MessageLoopForUI message_loop_; | 108 base::test::ScopedTaskEnvironment scoped_task_environment_; |
104 TestView parent_; | 109 TestView parent_; |
105 TestView* child_; // Owned by |parent_|. | 110 TestView* child_; // Owned by |parent_|. |
106 TestBoundsAnimator animator_; | 111 TestBoundsAnimator animator_; |
107 | 112 |
108 DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorTest); | 113 DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorTest); |
109 }; | 114 }; |
110 | 115 |
111 // Checks animate view to. | 116 // Checks animate view to. |
112 TEST_F(BoundsAnimatorTest, AnimateViewTo) { | 117 TEST_F(BoundsAnimatorTest, AnimateViewTo) { |
113 gfx::Rect initial_bounds(0, 0, 10, 10); | 118 gfx::Rect initial_bounds(0, 0, 10, 10); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 181 |
177 // Shouldn't be animating now. | 182 // Shouldn't be animating now. |
178 EXPECT_FALSE(animator()->IsAnimating()); | 183 EXPECT_FALSE(animator()->IsAnimating()); |
179 | 184 |
180 // Stopping should both cancel the delegate and delete it. | 185 // Stopping should both cancel the delegate and delete it. |
181 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); | 186 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); |
182 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); | 187 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); |
183 } | 188 } |
184 | 189 |
185 } // namespace views | 190 } // namespace views |
OLD | NEW |