| 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/common/window_animation_types.h" |
| 9 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| 10 #include "ash/wm/window_state_aura.h" | 11 #include "ash/wm/window_state_aura.h" |
| 11 #include "ash/wm/workspace_controller.h" | 12 #include "ash/wm/workspace_controller.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 #include "ui/aura/test/test_windows.h" | 14 #include "ui/aura/test/test_windows.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
| 16 #include "ui/compositor/layer_animation_observer.h" | 17 #include "ui/compositor/layer_animation_observer.h" |
| 17 #include "ui/compositor/layer_animator.h" | 18 #include "ui/compositor/layer_animator.h" |
| 18 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 19 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { | 65 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { |
| 65 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 66 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 66 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 67 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 67 | 68 |
| 68 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 69 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 69 window->Show(); | 70 window->Show(); |
| 70 EXPECT_TRUE(window->layer()->visible()); | 71 EXPECT_TRUE(window->layer()->visible()); |
| 71 | 72 |
| 72 // Hiding. | 73 // Hiding. |
| 73 ::wm::SetWindowVisibilityAnimationType( | 74 ::wm::SetWindowVisibilityAnimationType( |
| 74 window.get(), | 75 window.get(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); |
| 75 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); | |
| 76 AnimateOnChildWindowVisibilityChanged(window.get(), false); | 76 AnimateOnChildWindowVisibilityChanged(window.get(), false); |
| 77 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); | 77 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); |
| 78 EXPECT_FALSE(window->layer()->GetTargetVisibility()); | 78 EXPECT_FALSE(window->layer()->GetTargetVisibility()); |
| 79 EXPECT_FALSE(window->layer()->visible()); | 79 EXPECT_FALSE(window->layer()->visible()); |
| 80 | 80 |
| 81 // Showing. | 81 // Showing. |
| 82 ::wm::SetWindowVisibilityAnimationType( | 82 ::wm::SetWindowVisibilityAnimationType( |
| 83 window.get(), | 83 window.get(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); |
| 84 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); | |
| 85 AnimateOnChildWindowVisibilityChanged(window.get(), true); | 84 AnimateOnChildWindowVisibilityChanged(window.get(), true); |
| 86 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); | 85 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); |
| 87 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); | 86 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); |
| 88 EXPECT_TRUE(window->layer()->visible()); | 87 EXPECT_TRUE(window->layer()->visible()); |
| 89 | 88 |
| 90 // Stays shown. | 89 // Stays shown. |
| 91 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + | 90 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + |
| 92 base::TimeDelta::FromSeconds(5)); | 91 base::TimeDelta::FromSeconds(5)); |
| 93 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); | 92 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); |
| 94 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); | 93 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | 276 EXPECT_TRUE(layer->GetAnimator()->is_animating()); |
| 278 // Expect default duration (200ms for stock ash minimizing animation). | 277 // Expect default duration (200ms for stock ash minimizing animation). |
| 279 EXPECT_EQ(default_duration.InMilliseconds(), | 278 EXPECT_EQ(default_duration.InMilliseconds(), |
| 280 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | 279 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); |
| 281 window->Show(); | 280 window->Show(); |
| 282 layer->GetAnimator()->StopAnimating(); | 281 layer->GetAnimator()->StopAnimating(); |
| 283 } | 282 } |
| 284 } | 283 } |
| 285 | 284 |
| 286 } // namespace ash | 285 } // namespace ash |
| OLD | NEW |