OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/animation/animation_container.h" | 5 #include "ui/gfx/animation/animation_container.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/animation/animation_container_observer.h" | 9 #include "ui/gfx/animation/animation_container_observer.h" |
10 #include "ui/gfx/animation/linear_animation.h" | 10 #include "ui/gfx/animation/linear_animation.h" |
11 #include "ui/gfx/animation/test_animation_delegate.h" | 11 #include "ui/gfx/animation/test_animation_delegate.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class FakeAnimationContainerObserver : public AnimationContainerObserver { | 17 class FakeAnimationContainerObserver : public AnimationContainerObserver { |
18 public: | 18 public: |
19 FakeAnimationContainerObserver() | 19 FakeAnimationContainerObserver() |
20 : progressed_count_(0), | 20 : progressed_count_(0), |
21 empty_(false) { | 21 empty_(false) { |
22 } | 22 } |
23 | 23 |
24 int progressed_count() const { return progressed_count_; } | 24 int progressed_count() const { return progressed_count_; } |
25 bool empty() const { return empty_; } | 25 bool empty() const { return empty_; } |
26 | 26 |
27 private: | 27 private: |
28 virtual void AnimationContainerProgressed( | 28 void AnimationContainerProgressed(AnimationContainer* container) override { |
29 AnimationContainer* container) override { | |
30 progressed_count_++; | 29 progressed_count_++; |
31 } | 30 } |
32 | 31 |
33 // Invoked when no more animations are being managed by this container. | 32 // Invoked when no more animations are being managed by this container. |
34 virtual void AnimationContainerEmpty(AnimationContainer* container) override { | 33 void AnimationContainerEmpty(AnimationContainer* container) override { |
35 empty_ = true; | 34 empty_ = true; |
36 } | 35 } |
37 | 36 |
38 int progressed_count_; | 37 int progressed_count_; |
39 bool empty_; | 38 bool empty_; |
40 | 39 |
41 DISALLOW_COPY_AND_ASSIGN(FakeAnimationContainerObserver); | 40 DISALLOW_COPY_AND_ASSIGN(FakeAnimationContainerObserver); |
42 }; | 41 }; |
43 | 42 |
44 class TestAnimation : public LinearAnimation { | 43 class TestAnimation : public LinearAnimation { |
45 public: | 44 public: |
46 explicit TestAnimation(AnimationDelegate* delegate) | 45 explicit TestAnimation(AnimationDelegate* delegate) |
47 : LinearAnimation(20, 20, delegate) { | 46 : LinearAnimation(20, 20, delegate) { |
48 } | 47 } |
49 | 48 |
50 virtual void AnimateToState(double state) override { | 49 void AnimateToState(double state) override {} |
51 } | |
52 | 50 |
53 private: | 51 private: |
54 DISALLOW_COPY_AND_ASSIGN(TestAnimation); | 52 DISALLOW_COPY_AND_ASSIGN(TestAnimation); |
55 }; | 53 }; |
56 | 54 |
57 } // namespace | 55 } // namespace |
58 | 56 |
59 class AnimationContainerTest: public testing::Test { | 57 class AnimationContainerTest: public testing::Test { |
60 private: | 58 private: |
61 base::MessageLoopForUI message_loop_; | 59 base::MessageLoopForUI message_loop_; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 127 |
130 EXPECT_TRUE(observer.empty()); | 128 EXPECT_TRUE(observer.empty()); |
131 | 129 |
132 // And the container should no longer be running. | 130 // And the container should no longer be running. |
133 EXPECT_FALSE(container->is_running()); | 131 EXPECT_FALSE(container->is_running()); |
134 | 132 |
135 container->set_observer(NULL); | 133 container->set_observer(NULL); |
136 } | 134 } |
137 | 135 |
138 } // namespace gfx | 136 } // namespace gfx |
OLD | NEW |