Commit 05cdce00 authored by calamity's avatar calamity Committed by Commit bot

Refocus app list search box when dialogs are closed.

This CL fixes an issue where closing dialog boxes in the app list would
not restore focus to the search box. This is fixed by refocusing the
search box when the app list overlay is hidden.

BUG=450922

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

Cr-Commit-Position: refs/heads/master@{#317727}
parent c39790a9
...@@ -309,6 +309,8 @@ void AppListView::SetAppListOverlayVisible(bool visible) { ...@@ -309,6 +309,8 @@ void AppListView::SetAppListOverlayVisible(bool visible) {
search_box_widget_->GetLayer()->SetOpacity(visible ? kSearchBoxWidgetOpacity search_box_widget_->GetLayer()->SetOpacity(visible ? kSearchBoxWidgetOpacity
: 1.0f); : 1.0f);
search_box_view_->SetEnabled(!visible); search_box_view_->SetEnabled(!visible);
if (!visible)
search_box_view_->search_box()->RequestFocus();
} }
} }
......
...@@ -111,6 +111,9 @@ class AppListViewTestContext { ...@@ -111,6 +111,9 @@ class AppListViewTestContext {
// Tests displaying of the search results. // Tests displaying of the search results.
void RunSearchResultsTest(); void RunSearchResultsTest();
// Tests displaying the app list overlay.
void RunAppListOverlayTest();
// A standard set of checks on a view, e.g., ensuring it is drawn and visible. // A standard set of checks on a view, e.g., ensuring it is drawn and visible.
static void CheckView(views::View* subview); static void CheckView(views::View* subview);
...@@ -666,6 +669,25 @@ void AppListViewTestContext::RunSearchResultsTest() { ...@@ -666,6 +669,25 @@ void AppListViewTestContext::RunSearchResultsTest() {
Close(); Close();
} }
void AppListViewTestContext::RunAppListOverlayTest() {
Show();
AppListMainView* main_view = view_->app_list_main_view();
SearchBoxView* search_box_view = main_view->search_box_view();
// The search box should not be enabled when the app list overlay is shown.
view_->SetAppListOverlayVisible(true);
EXPECT_FALSE(search_box_view->enabled());
// The search box should be refocused when the app list overlay is hidden.
view_->SetAppListOverlayVisible(false);
EXPECT_TRUE(search_box_view->enabled());
EXPECT_EQ(search_box_view->search_box(),
view_->GetWidget()->GetFocusManager()->GetFocusedView());
Close();
}
class AppListViewTestAura : public views::ViewsTestBase, class AppListViewTestAura : public views::ViewsTestBase,
public ::testing::WithParamInterface<int> { public ::testing::WithParamInterface<int> {
public: public:
...@@ -825,6 +847,15 @@ TEST_P(AppListViewTestDesktop, BackTest) { ...@@ -825,6 +847,15 @@ TEST_P(AppListViewTestDesktop, BackTest) {
EXPECT_NO_FATAL_FAILURE(test_context_->RunBackTest()); EXPECT_NO_FATAL_FAILURE(test_context_->RunBackTest());
} }
// Tests that the correct views are displayed for showing search results.
TEST_P(AppListViewTestAura, AppListOverlayTest) {
EXPECT_NO_FATAL_FAILURE(test_context_->RunAppListOverlayTest());
}
TEST_P(AppListViewTestDesktop, AppListOverlayTest) {
EXPECT_NO_FATAL_FAILURE(test_context_->RunAppListOverlayTest());
}
#if defined(USE_AURA) #if defined(USE_AURA)
INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance,
AppListViewTestAura, AppListViewTestAura,
......
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