| 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 "base/run_loop.h" |
| 5 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "ui/gfx/animation/animation_delegate.h" | 8 #include "ui/gfx/animation/animation_delegate.h" |
| 8 #include "ui/gfx/animation/linear_animation.h" | 9 #include "ui/gfx/animation/linear_animation.h" |
| 9 #include "ui/gfx/animation/test_animation_delegate.h" | 10 #include "ui/gfx/animation/test_animation_delegate.h" |
| 10 | 11 |
| 11 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 12 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 13 #endif | 14 #endif |
| 14 | 15 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } // namespace | 82 } // namespace |
| 82 | 83 |
| 83 /////////////////////////////////////////////////////////////////////////////// | 84 /////////////////////////////////////////////////////////////////////////////// |
| 84 // LinearCase | 85 // LinearCase |
| 85 | 86 |
| 86 TEST_F(AnimationTest, RunCase) { | 87 TEST_F(AnimationTest, RunCase) { |
| 87 TestAnimationDelegate ad; | 88 TestAnimationDelegate ad; |
| 88 RunAnimation a1(150, &ad); | 89 RunAnimation a1(150, &ad); |
| 89 a1.SetDuration(2000); | 90 a1.SetDuration(2000); |
| 90 a1.Start(); | 91 a1.Start(); |
| 91 base::MessageLoop::current()->Run(); | 92 base::RunLoop().Run(); |
| 92 | 93 |
| 93 EXPECT_TRUE(ad.finished()); | 94 EXPECT_TRUE(ad.finished()); |
| 94 EXPECT_FALSE(ad.canceled()); | 95 EXPECT_FALSE(ad.canceled()); |
| 95 } | 96 } |
| 96 | 97 |
| 97 TEST_F(AnimationTest, CancelCase) { | 98 TEST_F(AnimationTest, CancelCase) { |
| 98 TestAnimationDelegate ad; | 99 TestAnimationDelegate ad; |
| 99 CancelAnimation a2(2000, 150, &ad); | 100 CancelAnimation a2(2000, 150, &ad); |
| 100 a2.Start(); | 101 a2.Start(); |
| 101 base::MessageLoop::current()->Run(); | 102 base::RunLoop().Run(); |
| 102 | 103 |
| 103 EXPECT_TRUE(ad.finished()); | 104 EXPECT_TRUE(ad.finished()); |
| 104 EXPECT_TRUE(ad.canceled()); | 105 EXPECT_TRUE(ad.canceled()); |
| 105 } | 106 } |
| 106 | 107 |
| 107 // Lets an animation run, invoking End part way through and make sure we get the | 108 // Lets an animation run, invoking End part way through and make sure we get the |
| 108 // right delegate methods invoked. | 109 // right delegate methods invoked. |
| 109 TEST_F(AnimationTest, EndCase) { | 110 TEST_F(AnimationTest, EndCase) { |
| 110 TestAnimationDelegate ad; | 111 TestAnimationDelegate ad; |
| 111 EndAnimation a2(2000, 150, &ad); | 112 EndAnimation a2(2000, 150, &ad); |
| 112 a2.Start(); | 113 a2.Start(); |
| 113 base::MessageLoop::current()->Run(); | 114 base::RunLoop().Run(); |
| 114 | 115 |
| 115 EXPECT_TRUE(ad.finished()); | 116 EXPECT_TRUE(ad.finished()); |
| 116 EXPECT_FALSE(ad.canceled()); | 117 EXPECT_FALSE(ad.canceled()); |
| 117 } | 118 } |
| 118 | 119 |
| 119 // Runs an animation with a delegate that deletes the animation in end. | 120 // Runs an animation with a delegate that deletes the animation in end. |
| 120 TEST_F(AnimationTest, DeleteFromEnd) { | 121 TEST_F(AnimationTest, DeleteFromEnd) { |
| 121 DeletingAnimationDelegate delegate; | 122 DeletingAnimationDelegate delegate; |
| 122 RunAnimation* animation = new RunAnimation(150, &delegate); | 123 RunAnimation* animation = new RunAnimation(150, &delegate); |
| 123 animation->Start(); | 124 animation->Start(); |
| 124 base::MessageLoop::current()->Run(); | 125 base::RunLoop().Run(); |
| 125 // delegate should have deleted animation. | 126 // delegate should have deleted animation. |
| 126 } | 127 } |
| 127 | 128 |
| 128 TEST_F(AnimationTest, ShouldRenderRichAnimation) { | 129 TEST_F(AnimationTest, ShouldRenderRichAnimation) { |
| 129 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 130 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 131 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 131 BOOL result; | 132 BOOL result; |
| 132 ASSERT_NE( | 133 ASSERT_NE( |
| 133 0, ::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0)); | 134 0, ::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0)); |
| 134 // ShouldRenderRichAnimation() should check the SPI_GETCLIENTAREAANIMATION | 135 // ShouldRenderRichAnimation() should check the SPI_GETCLIENTAREAANIMATION |
| (...skipping 15 matching lines...) Expand all Loading... |
| 150 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 151 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
| 151 animation.Start(); | 152 animation.Start(); |
| 152 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 153 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
| 153 animation.End(); | 154 animation.End(); |
| 154 EXPECT_EQ(1.0, animation.GetCurrentValue()); | 155 EXPECT_EQ(1.0, animation.GetCurrentValue()); |
| 155 animation.Start(); | 156 animation.Start(); |
| 156 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 157 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 } // namespace gfx | 160 } // namespace gfx |
| OLD | NEW |