Commit e4c85b5f authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Hide the AppList when shelf orientation changes

The AppList assumes that the Shelf Orientation stays the same during
its lifetime. Hide the AppList when shelf orientation changes to avoid
various corner cases.

Bug: 961471
Change-Id: I65283cc29c8047a5af41886ce7dd3b1b644a3dd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1693170Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676189}
parent 4d908127
......@@ -588,6 +588,10 @@ ash::AppListViewState AppListControllerImpl::GetAppListViewState() {
return model_->state_fullscreen();
}
void AppListControllerImpl::OnShelfAlignmentChanged(aura::Window* root_window) {
DismissAppList();
}
void AppListControllerImpl::OnShellDestroying() {
// Stop observing at the beginning of ~Shell to avoid unnecessary work during
// Shell shutdown.
......
......@@ -216,6 +216,7 @@ class ASH_EXPORT AppListControllerImpl
void NotifyAppListTargetVisibilityChanged(bool visible);
// ShellObserver:
void OnShelfAlignmentChanged(aura::Window* root_window) override;
void OnShellDestroying() override;
// OverviewObserver:
......
......@@ -16,6 +16,7 @@
#include "ash/ime/test_ime_controller_client.h"
#include "ash/keyboard/keyboard_controller_impl.h"
#include "ash/public/cpp/presentation_time_recorder.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
......@@ -105,6 +106,23 @@ class AppListControllerImplTest : public AshTestBase {
DISALLOW_COPY_AND_ASSIGN(AppListControllerImplTest);
};
// Tests that the AppList hides when shelf alignment changes. This necessary
// because the AppList is shown with certain assumptions based on shelf
// orientation.
TEST_F(AppListControllerImplTest, AppListHiddenWhenShelfAlignmentChanges) {
Shelf* const shelf = AshTestBase::GetPrimaryShelf();
shelf->SetAlignment(ash::ShelfAlignment::SHELF_ALIGNMENT_BOTTOM);
const std::vector<ash::ShelfAlignment> alignments(
{SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, SHELF_ALIGNMENT_BOTTOM});
for (ash::ShelfAlignment alignment : alignments) {
ShowAppListNow();
EXPECT_TRUE(Shell::Get()->app_list_controller()->presenter()->IsVisible());
shelf->SetAlignment(alignment);
EXPECT_EQ(AppListViewState::kClosed, GetAppListView()->app_list_state());
}
}
// Hide the expand arrow view in tablet mode when there is no activatable window
// (see https://crbug.com/923089).
TEST_F(AppListControllerImplTest, UpdateExpandArrowViewVisibility) {
......
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