Commit da4077c5 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Fix ContentsView::ResetForShow()

This clears the visibility of search results and assistant, while
the visibility of horizontal page container (i.e. apps grid)
remains. I thought SetActiveState() will update that, but actually
it does nothing if the target page is not visible. As the result,
this can cause nothing to be shown in the app-list.

BUG=b/142069648
TEST=manually, app_list_unittests

Change-Id: I6e50b7e1b2f2234bd347ac5b7fdef35ecbe8522d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1838303Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702647}
parent 6c5ebb18
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ash/app_list/views/contents_view.h" #include "ash/app_list/views/contents_view.h"
#include "ash/app_list/views/expand_arrow_view.h" #include "ash/app_list/views/expand_arrow_view.h"
#include "ash/app_list/views/folder_header_view.h" #include "ash/app_list/views/folder_header_view.h"
#include "ash/app_list/views/horizontal_page_container.h"
#include "ash/app_list/views/page_switcher.h" #include "ash/app_list/views/page_switcher.h"
#include "ash/app_list/views/result_selection_controller.h" #include "ash/app_list/views/result_selection_controller.h"
#include "ash/app_list/views/search_box_view.h" #include "ash/app_list/views/search_box_view.h"
...@@ -2649,6 +2650,30 @@ TEST_F(AppListViewFocusTest, ShowEmbeddedAssistantUI) { ...@@ -2649,6 +2650,30 @@ TEST_F(AppListViewFocusTest, ShowEmbeddedAssistantUI) {
EXPECT_EQ(1, GetTotalOpenAssistantUICount()); EXPECT_EQ(1, GetTotalOpenAssistantUICount());
} }
// Tests that the correct contents is visible in the contents_view upon
// reshowing. See b/142069648 for the details.
TEST_F(AppListViewTest, AppsGridVisibilityOnResetForShow) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
{app_list_features::kEnableEmbeddedAssistantUI}, {});
Initialize(true /*is_tablet_mode*/);
Show(true /*is_tablet_mode*/);
contents_view()->ShowEmbeddedAssistantUI(true);
EXPECT_FALSE(contents_view()->horizontal_page_container()->GetVisible());
EXPECT_FALSE(contents_view()->search_results_page_view()->GetVisible());
const int assistant_page_index = contents_view()->GetPageIndexForState(
ash::AppListState::kStateEmbeddedAssistant);
EXPECT_TRUE(contents_view()->GetPageView(assistant_page_index)->GetVisible());
view_->OnTabletModeChanged(false);
Show(false /*is_tablet_mode*/);
EXPECT_TRUE(contents_view()->horizontal_page_container()->GetVisible());
EXPECT_FALSE(contents_view()->search_results_page_view()->GetVisible());
EXPECT_FALSE(
contents_view()->GetPageView(assistant_page_index)->GetVisible());
}
// Tests that no answer card view when kEnableEmbeddedAssistantUI is enabled. // Tests that no answer card view when kEnableEmbeddedAssistantUI is enabled.
TEST_F(AppListViewTest, NoAnswerCardWhenEmbeddedAssistantUIEnabled) { TEST_F(AppListViewTest, NoAnswerCardWhenEmbeddedAssistantUIEnabled) {
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
......
...@@ -152,11 +152,13 @@ void ContentsView::ResetForShow() { ...@@ -152,11 +152,13 @@ void ContentsView::ResetForShow() {
// QueryChanged(). Since it wants to reset to kStateApps, first reset the // QueryChanged(). Since it wants to reset to kStateApps, first reset the
// search box and then set its active state to kStateApps. // search box and then set its active state to kStateApps.
GetSearchBoxView()->ResetForShow(); GetSearchBoxView()->ResetForShow();
SetActiveState(ash::AppListState::kStateApps, /*animate=*/false); // Make sure the default visibilities of the pages. This should be done before
// Make other pages invisible. // SetActiveState() since it checks the visibility of the pages.
horizontal_page_container_->SetVisible(true);
search_results_page_view_->SetVisible(false); search_results_page_view_->SetVisible(false);
if (assistant_page_view_) if (assistant_page_view_)
assistant_page_view_->SetVisible(false); assistant_page_view_->SetVisible(false);
SetActiveState(ash::AppListState::kStateApps, /*animate=*/false);
// In side shelf, the opacity of the contents is not animated so set it to the // In side shelf, the opacity of the contents is not animated so set it to the
// final state. In tablet mode, opacity of the elements is controlled by the // final state. In tablet mode, opacity of the elements is controlled by the
// HomeLauncherGestureHandler which expects these elements to be opaque. // HomeLauncherGestureHandler which expects these elements to be opaque.
......
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