| 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 <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
| 13 #include "ui/aura/client/window_parenting_client.h" | 13 #include "ui/aura/client/window_parenting_client.h" |
| 14 #include "ui/aura/test/aura_test_base.h" | 14 #include "ui/aura/test/aura_test_base.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
| 18 #include "ui/wm/core/default_activation_client.h" | 18 #include "ui/wm/core/default_activation_client.h" |
| 19 #include "ui/wm/core/shadow.h" | 19 #include "ui/wm/core/shadow.h" |
| 20 #include "ui/wm/core/shadow_types.h" | 20 #include "ui/wm/core/shadow_types.h" |
| 21 #include "ui/wm/core/window_util.h" | 21 #include "ui/wm/core/window_util.h" |
| 22 #include "ui/wm/core/wm_state.h" | |
| 23 #include "ui/wm/public/activation_client.h" | 22 #include "ui/wm/public/activation_client.h" |
| 24 | 23 |
| 25 namespace wm { | 24 namespace wm { |
| 26 | 25 |
| 27 class ShadowControllerTest : public aura::test::AuraTestBase { | 26 class ShadowControllerTest : public aura::test::AuraTestBase { |
| 28 public: | 27 public: |
| 29 ShadowControllerTest() {} | 28 ShadowControllerTest() {} |
| 30 ~ShadowControllerTest() override {} | 29 ~ShadowControllerTest() override {} |
| 31 | 30 |
| 32 void SetUp() override { | 31 void SetUp() override { |
| 33 wm_state_.reset(new wm::WMState); | |
| 34 AuraTestBase::SetUp(); | 32 AuraTestBase::SetUp(); |
| 35 new wm::DefaultActivationClient(root_window()); | 33 new wm::DefaultActivationClient(root_window()); |
| 36 aura::client::ActivationClient* activation_client = | 34 aura::client::ActivationClient* activation_client = |
| 37 aura::client::GetActivationClient(root_window()); | 35 aura::client::GetActivationClient(root_window()); |
| 38 shadow_controller_.reset(new ShadowController(activation_client)); | 36 shadow_controller_.reset(new ShadowController(activation_client)); |
| 39 } | 37 } |
| 40 void TearDown() override { | 38 void TearDown() override { |
| 41 shadow_controller_.reset(); | 39 shadow_controller_.reset(); |
| 42 AuraTestBase::TearDown(); | 40 AuraTestBase::TearDown(); |
| 43 wm_state_.reset(); | |
| 44 } | 41 } |
| 45 | 42 |
| 46 protected: | 43 protected: |
| 47 ShadowController* shadow_controller() { return shadow_controller_.get(); } | 44 ShadowController* shadow_controller() { return shadow_controller_.get(); } |
| 48 | 45 |
| 49 void ActivateWindow(aura::Window* window) { | 46 void ActivateWindow(aura::Window* window) { |
| 50 DCHECK(window); | 47 DCHECK(window); |
| 51 DCHECK(window->GetRootWindow()); | 48 DCHECK(window->GetRootWindow()); |
| 52 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( | 49 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( |
| 53 window); | 50 window); |
| 54 } | 51 } |
| 55 | 52 |
| 56 private: | 53 private: |
| 57 std::unique_ptr<ShadowController> shadow_controller_; | 54 std::unique_ptr<ShadowController> shadow_controller_; |
| 58 std::unique_ptr<wm::WMState> wm_state_; | |
| 59 | 55 |
| 60 DISALLOW_COPY_AND_ASSIGN(ShadowControllerTest); | 56 DISALLOW_COPY_AND_ASSIGN(ShadowControllerTest); |
| 61 }; | 57 }; |
| 62 | 58 |
| 63 // Tests that various methods in Window update the Shadow object as expected. | 59 // Tests that various methods in Window update the Shadow object as expected. |
| 64 TEST_F(ShadowControllerTest, Shadow) { | 60 TEST_F(ShadowControllerTest, Shadow) { |
| 65 std::unique_ptr<aura::Window> window(new aura::Window(NULL)); | 61 std::unique_ptr<aura::Window> window(new aura::Window(NULL)); |
| 66 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 62 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 67 window->Init(ui::LAYER_TEXTURED); | 63 window->Init(ui::LAYER_TEXTURED); |
| 68 ParentWindow(window.get()); | 64 ParentWindow(window.get()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 AddTransientChild(window1.get(), window2.get()); | 219 AddTransientChild(window1.get(), window2.get()); |
| 224 aura::client::SetHideOnDeactivate(window2.get(), true); | 220 aura::client::SetHideOnDeactivate(window2.get(), true); |
| 225 window2->Show(); | 221 window2->Show(); |
| 226 ActivateWindow(window2.get()); | 222 ActivateWindow(window2.get()); |
| 227 | 223 |
| 228 // window1 is now inactive, but its shadow should still appear active. | 224 // window1 is now inactive, but its shadow should still appear active. |
| 229 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style()); | 225 EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow1->style()); |
| 230 } | 226 } |
| 231 | 227 |
| 232 } // namespace wm | 228 } // namespace wm |
| OLD | NEW |