Commit 6f8585d0 authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Fix crash for showing app list in invalid display

Changes:
Fix the crash by doing early return when no root window exists for the
specified display.

Bug: 903293
Test: AppListPresenterDelegateTest.ShowInInvalidDisplay
Change-Id: I866f07e037c269851ab6c72fff622a0c7c27a4ac
Reviewed-on: https://chromium-review.googlesource.com/c/1341000
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609367}
parent 0ff6e692
...@@ -1088,6 +1088,13 @@ TEST_F(AppListPresenterDelegateTest, SearchBoxShownOnSmallDisplay) { ...@@ -1088,6 +1088,13 @@ TEST_F(AppListPresenterDelegateTest, SearchBoxShownOnSmallDisplay) {
EXPECT_LE(0, view->GetWidget()->GetNativeView()->bounds().y()); EXPECT_LE(0, view->GetWidget()->GetNativeView()->bounds().y());
} }
// Tests that no crash occurs after an attempt to show app list in an invalid
// display.
TEST_F(AppListPresenterDelegateTest, ShowInInvalidDisplay) {
GetAppListTestHelper()->ShowAndRunLoop(display::kInvalidDisplayId);
GetAppListTestHelper()->CheckState(app_list::AppListViewState::CLOSED);
}
// Test a variety of behaviors for home launcher (app list in tablet mode). // Test a variety of behaviors for home launcher (app list in tablet mode).
class AppListPresenterDelegateHomeLauncherTest class AppListPresenterDelegateHomeLauncherTest
: public AppListPresenterDelegateTest { : public AppListPresenterDelegateTest {
......
...@@ -126,6 +126,11 @@ void AppListPresenterImpl::Show(int64_t display_id, ...@@ -126,6 +126,11 @@ void AppListPresenterImpl::Show(int64_t display_id,
return; return;
} }
if (!delegate_->GetRootWindowForDisplayId(display_id)) {
LOG(ERROR) << "Root window does not exist for display: " << display_id;
return;
}
is_visible_ = true; is_visible_ = true;
RequestPresentationTime(display_id, event_time_stamp); RequestPresentationTime(display_id, event_time_stamp);
......
...@@ -70,7 +70,7 @@ class AppListPresenterDelegateTest : public AppListPresenterDelegate { ...@@ -70,7 +70,7 @@ class AppListPresenterDelegateTest : public AppListPresenterDelegate {
bool IsHomeLauncherEnabledInTabletMode() override { return false; } bool IsHomeLauncherEnabledInTabletMode() override { return false; }
bool GetOnScreenKeyboardShown() override { return false; } bool GetOnScreenKeyboardShown() override { return false; }
aura::Window* GetRootWindowForDisplayId(int64_t display_id) override { aura::Window* GetRootWindowForDisplayId(int64_t display_id) override {
return nullptr; return container_->GetRootWindow();
} }
void OnVisibilityChanged(bool visible, aura::Window* root_window) override {} void OnVisibilityChanged(bool visible, aura::Window* root_window) override {}
void OnTargetVisibilityChanged(bool visible) override {} void OnTargetVisibilityChanged(bool visible) override {}
......
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