| 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 "ui/wm/core/visibility_controller.h" | 5 #include "ui/wm/core/visibility_controller.h" |
| 6 | 6 |
| 7 #include "ui/aura/test/aura_test_base.h" | 7 #include "ui/aura/test/aura_test_base.h" |
| 8 #include "ui/aura/test/test_window_delegate.h" | 8 #include "ui/aura/test/test_window_delegate.h" |
| 9 #include "ui/aura/test/test_windows.h" | 9 #include "ui/aura/test/test_windows.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/aura/window_event_dispatcher.h" | 11 #include "ui/aura/window_event_dispatcher.h" |
| 12 #include "ui/compositor/layer.h" | 12 #include "ui/compositor/layer.h" |
| 13 #include "ui/compositor/layer_animator.h" | 13 #include "ui/compositor/layer_animator.h" |
| 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 15 #include "ui/compositor/scoped_layer_animation_settings.h" | 15 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 16 | 16 |
| 17 namespace wm { | 17 namespace wm { |
| 18 | 18 |
| 19 typedef aura::test::AuraTestBase VisibilityControllerTest; | 19 typedef aura::test::AuraTestBase VisibilityControllerTest; |
| 20 | 20 |
| 21 // Hiding a window in an animatable container should not hide the window's layer | |
| 22 // immediately. | |
| 23 TEST_F(VisibilityControllerTest, AnimateHideDoesntHideWindowLayer) { | |
| 24 // We cannot disable animations for this test. | |
| 25 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | |
| 26 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | |
| 27 | |
| 28 VisibilityController controller; | |
| 29 aura::client::SetVisibilityClient(root_window(), &controller); | |
| 30 | |
| 31 SetChildWindowVisibilityChangesAnimated(root_window()); | |
| 32 | |
| 33 aura::test::TestWindowDelegate d; | |
| 34 scoped_ptr<aura::Window> animatable(aura::test::CreateTestWindowWithDelegate( | |
| 35 &d, -2, gfx::Rect(0, 0, 50, 50), root_window())); | |
| 36 scoped_ptr<aura::Window> non_animatable( | |
| 37 aura::test::CreateTestWindowWithDelegateAndType( | |
| 38 &d, | |
| 39 ui::wm::WINDOW_TYPE_CONTROL, | |
| 40 -3, | |
| 41 gfx::Rect(51, 51, 50, 50), | |
| 42 root_window())); | |
| 43 EXPECT_TRUE(animatable->IsVisible()); | |
| 44 EXPECT_TRUE(animatable->layer()->visible()); | |
| 45 animatable->Hide(); | |
| 46 EXPECT_FALSE(animatable->IsVisible()); | |
| 47 EXPECT_TRUE(animatable->layer()->visible()); | |
| 48 | |
| 49 EXPECT_TRUE(non_animatable->IsVisible()); | |
| 50 EXPECT_TRUE(non_animatable->layer()->visible()); | |
| 51 non_animatable->Hide(); | |
| 52 EXPECT_FALSE(non_animatable->IsVisible()); | |
| 53 EXPECT_FALSE(non_animatable->layer()->visible()); | |
| 54 | |
| 55 aura::client::SetVisibilityClient(root_window(), NULL); | |
| 56 } | |
| 57 | |
| 58 // Check that a transparency change to 0 will not cause a hide call to be | 21 // Check that a transparency change to 0 will not cause a hide call to be |
| 59 // ignored. | 22 // ignored. |
| 60 TEST_F(VisibilityControllerTest, AnimateTransparencyToZeroAndHideHides) { | 23 TEST_F(VisibilityControllerTest, AnimateTransparencyToZeroAndHideHides) { |
| 61 // We cannot disable animations for this test. | 24 // We cannot disable animations for this test. |
| 62 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 25 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
| 63 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 26 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
| 64 | 27 |
| 65 VisibilityController controller; | 28 VisibilityController controller; |
| 66 aura::client::SetVisibilityClient(root_window(), &controller); | 29 aura::client::SetVisibilityClient(root_window(), &controller); |
| 67 | 30 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 84 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); | 47 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); |
| 85 | 48 |
| 86 // Check that the visibility is correct after the hide animation has finished. | 49 // Check that the visibility is correct after the hide animation has finished. |
| 87 window->Hide(); | 50 window->Hide(); |
| 88 window->layer()->GetAnimator()->StopAnimating(); | 51 window->layer()->GetAnimator()->StopAnimating(); |
| 89 EXPECT_FALSE(window->layer()->visible()); | 52 EXPECT_FALSE(window->layer()->visible()); |
| 90 EXPECT_FALSE(window->IsVisible()); | 53 EXPECT_FALSE(window->IsVisible()); |
| 91 } | 54 } |
| 92 | 55 |
| 93 } // namespace wm | 56 } // namespace wm |
| OLD | NEW |