Commit d4f6a0b4 authored by rsadam's avatar rsadam Committed by Commit bot

Fix Virtual Keyboard not being deployed in TouchView mode on Ozone.

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}
parent d0fe7495
......@@ -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() {
......@@ -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_);
}
......
......@@ -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(
......@@ -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:
......
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