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/gfx/animation/slide_animation.h" | 8 #include "ui/gfx/animation/slide_animation.h" |
9 #include "ui/gfx/animation/test_animation_delegate.h" | 9 #include "ui/gfx/animation/test_animation_delegate.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
11 | 11 |
12 using gfx::Animation; | 12 using gfx::Animation; |
13 using gfx::SlideAnimation; | 13 using gfx::SlideAnimation; |
14 using gfx::TestAnimationDelegate; | 14 using gfx::TestAnimationDelegate; |
15 | 15 |
16 namespace views { | 16 namespace views { |
17 namespace { | 17 namespace { |
18 | 18 |
19 class TestBoundsAnimator : public BoundsAnimator { | 19 class TestBoundsAnimator : public BoundsAnimator { |
20 public: | 20 public: |
21 explicit TestBoundsAnimator(View* view) : BoundsAnimator(view) { | 21 explicit TestBoundsAnimator(View* view) : BoundsAnimator(view) { |
22 } | 22 } |
23 | 23 |
24 protected: | 24 protected: |
25 virtual SlideAnimation* CreateAnimation() OVERRIDE { | 25 virtual SlideAnimation* CreateAnimation() override { |
26 SlideAnimation* animation = BoundsAnimator::CreateAnimation(); | 26 SlideAnimation* animation = BoundsAnimator::CreateAnimation(); |
27 animation->SetSlideDuration(10); | 27 animation->SetSlideDuration(10); |
28 return animation; | 28 return animation; |
29 } | 29 } |
30 | 30 |
31 private: | 31 private: |
32 DISALLOW_COPY_AND_ASSIGN(TestBoundsAnimator); | 32 DISALLOW_COPY_AND_ASSIGN(TestBoundsAnimator); |
33 }; | 33 }; |
34 | 34 |
35 class OwnedDelegate : public gfx::AnimationDelegate { | 35 class OwnedDelegate : public gfx::AnimationDelegate { |
(...skipping 10 matching lines...) Expand all Loading... |
46 return value; | 46 return value; |
47 } | 47 } |
48 | 48 |
49 static bool GetAndClearCanceled() { | 49 static bool GetAndClearCanceled() { |
50 bool value = canceled_; | 50 bool value = canceled_; |
51 canceled_ = false; | 51 canceled_ = false; |
52 return value; | 52 return value; |
53 } | 53 } |
54 | 54 |
55 // Overridden from gfx::AnimationDelegate: | 55 // Overridden from gfx::AnimationDelegate: |
56 virtual void AnimationCanceled(const Animation* animation) OVERRIDE { | 56 virtual void AnimationCanceled(const Animation* animation) override { |
57 canceled_ = true; | 57 canceled_ = true; |
58 } | 58 } |
59 | 59 |
60 private: | 60 private: |
61 static bool deleted_; | 61 static bool deleted_; |
62 static bool canceled_; | 62 static bool canceled_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(OwnedDelegate); | 64 DISALLOW_COPY_AND_ASSIGN(OwnedDelegate); |
65 }; | 65 }; |
66 | 66 |
67 // static | 67 // static |
68 bool OwnedDelegate::deleted_ = false; | 68 bool OwnedDelegate::deleted_ = false; |
69 bool OwnedDelegate::canceled_ = false; | 69 bool OwnedDelegate::canceled_ = false; |
70 | 70 |
71 class TestView : public View { | 71 class TestView : public View { |
72 public: | 72 public: |
73 TestView() {} | 73 TestView() {} |
74 | 74 |
75 virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE { | 75 virtual void SchedulePaintInRect(const gfx::Rect& r) override { |
76 if (dirty_rect_.IsEmpty()) | 76 if (dirty_rect_.IsEmpty()) |
77 dirty_rect_ = r; | 77 dirty_rect_ = r; |
78 else | 78 else |
79 dirty_rect_.Union(r); | 79 dirty_rect_.Union(r); |
80 } | 80 } |
81 | 81 |
82 const gfx::Rect& dirty_rect() const { return dirty_rect_; } | 82 const gfx::Rect& dirty_rect() const { return dirty_rect_; } |
83 | 83 |
84 private: | 84 private: |
85 gfx::Rect dirty_rect_; | 85 gfx::Rect dirty_rect_; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 // Shouldn't be animating now. | 176 // Shouldn't be animating now. |
177 EXPECT_FALSE(animator()->IsAnimating()); | 177 EXPECT_FALSE(animator()->IsAnimating()); |
178 | 178 |
179 // Stopping should both cancel the delegate and delete it. | 179 // Stopping should both cancel the delegate and delete it. |
180 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); | 180 EXPECT_TRUE(OwnedDelegate::GetAndClearDeleted()); |
181 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); | 181 EXPECT_TRUE(OwnedDelegate::GetAndClearCanceled()); |
182 } | 182 } |
183 | 183 |
184 } // namespace views | 184 } // namespace views |
OLD | NEW |