| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/gfx/animation/animation_delegate.h" | 6 #include "ui/gfx/animation/animation_delegate.h" |
| 7 #include "ui/gfx/animation/linear_animation.h" | 7 #include "ui/gfx/animation/linear_animation.h" |
| 8 #include "ui/gfx/animation/test_animation_delegate.h" | 8 #include "ui/gfx/animation/test_animation_delegate.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | |
| 11 #include "base/win/windows_version.h" | |
| 12 #endif | |
| 13 | |
| 14 namespace gfx { | 10 namespace gfx { |
| 15 | 11 |
| 16 class AnimationTest: public testing::Test { | 12 class AnimationTest: public testing::Test { |
| 17 private: | 13 private: |
| 18 base::MessageLoopForUI message_loop_; | 14 base::MessageLoopForUI message_loop_; |
| 19 }; | 15 }; |
| 20 | 16 |
| 21 namespace { | 17 namespace { |
| 22 | 18 |
| 23 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Runs an animation with a delegate that deletes the animation in end. | 114 // Runs an animation with a delegate that deletes the animation in end. |
| 119 TEST_F(AnimationTest, DeleteFromEnd) { | 115 TEST_F(AnimationTest, DeleteFromEnd) { |
| 120 DeletingAnimationDelegate delegate; | 116 DeletingAnimationDelegate delegate; |
| 121 RunAnimation* animation = new RunAnimation(150, &delegate); | 117 RunAnimation* animation = new RunAnimation(150, &delegate); |
| 122 animation->Start(); | 118 animation->Start(); |
| 123 base::MessageLoop::current()->Run(); | 119 base::MessageLoop::current()->Run(); |
| 124 // delegate should have deleted animation. | 120 // delegate should have deleted animation. |
| 125 } | 121 } |
| 126 | 122 |
| 127 TEST_F(AnimationTest, ShouldRenderRichAnimation) { | 123 TEST_F(AnimationTest, ShouldRenderRichAnimation) { |
| 128 #if defined(OS_WIN) | |
| 129 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | |
| 130 BOOL result; | |
| 131 ASSERT_NE( | |
| 132 0, ::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0)); | |
| 133 // ShouldRenderRichAnimation() should check the SPI_GETCLIENTAREAANIMATION | |
| 134 // value on Vista. | |
| 135 EXPECT_EQ(!!result, Animation::ShouldRenderRichAnimation()); | |
| 136 } else { | |
| 137 // On XP, the function should check the SM_REMOTESESSION value. | |
| 138 EXPECT_EQ(!::GetSystemMetrics(SM_REMOTESESSION), | |
| 139 Animation::ShouldRenderRichAnimation()); | |
| 140 } | |
| 141 #else | |
| 142 EXPECT_TRUE(Animation::ShouldRenderRichAnimation()); | 124 EXPECT_TRUE(Animation::ShouldRenderRichAnimation()); |
| 143 #endif | |
| 144 } | 125 } |
| 145 | 126 |
| 146 // Test that current value is always 0 after Start() is called. | 127 // Test that current value is always 0 after Start() is called. |
| 147 TEST_F(AnimationTest, StartState) { | 128 TEST_F(AnimationTest, StartState) { |
| 148 LinearAnimation animation(100, 60, NULL); | 129 LinearAnimation animation(100, 60, NULL); |
| 149 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 130 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
| 150 animation.Start(); | 131 animation.Start(); |
| 151 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 132 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
| 152 animation.End(); | 133 animation.End(); |
| 153 EXPECT_EQ(1.0, animation.GetCurrentValue()); | 134 EXPECT_EQ(1.0, animation.GetCurrentValue()); |
| 154 animation.Start(); | 135 animation.Start(); |
| 155 EXPECT_EQ(0.0, animation.GetCurrentValue()); | 136 EXPECT_EQ(0.0, animation.GetCurrentValue()); |
| 156 } | 137 } |
| 157 | 138 |
| 158 } // namespace gfx | 139 } // namespace gfx |
| OLD | NEW |