Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3865)

Unified Diff: ash/system/chromeos/power/tablet_power_button_controller_unittest.cc

Issue 2533373002: Enabled/disable touch screen in TabletPowerButtonController (Closed)
Patch Set: nits Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/chromeos/power/tablet_power_button_controller.cc ('k') | ash/test/test_shell_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4633032a53e5a128b82ea3b5b2c8768e3d18c392..a27af600e2ce450afb8e11bf69f96a0326d3beb9 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"
@@ -64,6 +65,8 @@ class TabletPowerButtonControllerTest : public AshTestBase {
tick_clock_ = new base::SimpleTestTickClock;
tablet_controller_->SetTickClockForTesting(
std::unique_ptr<base::TickClock>(tick_clock_));
+ shell_delegate_ =
+ static_cast<TestShellDelegate*>(WmShell::Get()->delegate());
generator_ = &AshTestBase::GetEventGenerator();
power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
EXPECT_FALSE(GetBacklightsForcedOff());
@@ -119,6 +122,7 @@ class TabletPowerButtonControllerTest : public AshTestBase {
TabletPowerButtonController* tablet_controller_; // Not owned.
std::unique_ptr<TabletPowerButtonController::TestApi> test_api_;
base::SimpleTestTickClock* tick_clock_; // Not owned.
+ TestShellDelegate* shell_delegate_; // Not owned.
ui::test::EventGenerator* generator_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonControllerTest);
@@ -356,5 +360,43 @@ 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 set corresponding touch screen state in local pref.
+TEST_F(TabletPowerButtonControllerTest, TouchScreenState) {
+ // Tests tablet power button.
+ EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabledInPrefs(true));
+ PressPowerButton();
+ ReleasePowerButton();
+ power_manager_client_->SendBrightnessChanged(0, false);
+ EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabledInPrefs(true));
+
+ PressPowerButton();
+ power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
+ ReleasePowerButton();
+ EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabledInPrefs(true));
+
+ EnableMaximizeMode(false);
+ // KeyEvent on laptop mode when screen is off.
+ PressPowerButton();
+ ReleasePowerButton();
+ power_manager_client_->SendBrightnessChanged(0, false);
+ EXPECT_TRUE(GetBacklightsForcedOff());
+ EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabledInPrefs(true));
+ generator_->PressKey(ui::VKEY_L, ui::EF_NONE);
+ power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
+ EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabledInPrefs(true));
+
+ // MouseEvent on laptop mode when screen is off.
+ PressPowerButton();
+ ReleasePowerButton();
+ power_manager_client_->SendBrightnessChanged(0, false);
+ EXPECT_TRUE(GetBacklightsForcedOff());
+ EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabledInPrefs(true));
+ generator_->MoveMouseBy(1, 1);
+ power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
+ EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabledInPrefs(true));
+}
+
} // namespace test
} // namespace ash
« no previous file with comments | « ash/system/chromeos/power/tablet_power_button_controller.cc ('k') | ash/test/test_shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698