Skip to content

Commit

Permalink
Fix Virtual Keyboard not being deployed in TouchView mode on Ozone.
Browse files Browse the repository at this point in the history
Ozone includes the internal keyboard in the actice keyboard devices
even if the TV mode disables it due to the fact that the volume keys
can still be pressed. We now explicitly check the state of maximized
mode when deciding to show the keyboard.

TEST=VirtualKeyboardControllerAutoTest.EnabledDuringMaximizeMode, VirtualKeyboardControllerAutoTest.SuppressedInMaximizedMode
BUG=462666

Review URL: https://codereview.chromium.org/970983003

Cr-Commit-Position: refs/heads/master@{#318801}
  • Loading branch information
rsadam authored and Commit bot committed Mar 2, 2015
1 parent d0fe749 commit d4f6a0b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 5 deletions.
19 changes: 15 additions & 4 deletions ash/virtual_keyboard_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ VirtualKeyboardController::~VirtualKeyboardController() {
}

void VirtualKeyboardController::OnMaximizeModeStarted() {
if (!IsSmartVirtualKeyboardEnabled())
if (!IsSmartVirtualKeyboardEnabled()) {
SetKeyboardEnabled(true);
} else {
UpdateKeyboardEnabled();
}
}

void VirtualKeyboardController::OnMaximizeModeEnded() {
if (!IsSmartVirtualKeyboardEnabled())
if (!IsSmartVirtualKeyboardEnabled()) {
SetKeyboardEnabled(false);
} else {
UpdateKeyboardEnabled();
}
}

void VirtualKeyboardController::OnTouchscreenDeviceConfigurationChanged() {
Expand Down Expand Up @@ -103,11 +109,16 @@ void VirtualKeyboardController::UpdateKeyboardEnabled() {
->IsMaximizeModeWindowManagerEnabled());
return;
}
SetKeyboardEnabled(!has_internal_keyboard_ && has_touchscreen_ &&
bool ignore_internal_keyboard = Shell::GetInstance()
->maximize_mode_controller()
->IsMaximizeModeWindowManagerEnabled();
bool is_internal_keyboard_active =
has_internal_keyboard_ && !ignore_internal_keyboard;
SetKeyboardEnabled(!is_internal_keyboard_active && has_touchscreen_ &&
(!has_external_keyboard_ || ignore_external_keyboard_));
ash::Shell::GetInstance()
->system_tray_notifier()
->NotifyVirtualKeyboardSuppressionChanged(!has_internal_keyboard_ &&
->NotifyVirtualKeyboardSuppressionChanged(!is_internal_keyboard_active &&
has_touchscreen_ &&
has_external_keyboard_);
}
Expand Down
75 changes: 74 additions & 1 deletion ash/virtual_keyboard_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest,
};

// Tests that the onscreen keyboard is disabled if an internal keyboard is
// present.
// present and maximized mode is disabled.
TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) {
std::vector<ui::TouchscreenDevice> screens;
screens.push_back(ui::TouchscreenDevice(
Expand Down Expand Up @@ -235,6 +235,79 @@ TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) {
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
}

// Tests maximized mode interaction without disabling the internal keyboard.
TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) {
std::vector<ui::TouchscreenDevice> screens;
screens.push_back(ui::TouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0));
UpdateTouchscreenDevices(screens);
std::vector<ui::KeyboardDevice> keyboards;
keyboards.push_back(
ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
UpdateKeyboardDevices(keyboards);
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
// Toggle maximized mode on.
Shell::GetInstance()
->maximize_mode_controller()
->EnableMaximizeModeWindowManager(true);
ASSERT_TRUE(keyboard::IsKeyboardEnabled());
// Toggle maximized mode off.
Shell::GetInstance()
->maximize_mode_controller()
->EnableMaximizeModeWindowManager(false);
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
}

// Tests that keyboard gets suppressed in maximized mode.
TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) {
std::vector<ui::TouchscreenDevice> screens;
screens.push_back(ui::TouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0));
UpdateTouchscreenDevices(screens);
std::vector<ui::KeyboardDevice> keyboards;
keyboards.push_back(
ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
keyboards.push_back(
ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL));
UpdateKeyboardDevices(keyboards);
// Toggle maximized mode on.
Shell::GetInstance()
->maximize_mode_controller()
->EnableMaximizeModeWindowManager(true);
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified());
ASSERT_TRUE(IsVirtualKeyboardSuppressed());
// Toggle show keyboard. Keyboard should be visible.
ResetObserver();
Shell::GetInstance()
->virtual_keyboard_controller()
->ToggleIgnoreExternalKeyboard();
ASSERT_TRUE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified());
ASSERT_TRUE(IsVirtualKeyboardSuppressed());
// Toggle show keyboard. Keyboard should be hidden.
ResetObserver();
Shell::GetInstance()
->virtual_keyboard_controller()
->ToggleIgnoreExternalKeyboard();
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified());
ASSERT_TRUE(IsVirtualKeyboardSuppressed());
// Remove external keyboard. Should be notified that the keyboard is not
// suppressed.
ResetObserver();
keyboards.pop_back();
UpdateKeyboardDevices(keyboards);
ASSERT_TRUE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified());
ASSERT_FALSE(IsVirtualKeyboardSuppressed());
// Toggle maximized mode oFF.
Shell::GetInstance()
->maximize_mode_controller()
->EnableMaximizeModeWindowManager(false);
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
}

class VirtualKeyboardControllerAlwaysEnabledTest
: public VirtualKeyboardControllerAutoTest {
public:
Expand Down

0 comments on commit d4f6a0b

Please sign in to comment.