| 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 "ash/wm/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
| 6 | 6 |
| 7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
| 10 #include "ash/wm/workspace_controller.h" | 10 #include "ash/wm/workspace_controller.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // New layer animates in to the identity transform. | 160 // New layer animates in to the identity transform. |
| 161 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); | 161 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); |
| 162 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); | 162 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); |
| 163 | 163 |
| 164 static_cast<gfx::AnimationContainerElement*>(old_layer->GetAnimator())->Step( | 164 static_cast<gfx::AnimationContainerElement*>(old_layer->GetAnimator())->Step( |
| 165 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); | 165 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
| 166 static_cast<gfx::AnimationContainerElement*>(window->layer()->GetAnimator())-> | 166 static_cast<gfx::AnimationContainerElement*>(window->layer()->GetAnimator())-> |
| 167 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); | 167 Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 TEST_F(WindowAnimationsTest, LockAnimationDuration) { | |
| 171 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | |
| 172 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | |
| 173 | |
| 174 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); | |
| 175 Layer* layer = window->layer(); | |
| 176 window->SetBounds(gfx::Rect(5, 10, 320, 240)); | |
| 177 window->Show(); | |
| 178 | |
| 179 // Test that it is possible to override transition duration when it is not | |
| 180 // locked. | |
| 181 { | |
| 182 ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator()); | |
| 183 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); | |
| 184 { | |
| 185 ui::ScopedLayerAnimationSettings settings2(layer->GetAnimator()); | |
| 186 // Duration is not locked so it gets overridden. | |
| 187 settings2.SetTransitionDuration(base::TimeDelta::FromMilliseconds(50)); | |
| 188 wm::GetWindowState(window.get())->Minimize(); | |
| 189 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | |
| 190 // Expect duration from the inner scope | |
| 191 EXPECT_EQ(50, | |
| 192 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | |
| 193 } | |
| 194 window->Show(); | |
| 195 layer->GetAnimator()->StopAnimating(); | |
| 196 } | |
| 197 | |
| 198 // Test that it is possible to lock transition duration | |
| 199 { | |
| 200 ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator()); | |
| 201 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); | |
| 202 // Duration is locked in outer scope. | |
| 203 settings1.LockTransitionDuration(); | |
| 204 { | |
| 205 ui::ScopedLayerAnimationSettings settings2(layer->GetAnimator()); | |
| 206 // Transition duration setting is ignored. | |
| 207 settings2.SetTransitionDuration(base::TimeDelta::FromMilliseconds(50)); | |
| 208 wm::GetWindowState(window.get())->Minimize(); | |
| 209 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | |
| 210 // Expect duration from the outer scope | |
| 211 EXPECT_EQ(1000, | |
| 212 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | |
| 213 } | |
| 214 window->Show(); | |
| 215 layer->GetAnimator()->StopAnimating(); | |
| 216 } | |
| 217 | |
| 218 // Test that duration respects default. | |
| 219 { | |
| 220 // Query default duration. | |
| 221 MinimizeAnimationObserver observer(layer->GetAnimator()); | |
| 222 wm::GetWindowState(window.get())->Minimize(); | |
| 223 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | |
| 224 base::TimeDelta default_duration(observer.duration()); | |
| 225 window->Show(); | |
| 226 layer->GetAnimator()->StopAnimating(); | |
| 227 | |
| 228 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | |
| 229 settings.LockTransitionDuration(); | |
| 230 // Setting transition duration is ignored since duration is locked | |
| 231 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); | |
| 232 wm::GetWindowState(window.get())->Minimize(); | |
| 233 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | |
| 234 // Expect default duration (200ms for stock ash minimizing animation). | |
| 235 EXPECT_EQ(default_duration.InMilliseconds(), | |
| 236 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | |
| 237 window->Show(); | |
| 238 layer->GetAnimator()->StopAnimating(); | |
| 239 } | |
| 240 } | |
| 241 | |
| 242 } // namespace internal | 170 } // namespace internal |
| 243 } // namespace ash | 171 } // namespace ash |
| OLD | NEW |