Commit 7af7260a authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: AppList v-keyboard behavioral change

When the v-keyboard is being shown and the body of the
applist is tapped or clicked, dismiss the keyboard with no
side effects.

Bug: 844773
Change-Id: Iab0325e5cb5e77678df5c33a8e7f8e589e926825
Reviewed-on: https://chromium-review.googlesource.com/1077497Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564727}
parent fc2c786e
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/display/test/display_manager_test_api.h" #include "ui/display/test/display_manager_test_api.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_test_util.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
namespace ash { namespace ash {
...@@ -92,6 +95,8 @@ class AppListPresenterDelegateTest : public AshTestBase, ...@@ -92,6 +95,8 @@ class AppListPresenterDelegateTest : public AshTestBase,
// testing::Test: // testing::Test:
void SetUp() override { void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
keyboard::switches::kEnableVirtualKeyboard);
AshTestBase::SetUp(); AshTestBase::SetUp();
// Make the display big enough to hold the app list. // Make the display big enough to hold the app list.
...@@ -675,6 +680,66 @@ TEST_P(AppListPresenterDelegateTest, TapAndClickEnablesSearchBox) { ...@@ -675,6 +680,66 @@ TEST_P(AppListPresenterDelegateTest, TapAndClickEnablesSearchBox) {
GetAppListTestHelper()->CheckVisibility(false); GetAppListTestHelper()->CheckVisibility(false);
} }
// Tests that tapping or clicking the body of the applist with an active virtual
// keyboard results in the virtual keyboard closing with no side effects.
TEST_P(AppListPresenterDelegateTest,
TapAppListWithVirtualKeyboardDismissesVirtualKeyboard) {
const bool test_click = GetParam();
GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId());
EnableTabletMode(true);
// Tap to activate the searchbox.
ui::test::EventGenerator& generator = GetEventGenerator();
generator.GestureTapAt(GetPointInsideSearchbox());
// Enter some text in the searchbox, the applist should transition to
// fullscreen search.
generator.PressKey(ui::KeyboardCode::VKEY_0, 0);
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckState(
app_list::AppListViewState::FULLSCREEN_SEARCH);
// Manually show the virtual keyboard.
keyboard::KeyboardController* const keyboard_controller =
keyboard::KeyboardController::GetInstance();
keyboard_controller->ShowKeyboard(true);
keyboard_controller->ui()->GetContentsWindow()->SetBounds(
keyboard::KeyboardBoundsFromRootBounds(
Shell::GetPrimaryRootWindow()->bounds(), 100));
keyboard_controller->NotifyContentsLoaded();
EXPECT_TRUE(keyboard_controller->keyboard_visible());
// Tap or click outside the searchbox, the virtual keyboard should hide.
if (test_click) {
generator.MoveMouseTo(GetPointOutsideSearchbox());
generator.ClickLeftButton();
generator.ReleaseLeftButton();
} else {
generator.GestureTapAt(GetPointOutsideSearchbox());
}
EXPECT_FALSE(keyboard_controller->keyboard_visible());
// The searchbox should still be active and the AppListView should still be in
// FULLSCREEN_SEARCH.
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckState(
app_list::AppListViewState::FULLSCREEN_SEARCH);
EXPECT_TRUE(GetAppListView()->search_box_view()->is_search_box_active());
// Tap or click the body of the AppList again, the searchbox should deactivate
// and the applist should be in FULLSCREEN_ALL_APPS.
if (test_click) {
generator.MoveMouseTo(GetPointOutsideSearchbox());
generator.ClickLeftButton();
generator.ReleaseLeftButton();
} else {
generator.GestureTapAt(GetPointOutsideSearchbox());
}
GetAppListTestHelper()->CheckState(
app_list::AppListViewState::FULLSCREEN_ALL_APPS);
EXPECT_FALSE(GetAppListView()->search_box_view()->is_search_box_active());
}
// Tests that the shelf background displays/hides with bottom shelf // Tests that the shelf background displays/hides with bottom shelf
// alignment. // alignment.
TEST_F(AppListPresenterDelegateTest, TEST_F(AppListPresenterDelegateTest,
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
-AppListPresenterDelegateTest.TabletModeTextStateTransitions -AppListPresenterDelegateTest.TabletModeTextStateTransitions
-AppListPresenterDelegateTest.TapAndClickOutsideClosesHalfAppList/0 -AppListPresenterDelegateTest.TapAndClickOutsideClosesHalfAppList/0
-AppListPresenterDelegateTest.TapAndClickOutsideClosesHalfAppList/1 -AppListPresenterDelegateTest.TapAndClickOutsideClosesHalfAppList/1
-AppListPresenterDelegateTest.TapAppListWithVirtualKeyboardDismissesVirtualKeyboard/0
-AppListPresenterDelegateTest.TapAppListWithVirtualKeyboardDismissesVirtualKeyboard/1
-AppListPresenterDelegateTest.WhitespaceQuery -AppListPresenterDelegateTest.WhitespaceQuery
# TODO: CursorManagerTestApi. http://crbug.com/780637 # TODO: CursorManagerTestApi. http://crbug.com/780637
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
#include "ui/gfx/path.h" #include "ui/gfx/path.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
...@@ -510,6 +511,15 @@ void AppListView::InitializeFullscreen(gfx::NativeView parent, ...@@ -510,6 +511,15 @@ void AppListView::InitializeFullscreen(gfx::NativeView parent,
} }
void AppListView::HandleClickOrTap(ui::LocatedEvent* event) { void AppListView::HandleClickOrTap(ui::LocatedEvent* event) {
// If the virtual keyboard is visible, dismiss the keyboard and return early.
keyboard::KeyboardController* const keyboard_controller =
keyboard::KeyboardController::GetInstance();
if (keyboard_controller && keyboard_controller->keyboard_visible()) {
keyboard_controller->HideKeyboard(
keyboard::KeyboardController::HIDE_REASON_MANUAL);
return;
}
// Clear focus if the located event is not handled by any child view. // Clear focus if the located event is not handled by any child view.
GetFocusManager()->ClearFocus(); GetFocusManager()->ClearFocus();
......
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