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 3 // found in the LICENSE file. 4 5 #include "ui/views/corewm/visibility_controller.h" 6 7 #include "ui/aura/root_window.h" 8 #include "ui/aura/test/aura_test_base.h" 9 #include "ui/aura/test/test_window_delegate.h" 10 #include "ui/aura/test/test_windows.h" 11 #include "ui/aura/window.h" 12 #include "ui/compositor/layer.h" 13 #include "ui/compositor/layer_animator.h" 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 15 16 namespace views { 17 namespace corewm { 18 19 typedef aura::test::AuraTestBase VisibilityControllerTest; 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( 35 aura::test::CreateTestWindowWithDelegate( 36 &d, -2, gfx::Rect(0, 0, 50, 50), root_window())); 37 scoped_ptr<aura::Window> non_animatable( 38 aura::test::CreateTestWindowWithDelegateAndType( 39 &d, aura::client::WINDOW_TYPE_CONTROL, -3, gfx::Rect(51, 51, 50, 50), 40 root_window())); 41 EXPECT_TRUE(animatable->IsVisible()); 42 EXPECT_TRUE(animatable->layer()->visible()); 43 animatable->Hide(); 44 EXPECT_FALSE(animatable->IsVisible()); 45 EXPECT_TRUE(animatable->layer()->visible()); 46 47 EXPECT_TRUE(non_animatable->IsVisible()); 48 EXPECT_TRUE(non_animatable->layer()->visible()); 49 non_animatable->Hide(); 50 EXPECT_FALSE(non_animatable->IsVisible()); 51 EXPECT_FALSE(non_animatable->layer()->visible()); 52 53 aura::client::SetVisibilityClient(root_window(), NULL); 54 } 55 56 } // namespace corewm 57 } // namespace views 58