Commit d0e7f5a1 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Fix HotseatAppListControllerImplTest.GetItemBoundsForWindow

Fixes the test when hotseat is enabled - the issue was that the app list
layout changes when the first test window is created (because the shelf
height changes), and the expected apps grid bounds were calculated
before a test window existed.

BUG=1016822

Change-Id: I88881ac6b5ecf0a5b3bd02c222632d5faaf72517
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1873988Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708390}
parent 406ad20b
...@@ -466,8 +466,7 @@ INSTANTIATE_TEST_SUITE_P(, HotseatAppListControllerImplTest, testing::Bool()); ...@@ -466,8 +466,7 @@ INSTANTIATE_TEST_SUITE_P(, HotseatAppListControllerImplTest, testing::Bool());
// Tests for HomeScreenDelegate::GetInitialAppListItemScreenBoundsForWindow // Tests for HomeScreenDelegate::GetInitialAppListItemScreenBoundsForWindow
// implemtenation. // implemtenation.
// Disabled due to crbug.com/1016843 TEST_P(HotseatAppListControllerImplTest, GetItemBoundsForWindow) {
TEST_F(AppListControllerImplTest, DISABLED_GetItemBoundsForWindow) {
// Populate app list model with 25 items, of which items at indices in // Populate app list model with 25 items, of which items at indices in
// |folders| are folders containing a single item. // |folders| are folders containing a single item.
const std::set<int> folders = {5, 23}; const std::set<int> folders = {5, 23};
...@@ -514,14 +513,18 @@ TEST_F(AppListControllerImplTest, DISABLED_GetItemBoundsForWindow) { ...@@ -514,14 +513,18 @@ TEST_F(AppListControllerImplTest, DISABLED_GetItemBoundsForWindow) {
{"", base::nullopt}, {"", base::nullopt},
{"fake_id_22", base::nullopt}}; {"fake_id_22", base::nullopt}};
// Tests the case app ID property is not set on the window.
std::unique_ptr<aura::Window> window_without_app_id(CreateTestWindow());
HomeScreenDelegate* const home_screen_delegate = HomeScreenDelegate* const home_screen_delegate =
Shell::Get()->home_screen_controller()->delegate(); Shell::Get()->home_screen_controller()->delegate();
// NOTE: Calculate the apps grid bounds after test window is shown, as showing
// the window can change the app list layout (due to the change in the shelf
// height).
const gfx::Rect apps_grid_bounds = apps_grid_view->GetBoundsInScreen(); const gfx::Rect apps_grid_bounds = apps_grid_view->GetBoundsInScreen();
const gfx::Rect apps_grid_center = const gfx::Rect apps_grid_center =
gfx::Rect(apps_grid_bounds.CenterPoint(), gfx::Size(1, 1)); gfx::Rect(apps_grid_bounds.CenterPoint(), gfx::Size(1, 1));
// Tests the case app ID property is not set on the window.
std::unique_ptr<aura::Window> window_without_app_id(CreateTestWindow());
EXPECT_EQ(apps_grid_center, EXPECT_EQ(apps_grid_center,
home_screen_delegate->GetInitialAppListItemScreenBoundsForWindow( home_screen_delegate->GetInitialAppListItemScreenBoundsForWindow(
window_without_app_id.get())); window_without_app_id.get()));
......
...@@ -2905,6 +2905,9 @@ gfx::Rect AppsGridView::GetExpectedItemBoundsInFirstPage( ...@@ -2905,6 +2905,9 @@ gfx::Rect AppsGridView::GetExpectedItemBoundsInFirstPage(
return gfx::Rect(GetContentsBounds().CenterPoint(), gfx::Size(1, 1)); return gfx::Rect(GetContentsBounds().CenterPoint(), gfx::Size(1, 1));
const int model_index = GetModelIndexOfItem(item); const int model_index = GetModelIndexOfItem(item);
if (model_index >= view_model_.view_size())
return gfx::Rect(GetContentsBounds().CenterPoint(), gfx::Size(1, 1));
const GridIndex grid_index = GetIndexFromModelIndex(model_index); const GridIndex grid_index = GetIndexFromModelIndex(model_index);
if (grid_index.page != 0) if (grid_index.page != 0)
return gfx::Rect(GetContentsBounds().CenterPoint(), gfx::Size(1, 1)); return gfx::Rect(GetContentsBounds().CenterPoint(), gfx::Size(1, 1));
......
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