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/shadow_controller.h" | 5 #include "ui/wm/core/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/window_tree_client.h" | 11 #include "ui/aura/client/window_tree_client.h" |
12 #include "ui/aura/test/aura_test_base.h" | 12 #include "ui/aura/test/aura_test_base.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
15 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
16 #include "ui/wm/core/shadow.h" | 16 #include "ui/wm/core/shadow.h" |
17 #include "ui/wm/core/shadow_types.h" | 17 #include "ui/wm/core/shadow_types.h" |
18 #include "ui/wm/core/window_util.h" | 18 #include "ui/wm/core/window_util.h" |
19 #include "ui/wm/core/wm_state.h" | 19 #include "ui/wm/core/wm_state.h" |
20 #include "ui/wm/public/activation_client.h" | 20 #include "ui/wm/public/activation_client.h" |
| 21 #include "ui/wm/test/wm_test_base.h" |
21 | 22 |
22 namespace wm { | 23 namespace wm { |
23 | 24 |
24 class ShadowControllerTest : public aura::test::AuraTestBase { | 25 class ShadowControllerTest : public WMTestBase { |
25 public: | 26 public: |
26 ShadowControllerTest() {} | 27 ShadowControllerTest() {} |
27 virtual ~ShadowControllerTest() {} | 28 virtual ~ShadowControllerTest() {} |
28 | 29 |
29 virtual void SetUp() OVERRIDE { | 30 virtual void SetUp() OVERRIDE { |
30 wm_state_.reset(new wm::WMState); | 31 wm_state_.reset(new WMState); |
31 AuraTestBase::SetUp(); | 32 AuraTestBase::SetUp(); |
32 aura::client::ActivationClient* activation_client = | 33 aura::client::ActivationClient* activation_client = |
33 aura::client::GetActivationClient(root_window()); | 34 aura::client::GetActivationClient(root_window()); |
34 shadow_controller_.reset(new ShadowController(activation_client)); | 35 shadow_controller_.reset(new ShadowController(activation_client)); |
35 } | 36 } |
36 virtual void TearDown() OVERRIDE { | 37 virtual void TearDown() OVERRIDE { |
37 shadow_controller_.reset(); | 38 shadow_controller_.reset(); |
38 AuraTestBase::TearDown(); | 39 AuraTestBase::TearDown(); |
39 wm_state_.reset(); | 40 wm_state_.reset(); |
40 } | 41 } |
41 | 42 |
42 protected: | 43 protected: |
43 ShadowController* shadow_controller() { return shadow_controller_.get(); } | 44 ShadowController* shadow_controller() { return shadow_controller_.get(); } |
44 | 45 |
45 void ActivateWindow(aura::Window* window) { | 46 void ActivateWindow(aura::Window* window) { |
46 DCHECK(window); | 47 DCHECK(window); |
47 DCHECK(window->GetRootWindow()); | 48 DCHECK(window->GetRootWindow()); |
48 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( | 49 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( |
49 window); | 50 window); |
50 } | 51 } |
51 | 52 |
52 private: | 53 private: |
53 scoped_ptr<ShadowController> shadow_controller_; | 54 scoped_ptr<ShadowController> shadow_controller_; |
54 scoped_ptr<wm::WMState> wm_state_; | 55 scoped_ptr<WMState> wm_state_; |
55 | 56 |
56 DISALLOW_COPY_AND_ASSIGN(ShadowControllerTest); | 57 DISALLOW_COPY_AND_ASSIGN(ShadowControllerTest); |
57 }; | 58 }; |
58 | 59 |
59 // Tests that various methods in Window update the Shadow object as expected. | 60 // Tests that various methods in Window update the Shadow object as expected. |
60 TEST_F(ShadowControllerTest, Shadow) { | 61 TEST_F(ShadowControllerTest, Shadow) { |
61 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 62 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
62 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 63 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
63 window->Init(aura::WINDOW_LAYER_TEXTURED); | 64 window->Init(aura::WINDOW_LAYER_TEXTURED); |
64 ParentWindow(window.get()); | 65 ParentWindow(window.get()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 AddTransientChild(window1.get(), window2.get()); | 209 AddTransientChild(window1.get(), window2.get()); |
209 aura::client::SetHideOnDeactivate(window2.get(), true); | 210 aura::client::SetHideOnDeactivate(window2.get(), true); |
210 window2->Show(); | 211 window2->Show(); |
211 ActivateWindow(window2.get()); | 212 ActivateWindow(window2.get()); |
212 | 213 |
213 // window1 is now inactive, but its shadow should still appear active. | 214 // window1 is now inactive, but its shadow should still appear active. |
214 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style()); | 215 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style()); |
215 } | 216 } |
216 | 217 |
217 } // namespace wm | 218 } // namespace wm |
OLD | NEW |