| 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 "ash/common/wm/screen_dimmer.h" | 5 #include "ash/common/wm/screen_dimmer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/aura/wm_window_aura.h" | |
| 10 #include "ash/common/wm/window_dimmer.h" | 9 #include "ash/common/wm/window_dimmer.h" |
| 11 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| 11 #include "ash/common/wm_window.h" |
| 12 #include "ash/common/wm_window_user_data.h" | 12 #include "ash/common/wm_window_user_data.h" |
| 13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
| 18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 namespace test { | 21 namespace test { |
| 22 | 22 |
| 23 class ScreenDimmerTest : public AshTestBase { | 23 class ScreenDimmerTest : public AshTestBase { |
| 24 public: | 24 public: |
| 25 ScreenDimmerTest() {} | 25 ScreenDimmerTest() {} |
| 26 ~ScreenDimmerTest() override {} | 26 ~ScreenDimmerTest() override {} |
| 27 | 27 |
| 28 void SetUp() override { | 28 void SetUp() override { |
| 29 AshTestBase::SetUp(); | 29 AshTestBase::SetUp(); |
| 30 dimmer_ = base::MakeUnique<ScreenDimmer>(ScreenDimmer::Container::ROOT); | 30 dimmer_ = base::MakeUnique<ScreenDimmer>(ScreenDimmer::Container::ROOT); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void TearDown() override { | 33 void TearDown() override { |
| 34 dimmer_.reset(); | 34 dimmer_.reset(); |
| 35 AshTestBase::TearDown(); | 35 AshTestBase::TearDown(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 aura::Window* GetDimWindow() { | 38 aura::Window* GetDimWindow() { |
| 39 WindowDimmer* window_dimmer = | 39 WindowDimmer* window_dimmer = |
| 40 dimmer_->window_dimmers_->Get(WmShell::Get()->GetPrimaryRootWindow()); | 40 dimmer_->window_dimmers_->Get(WmShell::Get()->GetPrimaryRootWindow()); |
| 41 return window_dimmer ? WmWindowAura::GetAuraWindow(window_dimmer->window()) | 41 return window_dimmer ? WmWindow::GetAuraWindow(window_dimmer->window()) |
| 42 : nullptr; | 42 : nullptr; |
| 43 } | 43 } |
| 44 | 44 |
| 45 ui::Layer* GetDimWindowLayer() { | 45 ui::Layer* GetDimWindowLayer() { |
| 46 aura::Window* window = GetDimWindow(); | 46 aura::Window* window = GetDimWindow(); |
| 47 return window ? window->layer() : nullptr; | 47 return window ? window->layer() : nullptr; |
| 48 } | 48 } |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 std::unique_ptr<ScreenDimmer> dimmer_; | 51 std::unique_ptr<ScreenDimmer> dimmer_; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 // This test verifies ScreenDimmer can be destroyed after the shell. The | 133 // This test verifies ScreenDimmer can be destroyed after the shell. The |
| 134 // interesting part of this test is in TearDown(), which creates a ScreenDimmer | 134 // interesting part of this test is in TearDown(), which creates a ScreenDimmer |
| 135 // that is deleted after WmShell. | 135 // that is deleted after WmShell. |
| 136 TEST_F(ScreenDimmerShellDestructionTest, DontCrashIfScreenDimmerOutlivesShell) { | 136 TEST_F(ScreenDimmerShellDestructionTest, DontCrashIfScreenDimmerOutlivesShell) { |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace test | 139 } // namespace test |
| 140 } // namespace ash | 140 } // namespace ash |
| OLD | NEW |