| Index: app/animation_unittest.cc
|
| diff --git a/app/animation_unittest.cc b/app/animation_unittest.cc
|
| index 30f9b523dcbdf7bf18f59eb25bcc9ab765f7c167..df0b262b28adc421d4f6ef8ea667717a7a5ab0a0 100644
|
| --- a/app/animation_unittest.cc
|
| +++ b/app/animation_unittest.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "app/animation.h"
|
| +#include "app/linear_animation.h"
|
| #include "app/test_animation_delegate.h"
|
| #if defined(OS_WIN)
|
| #include "base/win_util.h"
|
| @@ -14,13 +14,15 @@ class AnimationTest: public testing::Test {
|
| MessageLoopForUI message_loop_;
|
| };
|
|
|
| +namespace {
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // RunAnimation
|
|
|
| -class RunAnimation : public Animation {
|
| +class RunAnimation : public LinearAnimation {
|
| public:
|
| RunAnimation(int frame_rate, AnimationDelegate* delegate)
|
| - : Animation(frame_rate, delegate) {
|
| + : LinearAnimation(frame_rate, delegate) {
|
| }
|
|
|
| virtual void AnimateToState(double state) {
|
| @@ -32,10 +34,10 @@ class RunAnimation : public Animation {
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // CancelAnimation
|
|
|
| -class CancelAnimation : public Animation {
|
| +class CancelAnimation : public LinearAnimation {
|
| public:
|
| CancelAnimation(int duration, int frame_rate, AnimationDelegate* delegate)
|
| - : Animation(duration, frame_rate, delegate) {
|
| + : LinearAnimation(duration, frame_rate, delegate) {
|
| }
|
|
|
| virtual void AnimateToState(double state) {
|
| @@ -45,6 +47,35 @@ class CancelAnimation : public Animation {
|
| };
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| +// EndAnimation
|
| +
|
| +class EndAnimation : public LinearAnimation {
|
| + public:
|
| + EndAnimation(int duration, int frame_rate, AnimationDelegate* delegate)
|
| + : LinearAnimation(duration, frame_rate, delegate) {
|
| + }
|
| +
|
| + virtual void AnimateToState(double state) {
|
| + if (state >= 0.5)
|
| + End();
|
| + }
|
| +};
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// DeletingAnimationDelegate
|
| +
|
| +// AnimationDelegate implementation that deletes the animation in ended.
|
| +class DeletingAnimationDelegate : public AnimationDelegate {
|
| + public:
|
| + virtual void AnimationEnded(const Animation* animation) {
|
| + delete animation;
|
| + MessageLoop::current()->Quit();
|
| + }
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| // LinearCase
|
|
|
| TEST_F(AnimationTest, RunCase) {
|
| @@ -68,6 +99,27 @@ TEST_F(AnimationTest, CancelCase) {
|
| EXPECT_TRUE(ad.canceled());
|
| }
|
|
|
| +// Lets an animation run, invoking End part way through and make sure we get the
|
| +// right delegate methods invoked.
|
| +TEST_F(AnimationTest, EndCase) {
|
| + TestAnimationDelegate ad;
|
| + EndAnimation a2(2000, 150, &ad);
|
| + a2.Start();
|
| + MessageLoop::current()->Run();
|
| +
|
| + EXPECT_TRUE(ad.finished());
|
| + EXPECT_FALSE(ad.canceled());
|
| +}
|
| +
|
| +// Runs an animation with a delegate that deletes the animation in end.
|
| +TEST_F(AnimationTest, DeleteFromEnd) {
|
| + DeletingAnimationDelegate delegate;
|
| + RunAnimation* animation = new RunAnimation(150, &delegate);
|
| + animation->Start();
|
| + MessageLoop::current()->Run();
|
| + // delegate should have deleted animation.
|
| +}
|
| +
|
| TEST_F(AnimationTest, ShouldRenderRichAnimation) {
|
| #if defined(OS_WIN)
|
| if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) {
|
|
|