| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // Expect duration from the inner scope | 194 // Expect duration from the inner scope |
| 195 EXPECT_EQ(50, | 195 EXPECT_EQ(50, |
| 196 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | 196 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); |
| 197 } | 197 } |
| 198 window->Show(); | 198 window->Show(); |
| 199 layer->GetAnimator()->StopAnimating(); | 199 layer->GetAnimator()->StopAnimating(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Test that it is possible to lock transition duration | 202 // Test that it is possible to lock transition duration |
| 203 { | 203 { |
| 204 // Update layer as minimizing will replace the window's layer. |
| 205 layer = window->layer(); |
| 204 ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator()); | 206 ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator()); |
| 205 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); | 207 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); |
| 206 // Duration is locked in outer scope. | 208 // Duration is locked in outer scope. |
| 207 settings1.LockTransitionDuration(); | 209 settings1.LockTransitionDuration(); |
| 208 { | 210 { |
| 209 ui::ScopedLayerAnimationSettings settings2(layer->GetAnimator()); | 211 ui::ScopedLayerAnimationSettings settings2(layer->GetAnimator()); |
| 210 // Transition duration setting is ignored. | 212 // Transition duration setting is ignored. |
| 211 settings2.SetTransitionDuration(base::TimeDelta::FromMilliseconds(50)); | 213 settings2.SetTransitionDuration(base::TimeDelta::FromMilliseconds(50)); |
| 212 wm::GetWindowState(window.get())->Minimize(); | 214 wm::GetWindowState(window.get())->Minimize(); |
| 213 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | 215 EXPECT_TRUE(layer->GetAnimator()->is_animating()); |
| 214 // Expect duration from the outer scope | 216 // Expect duration from the outer scope |
| 215 EXPECT_EQ(1000, | 217 EXPECT_EQ(1000, |
| 216 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | 218 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); |
| 217 } | 219 } |
| 218 window->Show(); | 220 window->Show(); |
| 219 layer->GetAnimator()->StopAnimating(); | 221 layer->GetAnimator()->StopAnimating(); |
| 220 } | 222 } |
| 221 | 223 |
| 222 // Test that duration respects default. | 224 // Test that duration respects default. |
| 223 { | 225 { |
| 226 layer = window->layer(); |
| 224 // Query default duration. | 227 // Query default duration. |
| 225 MinimizeAnimationObserver observer(layer->GetAnimator()); | 228 MinimizeAnimationObserver observer(layer->GetAnimator()); |
| 226 wm::GetWindowState(window.get())->Minimize(); | 229 wm::GetWindowState(window.get())->Minimize(); |
| 227 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | 230 EXPECT_TRUE(layer->GetAnimator()->is_animating()); |
| 228 base::TimeDelta default_duration(observer.duration()); | 231 base::TimeDelta default_duration(observer.duration()); |
| 229 window->Show(); | 232 window->Show(); |
| 230 layer->GetAnimator()->StopAnimating(); | 233 layer->GetAnimator()->StopAnimating(); |
| 231 | 234 |
| 235 layer = window->layer(); |
| 232 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 236 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 233 settings.LockTransitionDuration(); | 237 settings.LockTransitionDuration(); |
| 234 // Setting transition duration is ignored since duration is locked | 238 // Setting transition duration is ignored since duration is locked |
| 235 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); | 239 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); |
| 236 wm::GetWindowState(window.get())->Minimize(); | 240 wm::GetWindowState(window.get())->Minimize(); |
| 237 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | 241 EXPECT_TRUE(layer->GetAnimator()->is_animating()); |
| 238 // Expect default duration (200ms for stock ash minimizing animation). | 242 // Expect default duration (200ms for stock ash minimizing animation). |
| 239 EXPECT_EQ(default_duration.InMilliseconds(), | 243 EXPECT_EQ(default_duration.InMilliseconds(), |
| 240 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | 244 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); |
| 241 window->Show(); | 245 window->Show(); |
| 242 layer->GetAnimator()->StopAnimating(); | 246 layer->GetAnimator()->StopAnimating(); |
| 243 } | 247 } |
| 244 } | 248 } |
| 245 | 249 |
| 246 } // namespace ash | 250 } // namespace ash |
| OLD | NEW |