Commit 41396d6e authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

tablet: Fix a bug with keyboard not disabled on boot.

This was failing on Nautilus. I am not sure why it worked fine with
other devices, but I tested this manually.

Test: manual
Bug: b/111137179
Change-Id: I8d457f7180b5b486d86226960913b20836849f70
Reviewed-on: https://chromium-review.googlesource.com/1139227Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576097}
parent 5c723c39
......@@ -76,6 +76,8 @@ class ASH_EXPORT WindowSelectorController : public WindowSelectorDelegate {
private:
class OverviewBlurController;
friend class WindowSelectorTest;
FRIEND_TEST_ALL_PREFIXES(TabletModeControllerTest,
DisplayDisconnectionDuringOverview);
// There is no need to blur or unblur the wallpaper for tests.
static void SetDoNotChangeWallpaperBlurForTests();
......
......@@ -410,13 +410,12 @@ void TabletModeController::HandleHingeRotation(
}
void TabletModeController::EnterTabletMode() {
// Always reset first to avoid creation before destruction of a previous
// object.
event_blocker_ = CreateScopedDisableInternalMouseAndKeyboard();
if (IsTabletModeWindowManagerEnabled())
return;
DCHECK(!event_blocker_);
event_blocker_ = CreateScopedDisableInternalMouseAndKeyboard();
should_enter_tablet_mode_ = true;
if (has_external_mouse_)
......@@ -525,7 +524,7 @@ void TabletModeController::HandleMouseAddedOrRemoved() {
}
}
if (has_external_mouse_ && has_external_mouse)
if (has_external_mouse_ == has_external_mouse)
return;
has_external_mouse_ = has_external_mouse;
......
......@@ -541,12 +541,16 @@ TEST_F(TabletModeControllerTest, VerticalHingeTest) {
// Test if this case does not crash. See http://crbug.com/462806
TEST_F(TabletModeControllerTest, DisplayDisconnectionDuringOverview) {
// Do not animate wallpaper on entering overview.
WindowSelectorController::SetDoNotChangeWallpaperBlurForTests();
UpdateDisplay("800x600,800x600");
std::unique_ptr<aura::Window> w1(
CreateTestWindowInShellWithBounds(gfx::Rect(0, 0, 100, 100)));
std::unique_ptr<aura::Window> w2(
CreateTestWindowInShellWithBounds(gfx::Rect(800, 0, 100, 100)));
ASSERT_NE(w1->GetRootWindow(), w2->GetRootWindow());
ASSERT_FALSE(IsTabletModeStarted());
tablet_mode_controller()->EnableTabletModeWindowManager(true);
EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview());
......@@ -755,9 +759,9 @@ TEST_F(TabletModeControllerTest, RecordLidAngle) {
TEST_F(TabletModeControllerTest, CannotEnterTabletModeWithExternalMouse) {
// Set the current list of devices to empty so that they don't interfere
// with the test.
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
ui::InputDeviceClientTestApi().SetMouseDevices({});
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
OpenLidToAngle(300.0f);
EXPECT_TRUE(IsTabletModeStarted());
......@@ -768,7 +772,7 @@ TEST_F(TabletModeControllerTest, CannotEnterTabletModeWithExternalMouse) {
// Attach a external mouse.
ui::InputDeviceClientTestApi().SetMouseDevices({ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "mouse")});
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(IsTabletModeStarted());
// Open lid to tent mode. Verify that tablet mode is not started.
......@@ -781,9 +785,9 @@ TEST_F(TabletModeControllerTest, CannotEnterTabletModeWithExternalMouse) {
TEST_F(TabletModeControllerTest, LeaveTabletModeWhenExternalMouseConnected) {
// Set the current list of devices to empty so that they don't interfere
// with the test.
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
ui::InputDeviceClientTestApi().SetMouseDevices({});
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
// Start in tablet mode.
OpenLidToAngle(300.0f);
......@@ -792,12 +796,12 @@ TEST_F(TabletModeControllerTest, LeaveTabletModeWhenExternalMouseConnected) {
// Attach external mouse and keyboard. Verify that tablet mode has ended.
ui::InputDeviceClientTestApi().SetMouseDevices({ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "mouse")});
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(IsTabletModeStarted());
// Verify that after unplugging the mouse, tablet mode will resume.
ui::InputDeviceClientTestApi().SetMouseDevices({});
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(IsTabletModeStarted());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment