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 "ui/aura_shell/shadow_controller.h" | 5 #include "ui/aura_shell/shadow_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "ui/aura/client/aura_constants.h" | |
12 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
13 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
14 #include "ui/aura_shell/shadow.h" | 13 #include "ui/aura_shell/shadow.h" |
15 #include "ui/aura_shell/shadow_types.h" | 14 #include "ui/aura_shell/shadow_types.h" |
16 #include "ui/aura_shell/shell.h" | 15 #include "ui/aura_shell/shell.h" |
17 #include "ui/aura_shell/test/aura_shell_test_base.h" | 16 #include "ui/aura_shell/test/aura_shell_test_base.h" |
18 #include "ui/aura_shell/window_properties.h" | 17 #include "ui/aura_shell/window_properties.h" |
19 #include "ui/gfx/compositor/layer.h" | 18 #include "ui/gfx/compositor/layer.h" |
20 | 19 |
21 namespace aura_shell { | 20 namespace aura_shell { |
22 namespace test { | 21 namespace test { |
23 | 22 |
24 typedef aura_shell::test::AuraShellTestBase ShadowControllerTest; | 23 typedef aura_shell::test::AuraShellTestBase ShadowControllerTest; |
25 | 24 |
26 // 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. |
27 TEST_F(ShadowControllerTest, Shadow) { | 26 TEST_F(ShadowControllerTest, Shadow) { |
28 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 27 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
29 window->SetType(aura::WINDOW_TYPE_NORMAL); | 28 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
30 window->Init(ui::Layer::LAYER_HAS_TEXTURE); | 29 window->Init(ui::Layer::LAYER_HAS_TEXTURE); |
31 window->SetParent(NULL); | 30 window->SetParent(NULL); |
32 | 31 |
33 // 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 |
34 // 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). |
35 internal::ShadowController::TestApi api( | 34 internal::ShadowController::TestApi api( |
36 aura_shell::Shell::GetInstance()->shadow_controller()); | 35 aura_shell::Shell::GetInstance()->shadow_controller()); |
37 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); | 36 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); |
38 ASSERT_TRUE(shadow != NULL); | 37 ASSERT_TRUE(shadow != NULL); |
39 EXPECT_TRUE(shadow->layer()->visible()); | 38 EXPECT_TRUE(shadow->layer()->visible()); |
(...skipping 16 matching lines...) Expand all Loading... |
56 | 55 |
57 window->parent()->RemoveChild(window.get()); | 56 window->parent()->RemoveChild(window.get()); |
58 aura::Window* window_ptr = window.get(); | 57 aura::Window* window_ptr = window.get(); |
59 window.reset(); | 58 window.reset(); |
60 EXPECT_TRUE(api.GetShadowForWindow(window_ptr) == NULL); | 59 EXPECT_TRUE(api.GetShadowForWindow(window_ptr) == NULL); |
61 } | 60 } |
62 | 61 |
63 // Tests that the window's shadow's bounds are updated correctly. | 62 // Tests that the window's shadow's bounds are updated correctly. |
64 TEST_F(ShadowControllerTest, ShadowBounds) { | 63 TEST_F(ShadowControllerTest, ShadowBounds) { |
65 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 64 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
66 window->SetType(aura::WINDOW_TYPE_NORMAL); | 65 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
67 window->Init(ui::Layer::LAYER_HAS_TEXTURE); | 66 window->Init(ui::Layer::LAYER_HAS_TEXTURE); |
68 window->SetParent(NULL); | 67 window->SetParent(NULL); |
69 window->Show(); | 68 window->Show(); |
70 | 69 |
71 const gfx::Rect kOldBounds(20, 30, 400, 300); | 70 const gfx::Rect kOldBounds(20, 30, 400, 300); |
72 window->SetBounds(kOldBounds); | 71 window->SetBounds(kOldBounds); |
73 | 72 |
74 // 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 |
75 // 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). |
76 internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR); | 75 internal::SetShadowType(window.get(), internal::SHADOW_TYPE_RECTANGULAR); |
77 internal::ShadowController::TestApi api( | 76 internal::ShadowController::TestApi api( |
78 aura_shell::Shell::GetInstance()->shadow_controller()); | 77 aura_shell::Shell::GetInstance()->shadow_controller()); |
79 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); | 78 const internal::Shadow* shadow = api.GetShadowForWindow(window.get()); |
80 ASSERT_TRUE(shadow != NULL); | 79 ASSERT_TRUE(shadow != NULL); |
81 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(), | 80 EXPECT_EQ(gfx::Rect(kOldBounds.size()).ToString(), |
82 shadow->content_bounds().ToString()); | 81 shadow->content_bounds().ToString()); |
83 | 82 |
84 // 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. |
85 gfx::Rect kNewBounds(50, 60, 500, 400); | 84 gfx::Rect kNewBounds(50, 60, 500, 400); |
86 window->SetBounds(kNewBounds); | 85 window->SetBounds(kNewBounds); |
87 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(), | 86 EXPECT_EQ(gfx::Rect(kNewBounds.size()).ToString(), |
88 shadow->content_bounds().ToString()); | 87 shadow->content_bounds().ToString()); |
89 } | 88 } |
90 | 89 |
91 } // namespace test | 90 } // namespace test |
92 } // namespace aura_shell | 91 } // namespace aura_shell |
OLD | NEW |