| 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" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // We cannot disable animations for this test. | 25 // We cannot disable animations for this test. |
| 26 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 26 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 27 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 27 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 28 | 28 |
| 29 VisibilityController controller; | 29 VisibilityController controller; |
| 30 aura::client::SetVisibilityClient(root_window(), &controller); | 30 aura::client::SetVisibilityClient(root_window(), &controller); |
| 31 | 31 |
| 32 SetChildWindowVisibilityChangesAnimated(root_window()); | 32 SetChildWindowVisibilityChangesAnimated(root_window()); |
| 33 | 33 |
| 34 aura::test::TestWindowDelegate d; | 34 aura::test::TestWindowDelegate d; |
| 35 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 35 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
| 36 &d, -2, gfx::Rect(0, 0, 50, 50), root_window())); | 36 &d, -2, gfx::Rect(0, 0, 50, 50), root_window())); |
| 37 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 37 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 38 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(5)); | 38 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(5)); |
| 39 | 39 |
| 40 EXPECT_TRUE(window->layer()->visible()); | 40 EXPECT_TRUE(window->layer()->visible()); |
| 41 EXPECT_TRUE(window->IsVisible()); | 41 EXPECT_TRUE(window->IsVisible()); |
| 42 | 42 |
| 43 window->layer()->SetOpacity(0.0); | 43 window->layer()->SetOpacity(0.0); |
| 44 EXPECT_TRUE(window->layer()->visible()); | 44 EXPECT_TRUE(window->layer()->visible()); |
| 45 EXPECT_TRUE(window->IsVisible()); | 45 EXPECT_TRUE(window->IsVisible()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 58 // window. | 58 // window. |
| 59 TEST_F(VisibilityControllerTest, SetWindowVisibilityChagnesAnimated) { | 59 TEST_F(VisibilityControllerTest, SetWindowVisibilityChagnesAnimated) { |
| 60 // We cannot disable animations for this test. | 60 // We cannot disable animations for this test. |
| 61 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 61 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 62 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 62 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 63 | 63 |
| 64 VisibilityController controller; | 64 VisibilityController controller; |
| 65 aura::client::SetVisibilityClient(root_window(), &controller); | 65 aura::client::SetVisibilityClient(root_window(), &controller); |
| 66 | 66 |
| 67 aura::test::TestWindowDelegate d; | 67 aura::test::TestWindowDelegate d; |
| 68 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 68 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
| 69 &d, -2, gfx::Rect(0, 0, 50, 50), root_window())); | 69 &d, -2, gfx::Rect(0, 0, 50, 50), root_window())); |
| 70 // Test using Show animation because Hide animation detaches the window's | 70 // Test using Show animation because Hide animation detaches the window's |
| 71 // layer. | 71 // layer. |
| 72 window->Hide(); | 72 window->Hide(); |
| 73 ASSERT_FALSE(window->IsVisible()); | 73 ASSERT_FALSE(window->IsVisible()); |
| 74 | 74 |
| 75 SetWindowVisibilityChangesAnimated(window.get()); | 75 SetWindowVisibilityChangesAnimated(window.get()); |
| 76 SetWindowVisibilityAnimationDuration(window.get(), | 76 SetWindowVisibilityAnimationDuration(window.get(), |
| 77 base::TimeDelta::FromMilliseconds(5)); | 77 base::TimeDelta::FromMilliseconds(5)); |
| 78 SetWindowVisibilityAnimationType(window.get(), | 78 SetWindowVisibilityAnimationType(window.get(), |
| 79 WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 79 WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
| 80 window->Show(); | 80 window->Show(); |
| 81 EXPECT_TRUE(window->layer()->GetAnimator()->is_animating()); | 81 EXPECT_TRUE(window->layer()->GetAnimator()->is_animating()); |
| 82 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); | 82 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); |
| 83 EXPECT_EQ(0.0f, window->layer()->opacity()); | 83 EXPECT_EQ(0.0f, window->layer()->opacity()); |
| 84 | 84 |
| 85 window->layer()->GetAnimator()->StopAnimating(); | 85 window->layer()->GetAnimator()->StopAnimating(); |
| 86 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); | 86 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); |
| 87 EXPECT_EQ(1.0f, window->layer()->opacity()); | 87 EXPECT_EQ(1.0f, window->layer()->opacity()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace wm | 90 } // namespace wm |
| OLD | NEW |