| 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/desktop_background/desktop_background_controller.h" | 5 #include "ash/desktop_background/desktop_background_controller.h" |
| 6 | 6 |
| 7 #include "ash/desktop_background/desktop_background_widget_controller.h" | 7 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 12 #include "ui/compositor/test/layer_animator_test_controller.h" |
| 12 | 13 |
| 13 using aura::RootWindow; | 14 using aura::RootWindow; |
| 14 using aura::Window; | 15 using aura::Window; |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Containers IDs used for tests. | 19 // Containers IDs used for tests. |
| 19 const int kDesktopBackgroundId = | 20 const int kDesktopBackgroundId = |
| 20 ash::internal::kShellWindowId_DesktopBackgroundContainer; | 21 ash::internal::kShellWindowId_DesktopBackgroundContainer; |
| 21 const int kLockScreenBackgroundId = | 22 const int kLockScreenBackgroundId = |
| 22 ash::internal::kShellWindowId_LockScreenBackgroundContainer; | 23 ash::internal::kShellWindowId_LockScreenBackgroundContainer; |
| 23 | 24 |
| 24 // Returns number of child windows in a shell window container. | 25 // Returns number of child windows in a shell window container. |
| 25 int ChildCountForContainer(int container_id) { | 26 int ChildCountForContainer(int container_id) { |
| 26 RootWindow* root = ash::Shell::GetPrimaryRootWindow(); | 27 RootWindow* root = ash::Shell::GetPrimaryRootWindow(); |
| 27 Window* container = root->GetChildById(container_id); | 28 Window* container = root->GetChildById(container_id); |
| 28 return static_cast<int>(container->children().size()); | 29 return static_cast<int>(container->children().size()); |
| 29 } | 30 } |
| 30 | 31 |
| 31 // Steps a widget's layer animation until it is completed. Animations must be | 32 // Steps a widget's layer animation until it is completed. Animations must be |
| 32 // enabled. | 33 // enabled. |
| 33 void RunAnimationForWidget(views::Widget* widget) { | 34 void RunAnimationForWidget(views::Widget* widget) { |
| 34 // Animations must be enabled for stepping to work. | 35 // Animations must be enabled for stepping to work. |
| 35 DCHECK(!ui::LayerAnimator::disable_animations_for_test()); | 36 DCHECK(!ui::LayerAnimator::disable_animations_for_test()); |
| 36 | 37 |
| 37 ui::Layer* layer = widget->GetNativeView()->layer(); | 38 ui::Layer* layer = widget->GetNativeView()->layer(); |
| 38 ui::LayerAnimator* animator = layer->GetAnimator(); | 39 ui::LayerAnimatorTestController controller(layer->GetAnimator()); |
| 39 ui::AnimationContainerElement* element = layer->GetAnimator(); | 40 ui::AnimationContainerElement* element = layer->GetAnimator(); |
| 40 // Multiple steps are required to complete complex animations. | 41 // Multiple steps are required to complete complex animations. |
| 41 // TODO(vollick): This should not be necessary. crbug.com/154017 | 42 // TODO(vollick): This should not be necessary. crbug.com/154017 |
| 42 while (animator->is_animating()) { | 43 while (controller.animator()->is_animating()) { |
| 43 base::TimeTicks step_time = animator->last_step_time(); | 44 controller.StartThreadedAnimationsIfNeeded(); |
| 45 base::TimeTicks step_time = controller.animator()->last_step_time(); |
| 44 element->Step(step_time + base::TimeDelta::FromMilliseconds(1000)); | 46 element->Step(step_time + base::TimeDelta::FromMilliseconds(1000)); |
| 45 } | 47 } |
| 46 } | 48 } |
| 47 | 49 |
| 48 } // namespace | 50 } // namespace |
| 49 | 51 |
| 50 namespace ash { | 52 namespace ash { |
| 51 namespace internal { | 53 namespace internal { |
| 52 | 54 |
| 53 class DesktopBackgroundControllerTest : public test::AshTestBase { | 55 class DesktopBackgroundControllerTest : public test::AshTestBase { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 222 |
| 221 EXPECT_TRUE(root->GetProperty(kDesktopController)); | 223 EXPECT_TRUE(root->GetProperty(kDesktopController)); |
| 222 EXPECT_FALSE( | 224 EXPECT_FALSE( |
| 223 root->GetProperty(kAnimatingDesktopController)->GetController(false)); | 225 root->GetProperty(kAnimatingDesktopController)->GetController(false)); |
| 224 // The desktop controller should be the last created animating controller. | 226 // The desktop controller should be the last created animating controller. |
| 225 EXPECT_EQ(animatingController, root->GetProperty(kDesktopController)); | 227 EXPECT_EQ(animatingController, root->GetProperty(kDesktopController)); |
| 226 } | 228 } |
| 227 | 229 |
| 228 } // namespace internal | 230 } // namespace internal |
| 229 } // namespace ash | 231 } // namespace ash |
| OLD | NEW |