| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/shadow_controller.h" | 5 #include "ash/wm/shadow_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/aura_shell_test_base.h" | 11 #include "ash/test/aura_shell_test_base.h" |
| 12 #include "ash/wm/shadow.h" | 12 #include "ash/wm/shadow.h" |
| 13 #include "ash/wm/shadow_types.h" | 13 #include "ash/wm/shadow_types.h" |
| 14 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/gfx/compositor/layer.h" | 18 #include "ui/gfx/compositor/layer.h" |
| 19 | 19 |
| 20 namespace aura_shell { | 20 namespace ash { |
| 21 namespace test { | 21 namespace test { |
| 22 | 22 |
| 23 typedef aura_shell::test::AuraShellTestBase ShadowControllerTest; | 23 typedef ash::test::AuraShellTestBase ShadowControllerTest; |
| 24 | 24 |
| 25 // Tests that various methods in Window update the Shadow object as expected. | 25 // Tests that various methods in Window update the Shadow object as expected. |
| 26 TEST_F(ShadowControllerTest, Shadow) { | 26 TEST_F(ShadowControllerTest, Shadow) { |
| 27 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 27 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
| 28 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 28 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
| 29 window->Init(ui::Layer::LAYER_HAS_TEXTURE); | 29 window->Init(ui::Layer::LAYER_HAS_TEXTURE); |
| 30 window->SetParent(NULL); | 30 window->SetParent(NULL); |
| 31 | 31 |
| 32 // We should create the shadow before the window is visible (the shadow's | 32 // We should create the shadow before the window is visible (the shadow's |
| 33 // layer won't get drawn yet since it's a child of the window's layer). | 33 // layer won't get drawn yet since it's a child of the window's layer). |
| 34 internal::ShadowController::TestApi api( | 34 internal::ShadowController::TestApi api( |
| 35 aura_shell::Shell::GetInstance()->shadow_controller()); | 35 ash::Shell::GetInstance()->shadow_controller()); |
| 36 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); | 36 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); |
| 37 ASSERT_TRUE(shadow != NULL); | 37 ASSERT_TRUE(shadow != NULL); |
| 38 EXPECT_TRUE(shadow->layer()->visible()); | 38 EXPECT_TRUE(shadow->layer()->visible()); |
| 39 | 39 |
| 40 // The shadow should remain visible after window visibility changes. | 40 // The shadow should remain visible after window visibility changes. |
| 41 window->Show(); | 41 window->Show(); |
| 42 EXPECT_TRUE(shadow->layer()->visible()); | 42 EXPECT_TRUE(shadow->layer()->visible()); |
| 43 window->Hide(); | 43 window->Hide(); |
| 44 EXPECT_TRUE(shadow->layer()->visible()); | 44 EXPECT_TRUE(shadow->layer()->visible()); |
| 45 | 45 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 67 window->SetParent(NULL); | 67 window->SetParent(NULL); |
| 68 window->Show(); | 68 window->Show(); |
| 69 | 69 |
| 70 const gfx::Rect kOldBounds(20, 30, 400, 300); | 70 const gfx::Rect kOldBounds(20, 30, 400, 300); |
| 71 window->SetBounds(kOldBounds); | 71 window->SetBounds(kOldBounds); |
| 72 | 72 |
| 73 // When the shadow is first created, it should use the window's size (but | 73 // When the shadow is first created, it should use the window's size (but |
| 74 // remain at the origin, since it's a child of the window's layer). | 74 // remain at the origin, since it's a child of the window's layer). |
| 75 internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR); | 75 internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR); |
| 76 internal::ShadowController::TestApi api( | 76 internal::ShadowController::TestApi api( |
| 77 aura_shell::Shell::GetInstance()->shadow_controller()); | 77 ash::Shell::GetInstance()->shadow_controller()); |
| 78 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); | 78 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); |
| 79 ASSERT_TRUE(shadow != NULL); | 79 ASSERT_TRUE(shadow != NULL); |
| 80 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(), | 80 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(), |
| 81 shadow->content_bounds().ToString()); | 81 shadow->content_bounds().ToString()); |
| 82 | 82 |
| 83 // When we change the window's bounds, the shadow's should be updated too. | 83 // When we change the window's bounds, the shadow's should be updated too. |
| 84 gfx::Rect kNewBounds(50, 60, 500, 400); | 84 gfx::Rect kNewBounds(50, 60, 500, 400); |
| 85 window->SetBounds(kNewBounds); | 85 window->SetBounds(kNewBounds); |
| 86 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(), | 86 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(), |
| 87 shadow->content_bounds().ToString()); | 87 shadow->content_bounds().ToString()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace test | 90 } // namespace test |
| 91 } // namespace aura_shell | 91 } // namespace ash |
| OLD | NEW |