| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/system/chromeos/power/tablet_power_button_controller.h" | 5 #include "ash/system/chromeos/power/tablet_power_button_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/session/session_controller.h" | 10 #include "ash/common/session/session_controller.h" |
| 11 #include "ash/common/test/test_session_controller_client.h" | 11 #include "ash/common/test/test_session_controller_client.h" |
| 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 13 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 14 #include "ash/public/cpp/config.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/test/lock_state_controller_test_api.h" | 17 #include "ash/test/lock_state_controller_test_api.h" |
| 17 #include "ash/test/test_shell_delegate.h" | 18 #include "ash/test/test_shell_delegate.h" |
| 18 #include "ash/wm/lock_state_controller.h" | 19 #include "ash/wm/lock_state_controller.h" |
| 19 #include "ash/wm/power_button_controller.h" | 20 #include "ash/wm/power_button_controller.h" |
| 20 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 21 #include "base/compiler_specific.h" | 22 #include "base/compiler_specific.h" |
| 22 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
| 23 #include "base/run_loop.h" | 24 #include "base/run_loop.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 std::unique_ptr<base::TickClock>(tick_clock_)); | 70 std::unique_ptr<base::TickClock>(tick_clock_)); |
| 70 shell_delegate_ = | 71 shell_delegate_ = |
| 71 static_cast<TestShellDelegate*>(Shell::Get()->shell_delegate()); | 72 static_cast<TestShellDelegate*>(Shell::Get()->shell_delegate()); |
| 72 generator_ = &AshTestBase::GetEventGenerator(); | 73 generator_ = &AshTestBase::GetEventGenerator(); |
| 73 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); | 74 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); |
| 74 EXPECT_FALSE(GetBacklightsForcedOff()); | 75 EXPECT_FALSE(GetBacklightsForcedOff()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void TearDown() override { | 78 void TearDown() override { |
| 78 generator_ = nullptr; | 79 generator_ = nullptr; |
| 79 const bool is_mash = WmShell::Get()->IsRunningInMash(); | 80 const Config config = Shell::GetAshConfig(); |
| 80 AshTestBase::TearDown(); | 81 AshTestBase::TearDown(); |
| 81 // Mash shuts down dbus after each test. | 82 // Mash/mus shuts down dbus after each test. |
| 82 if (!is_mash) | 83 if (config == Config::CLASSIC) |
| 83 chromeos::DBusThreadManager::Shutdown(); | 84 chromeos::DBusThreadManager::Shutdown(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 protected: | 87 protected: |
| 87 void PressPowerButton() { | 88 void PressPowerButton() { |
| 88 tablet_controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 89 tablet_controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void ReleasePowerButton() { | 92 void ReleasePowerButton() { |
| 92 tablet_controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 93 tablet_controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // Test that after another long duration, backlights should be forced off. | 479 // Test that after another long duration, backlights should be forced off. |
| 479 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(800)); | 480 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(800)); |
| 480 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); | 481 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); |
| 481 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); | 482 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); |
| 482 power_manager_client_->SendBrightnessChanged(0, false); | 483 power_manager_client_->SendBrightnessChanged(0, false); |
| 483 EXPECT_TRUE(GetBacklightsForcedOff()); | 484 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 484 } | 485 } |
| 485 | 486 |
| 486 } // namespace test | 487 } // namespace test |
| 487 } // namespace ash | 488 } // namespace ash |
| OLD | NEW |