| Index: ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
|
| diff --git a/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc b/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
|
| index a99fb9008e2026badf611f2cd8184761ba56b934..82b3088055698f4638112931e345fe0cb0cfe9dc 100644
|
| --- a/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
|
| +++ b/ash/system/chromeos/power/tablet_power_button_controller_unittest.cc
|
| @@ -13,6 +13,7 @@
|
| #include "ash/shell.h"
|
| #include "ash/test/ash_test_base.h"
|
| #include "ash/test/lock_state_controller_test_api.h"
|
| +#include "ash/test/test_shell_delegate.h"
|
| #include "ash/wm/lock_state_controller.h"
|
| #include "ash/wm/power_button_controller.h"
|
| #include "base/command_line.h"
|
| @@ -61,6 +62,8 @@ class TabletPowerButtonControllerTest : public AshTestBase {
|
| ->tablet_power_button_controller_for_test();
|
| test_api_ = base::MakeUnique<TabletPowerButtonController::TestApi>(
|
| tablet_controller_);
|
| + shell_delegate_ =
|
| + static_cast<TestShellDelegate*>(WmShell::Get()->delegate());
|
| generator_ = &AshTestBase::GetEventGenerator();
|
| power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
|
| EXPECT_FALSE(GetBacklightsForcedOff());
|
| @@ -115,6 +118,7 @@ class TabletPowerButtonControllerTest : public AshTestBase {
|
| LockStateController* lock_state_controller_; // Not owned.
|
| TabletPowerButtonController* tablet_controller_; // Not owned.
|
| std::unique_ptr<TabletPowerButtonController::TestApi> test_api_;
|
| + TestShellDelegate* shell_delegate_; // Not owned.
|
| ui::test::EventGenerator* generator_ = nullptr;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonControllerTest);
|
| @@ -323,5 +327,42 @@ TEST_F(TabletPowerButtonControllerTest, IgnorePowerOnKeyEvent) {
|
| EXPECT_EQ(1, power_manager_client_->num_set_backlights_forced_off_calls());
|
| }
|
|
|
| +// Tests that under (1) tablet power button pressed/released, (2) keyboard/mouse
|
| +// events on laptop mode when screen is off, requesting/stopping backlights
|
| +// forced off should also try to toggle touch screen.
|
| +TEST_F(TabletPowerButtonControllerTest, ToggleTouchScreen) {
|
| + // Tests tablet power button.
|
| + EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabled());
|
| + PressPowerButton();
|
| + ReleasePowerButton();
|
| + power_manager_client_->SendBrightnessChanged(0, false);
|
| + EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabled());
|
| +
|
| + PressPowerButton();
|
| + power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
|
| + ReleasePowerButton();
|
| + EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabled());
|
| +
|
| + // KeyEvent on laptop mode when screen is off.
|
| + PressPowerButton();
|
| + ReleasePowerButton();
|
| + power_manager_client_->SendBrightnessChanged(0, false);
|
| + EXPECT_TRUE(GetBacklightsForcedOff());
|
| + EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabled());
|
| + generator_->PressKey(ui::VKEY_L, ui::EF_NONE);
|
| + power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
|
| + EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabled());
|
| +
|
| + // MouseEvent on laptop mode when screen is off.
|
| + PressPowerButton();
|
| + ReleasePowerButton();
|
| + power_manager_client_->SendBrightnessChanged(0, false);
|
| + EXPECT_TRUE(GetBacklightsForcedOff());
|
| + EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabled());
|
| + generator_->MoveMouseBy(1, 1);
|
| + power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
|
| + EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabled());
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace ash
|
|
|