Commit 29666b56 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros launcher: Check for whitespace query.

Instead of transitioning to HALF or FULLSCREEN_SEARCH whenever the
search query is not empty, transition only when the query is not empty
and contains some non-whitespace characters.

This will be changed when Zero Query State is introduced, at a later
date.

for-Commit-Position: refs/heads/master@{#487254}
Bug: 746048
Change-Id: I78a2eb73589d3a13c2213d9f4f1d26f2c6162dc8
Reviewed-on: https://chromium-review.googlesource.com/578470Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488474}
parent 75fbbcc4
...@@ -787,4 +787,32 @@ TEST_P(FullscreenAppListPresenterDelegateTest, ...@@ -787,4 +787,32 @@ TEST_P(FullscreenAppListPresenterDelegateTest,
EXPECT_EQ(view->app_list_state(), app_list::AppListView::FULLSCREEN_ALL_APPS); EXPECT_EQ(view->app_list_state(), app_list::AppListView::FULLSCREEN_ALL_APPS);
} }
// Tests that the search box is set active with a whitespace query and that the
// app list state doesn't transition with a whitespace query.
TEST_F(FullscreenAppListPresenterDelegateTest, WhitespaceQuery) {
app_list_presenter_impl()->Show(GetPrimaryDisplayId());
app_list::AppListView* view = app_list_presenter_impl()->GetView();
ui::test::EventGenerator& generator = GetEventGenerator();
EXPECT_FALSE(view->search_box_view()->is_search_box_active());
EXPECT_EQ(view->app_list_state(), app_list::AppListView::PEEKING);
// Enter a whitespace query, the searchbox should activate but stay in peeking
// mode.
generator.PressKey(ui::VKEY_SPACE, 0);
EXPECT_TRUE(view->search_box_view()->is_search_box_active());
EXPECT_EQ(view->app_list_state(), app_list::AppListView::PEEKING);
// Enter a non-whitespace character, the Searchbox should stay active and go
// to HALF
generator.PressKey(ui::VKEY_0, 0);
EXPECT_TRUE(view->search_box_view()->is_search_box_active());
EXPECT_EQ(view->app_list_state(), app_list::AppListView::HALF);
// Delete the non whitespace character, the Searchbox should deactivate and go
// to PEEKING
generator.PressKey(ui::VKEY_BACK, 0);
EXPECT_FALSE(view->search_box_view()->is_search_box_active());
EXPECT_EQ(view->app_list_state(), app_list::AppListView::PEEKING);
}
} // namespace ash } // namespace ash
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
-FullscreenAppListPresenterDelegateTest.TapAndClickEnablesSearchBox -FullscreenAppListPresenterDelegateTest.TapAndClickEnablesSearchBox
-FullscreenAppListPresenterDelegateTest.TapAndClickOutsideClosesHalfAppList -FullscreenAppListPresenterDelegateTest.TapAndClickOutsideClosesHalfAppList
-FullscreenAppListPresenterDelegateTest.TapAndClickOutsideClosesPeekingAppList -FullscreenAppListPresenterDelegateTest.TapAndClickOutsideClosesPeekingAppList
-FullscreenAppListPresenterDelegateTest.WhitespaceQuery
-NativeCursorManagerAshTest.FractionalScale -NativeCursorManagerAshTest.FractionalScale
-NativeCursorManagerAshTest.LockCursor -NativeCursorManagerAshTest.LockCursor
-NativeCursorManagerAshTest.SetCursor -NativeCursorManagerAshTest.SetCursor
......
...@@ -904,6 +904,7 @@ void AppListView::SetState(AppListState new_state) { ...@@ -904,6 +904,7 @@ void AppListView::SetState(AppListState new_state) {
new_widget_bounds.set_y(peeking_app_list_y); new_widget_bounds.set_y(peeking_app_list_y);
app_list_main_view_->contents_view()->SetActiveState( app_list_main_view_->contents_view()->SetActiveState(
AppListModel::STATE_START); AppListModel::STATE_START);
search_box_view()->ClearSearch();
break; break;
} }
case FULLSCREEN_SEARCH: case FULLSCREEN_SEARCH:
......
...@@ -526,9 +526,12 @@ void SearchBoxView::ContentsChanged(views::Textfield* sender, ...@@ -526,9 +526,12 @@ void SearchBoxView::ContentsChanged(views::Textfield* sender,
view_delegate_->AutoLaunchCanceled(); view_delegate_->AutoLaunchCanceled();
NotifyQueryChanged(); NotifyQueryChanged();
if (is_fullscreen_app_list_enabled_) { if (is_fullscreen_app_list_enabled_) {
if (is_search_box_active_ == search_box_->text().empty())
SetSearchBoxActive(!search_box_->text().empty()); SetSearchBoxActive(!search_box_->text().empty());
app_list_view_->SetStateFromSearchBoxView(search_box_->text().empty()); // If the query is only whitespace, don't transition the AppListView state.
base::string16 trimmed_query = search_box_->text();
base::TrimWhitespace(search_box_->text(), base::TrimPositions::TRIM_ALL,
&trimmed_query);
app_list_view_->SetStateFromSearchBoxView(trimmed_query.empty());
} }
} }
......
...@@ -60,8 +60,7 @@ SearchResultListView::SearchResultListView( ...@@ -60,8 +60,7 @@ SearchResultListView::SearchResultListView(
AddChildView(auto_launch_indicator_); AddChildView(auto_launch_indicator_);
} }
SearchResultListView::~SearchResultListView() { SearchResultListView::~SearchResultListView() {}
}
bool SearchResultListView::IsResultViewSelected( bool SearchResultListView::IsResultViewSelected(
const SearchResultView* result_view) const { const SearchResultView* result_view) const {
...@@ -163,8 +162,7 @@ int SearchResultListView::GetYSize() { ...@@ -163,8 +162,7 @@ int SearchResultListView::GetYSize() {
int SearchResultListView::DoUpdate() { int SearchResultListView::DoUpdate() {
std::vector<SearchResult*> display_results = std::vector<SearchResult*> display_results =
AppListModel::FilterSearchResultsByDisplayType( AppListModel::FilterSearchResultsByDisplayType(
results(), results(), SearchResult::DISPLAY_LIST,
SearchResult::DISPLAY_LIST,
results_container_->child_count()); results_container_->child_count());
for (size_t i = 0; i < static_cast<size_t>(results_container_->child_count()); for (size_t i = 0; i < static_cast<size_t>(results_container_->child_count());
...@@ -250,8 +248,8 @@ void SearchResultListView::AnimationProgressed( ...@@ -250,8 +248,8 @@ void SearchResultListView::AnimationProgressed(
const gfx::Animation* animation) { const gfx::Animation* animation) {
DCHECK_EQ(auto_launch_animation_.get(), animation); DCHECK_EQ(auto_launch_animation_.get(), animation);
int indicator_width = auto_launch_animation_->CurrentValueBetween(0, width()); int indicator_width = auto_launch_animation_->CurrentValueBetween(0, width());
auto_launch_indicator_->SetBounds( auto_launch_indicator_->SetBounds(0, 0, indicator_width,
0, 0, indicator_width, kTimeoutIndicatorHeight); kTimeoutIndicatorHeight);
} }
void SearchResultListView::SearchResultActivated(SearchResultView* view, void SearchResultListView::SearchResultActivated(SearchResultView* view,
...@@ -264,8 +262,8 @@ void SearchResultListView::SearchResultActionActivated(SearchResultView* view, ...@@ -264,8 +262,8 @@ void SearchResultListView::SearchResultActionActivated(SearchResultView* view,
size_t action_index, size_t action_index,
int event_flags) { int event_flags) {
if (view_delegate_ && view->result()) { if (view_delegate_ && view->result()) {
view_delegate_->InvokeSearchResultAction( view_delegate_->InvokeSearchResultAction(view->result(), action_index,
view->result(), action_index, event_flags); event_flags);
} }
} }
......
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