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

Fix AppListPresenterDelegateScalableAppListTest with hotseat enabled

Enabling hotseat exposes some rounding errors when calculating expected
app list layout half way during drag between peeking/half to
full-screen/closed state.

To fix this, calculate the expected search box padding using currently
reported app list transition progress (which is already checked that is
reasonably close to half state values), and gfx::Tween::IntValueBetween,
which is also the method used to determine the padding value for the
current progress app list progress.

BUG=1011920

Change-Id: I9792442aba0953f880308606d2291a98e6aac9d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1848155
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704230}
parent eace69bd
...@@ -2074,20 +2074,20 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, ...@@ -2074,20 +2074,20 @@ TEST_P(AppListPresenterDelegateScalableAppListTest,
gfx::Point(peeking_top.x(), (peeking_top.y() + fullscreen_y) / 2)); gfx::Point(peeking_top.x(), (peeking_top.y() + fullscreen_y) / 2));
GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->WaitUntilIdle();
EXPECT_LE(std::abs(GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagNone) -
1.5f),
0.01f);
gfx::Rect search_box_bounds = gfx::Rect search_box_bounds =
GetAppListView()->search_box_view()->GetBoundsInScreen(); GetAppListView()->search_box_view()->GetBoundsInScreen();
search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets()); search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets());
float progress = GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagNone);
EXPECT_LE(std::abs(progress - 1.5f), 0.01f);
EXPECT_EQ((peeking_top.y() + fullscreen_y) / 2 + EXPECT_EQ((peeking_top.y() + fullscreen_y) / 2 +
(config.search_box_peeking_top_padding() + gfx::Tween::IntValueBetween(
fullscreen_search_box_padding) / progress - 1, config.search_box_peeking_top_padding(),
2, fullscreen_search_box_padding),
search_box_bounds.y()); search_box_bounds.y());
EXPECT_EQ(ExpectedAppsGridTop(config, 900, search_box_bounds), EXPECT_EQ(ExpectedAppsGridTop(config, 900, search_box_bounds),
apps_grid_view()->GetBoundsInScreen().y()); apps_grid_view()->GetBoundsInScreen().y());
EXPECT_TRUE(apps_grid_view()->GetVisible()); EXPECT_TRUE(apps_grid_view()->GetVisible());
...@@ -2118,18 +2118,17 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, ...@@ -2118,18 +2118,17 @@ TEST_P(AppListPresenterDelegateScalableAppListTest,
gfx::Point(peeking_top.x(), (peeking_top.y() + closed_y) / 2)); gfx::Point(peeking_top.x(), (peeking_top.y() + closed_y) / 2));
GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->WaitUntilIdle();
EXPECT_LE(std::abs(GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagNone) -
0.5f),
0.01f);
search_box_bounds = GetAppListView()->search_box_view()->GetBoundsInScreen(); search_box_bounds = GetAppListView()->search_box_view()->GetBoundsInScreen();
search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets()); search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets());
progress = GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagNone);
EXPECT_LE(std::abs(progress - 0.5f), 0.01f);
EXPECT_EQ((peeking_top.y() + closed_y) / 2 + EXPECT_EQ((peeking_top.y() + closed_y) / 2 +
(config.search_box_peeking_top_padding() + gfx::Tween::IntValueBetween(
config.search_box_closed_top_padding()) / progress, config.search_box_peeking_top_padding(),
2, config.search_box_closed_top_padding()),
search_box_bounds.y()); search_box_bounds.y());
EXPECT_EQ(ExpectedAppsGridTop(config, 900, search_box_bounds), EXPECT_EQ(ExpectedAppsGridTop(config, 900, search_box_bounds),
apps_grid_view()->GetBoundsInScreen().y()); apps_grid_view()->GetBoundsInScreen().y());
...@@ -2186,19 +2185,18 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, ...@@ -2186,19 +2185,18 @@ TEST_P(AppListPresenterDelegateScalableAppListTest,
gfx::Point(half_top.x(), (half_top.y() + fullscreen_y) / 2)); gfx::Point(half_top.x(), (half_top.y() + fullscreen_y) / 2));
GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->WaitUntilIdle();
EXPECT_LE(std::abs(GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagSearchResults) -
1.5f),
0.01f);
gfx::Rect search_box_bounds = gfx::Rect search_box_bounds =
GetAppListView()->search_box_view()->GetBoundsInScreen(); GetAppListView()->search_box_view()->GetBoundsInScreen();
search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets()); search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets());
float progress = GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagSearchResults);
EXPECT_LE(std::abs(progress - 1.5f), 0.01f);
EXPECT_EQ((half_top.y() + fullscreen_y) / 2 + EXPECT_EQ((half_top.y() + fullscreen_y) / 2 +
(config.search_box_fullscreen_top_padding() + gfx::Tween::IntValueBetween(
fullscreen_search_box_padding) / progress - 1, config.search_box_fullscreen_top_padding(),
2, fullscreen_search_box_padding),
search_box_bounds.y()); search_box_bounds.y());
EXPECT_EQ(search_box_bounds.y(), EXPECT_EQ(search_box_bounds.y(),
search_result_page()->GetBoundsInScreen().y()); search_result_page()->GetBoundsInScreen().y());
...@@ -2243,18 +2241,18 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, ...@@ -2243,18 +2241,18 @@ TEST_P(AppListPresenterDelegateScalableAppListTest,
// should be half distance between closed and peeking padding. // should be half distance between closed and peeking padding.
generator->MoveTouch(gfx::Point(half_top.x(), (half_top.y() + closed_y) / 2)); generator->MoveTouch(gfx::Point(half_top.x(), (half_top.y() + closed_y) / 2));
GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->WaitUntilIdle();
EXPECT_LE(std::abs(GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagSearchResults) - progress = GetAppListView()->GetAppListTransitionProgress(
0.5f), AppListView::kProgressFlagSearchResults);
0.01f); EXPECT_LE(std::abs(progress - 0.5f), 0.01f);
search_box_bounds = GetAppListView()->search_box_view()->GetBoundsInScreen(); search_box_bounds = GetAppListView()->search_box_view()->GetBoundsInScreen();
search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets()); search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets());
EXPECT_EQ((half_top.y() + closed_y) / 2 + EXPECT_EQ((half_top.y() + closed_y) / 2 +
(config.search_box_fullscreen_top_padding() + gfx::Tween::IntValueBetween(
config.search_box_closed_top_padding()) / progress, config.search_box_fullscreen_top_padding(),
2, config.search_box_closed_top_padding()),
search_box_bounds.y()); search_box_bounds.y());
EXPECT_EQ(search_box_bounds.y(), EXPECT_EQ(search_box_bounds.y(),
search_result_page()->GetBoundsInScreen().y()); search_result_page()->GetBoundsInScreen().y());
...@@ -2332,10 +2330,13 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageDuringDrag) { ...@@ -2332,10 +2330,13 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageDuringDrag) {
GetAppListView()->search_box_view()->GetBoundsInScreen(); GetAppListView()->search_box_view()->GetBoundsInScreen();
search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets()); search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets());
float progress = GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagSearchResults);
EXPECT_LE(std::abs(progress - 1.5f), 0.01f);
EXPECT_EQ((half_top.y() + fullscreen_y) / 2 + EXPECT_EQ((half_top.y() + fullscreen_y) / 2 +
(config.search_box_fullscreen_top_padding() + gfx::Tween::IntValueBetween(
fullscreen_search_box_padding) / progress - 1, config.search_box_fullscreen_top_padding(),
2, fullscreen_search_box_padding),
search_box_bounds.y()); search_box_bounds.y());
EXPECT_EQ(search_box_bounds.y(), EXPECT_EQ(search_box_bounds.y(),
search_result_page()->GetBoundsInScreen().y()); search_result_page()->GetBoundsInScreen().y());
...@@ -2392,10 +2393,13 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageDuringDrag) { ...@@ -2392,10 +2393,13 @@ TEST_P(AppListPresenterDelegateScalableAppListTest, SwitchPageDuringDrag) {
search_box_bounds = GetAppListView()->search_box_view()->GetBoundsInScreen(); search_box_bounds = GetAppListView()->search_box_view()->GetBoundsInScreen();
search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets()); search_box_bounds.Inset(GetAppListView()->search_box_view()->GetInsets());
progress = GetAppListView()->GetAppListTransitionProgress(
AppListView::kProgressFlagSearchResults);
EXPECT_LE(std::abs(progress - 1.5f), 0.01f);
EXPECT_EQ((half_top.y() + fullscreen_y) / 2 + EXPECT_EQ((half_top.y() + fullscreen_y) / 2 +
(config.search_box_fullscreen_top_padding() + gfx::Tween::IntValueBetween(
fullscreen_search_box_padding) / progress - 1, config.search_box_fullscreen_top_padding(),
2, fullscreen_search_box_padding),
search_box_bounds.y()); search_box_bounds.y());
EXPECT_EQ(search_box_bounds.y(), EXPECT_EQ(search_box_bounds.y(),
search_result_page()->GetBoundsInScreen().y()); search_result_page()->GetBoundsInScreen().y());
......
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