Commit 71eb478f authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Better handle overview start cancellation

AppListControllerImpl: if overview mode starting animation was
canceled, the overview is about to start exiting, so update app list
visibility accordingly - app list will not be occluded by overview, so
its visibility should be determined by whether any windows are
visible (this avoids changing the app list visibility to false for a
moment before overview exit starts).

In ShelfLayoutManager do not reset workspace update blockers as another
overview animation is about to start.

BUG=1024510

Change-Id: Ia5ac80f394a1d977c25b3dcac9cdae89c93dae16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1914532Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715495}
parent 67831772
......@@ -640,7 +640,8 @@ void AppListControllerImpl::OnOverviewModeStartingAnimationComplete(
bool canceled) {
if (!IsTabletMode())
return;
OnHomeLauncherAnimationComplete(false /* shown */, last_visible_display_id_);
OnHomeLauncherAnimationComplete(canceled && !HasVisibleWindows() /* shown */,
last_visible_display_id_);
}
void AppListControllerImpl::OnOverviewModeEnding(OverviewSession* session) {
......
......@@ -874,6 +874,10 @@ void ShelfLayoutManager::OnOverviewModeStarting() {
void ShelfLayoutManager::OnOverviewModeStartingAnimationComplete(
bool canceled) {
// If transition is canceled, keep work area updates suspended, as new
// overview transition is about to start.
if (canceled)
return;
overview_suspend_work_area_update_.reset();
}
......@@ -882,6 +886,10 @@ void ShelfLayoutManager::OnOverviewModeEnding(OverviewSession* session) {
}
void ShelfLayoutManager::OnOverviewModeEndingAnimationComplete(bool canceled) {
// If transition is canceled, keep work area updates suspended, as new
// overview transition is about to start.
if (canceled)
return;
overview_suspend_work_area_update_.reset();
}
......
......@@ -4135,6 +4135,148 @@ TEST_P(HotseatShelfLayoutManagerTest, InAppToHomeChangesStateOnce) {
}
}
// Tests that transitioning from overview to home while a transition from home
// to overview is still in progress ends up with hotseat in kShown state (and in
// app shelf not visible).
TEST_P(HotseatShelfLayoutManagerTest, HomeToOverviewAndBack) {
GetPrimaryShelf()->SetAutoHideBehavior(GetParam());
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
WindowState::Get(window.get())->Minimize();
// Start going to overview - hotseat should transition to extended state.
HotseatStateWatcher watcher(GetShelfLayoutManager());
{
gfx::Point overview_button_center = GetPrimaryShelf()
->shelf_widget()
->status_area_widget()
->overview_button_tray()
->GetBoundsInScreen()
.CenterPoint();
ui::ScopedAnimationDurationScaleMode regular_animations(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
GetEventGenerator()->GestureTapAt(overview_button_center);
watcher.CheckEqual({HotseatState::kExtended});
}
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
views::View* home_button = GetPrimaryShelf()->shelf_widget()->GetHomeButton();
GetEventGenerator()->GestureTapAt(
home_button->GetBoundsInScreen().CenterPoint());
GetAppListTestHelper()->CheckVisibility(true);
EXPECT_FALSE(overview_controller->InOverviewSession());
EXPECT_FALSE(ShelfConfig::Get()->is_in_app());
watcher.CheckEqual({HotseatState::kExtended, HotseatState::kShown});
}
TEST_P(HotseatShelfLayoutManagerTest, InAppToOverviewAndBack) {
GetPrimaryShelf()->SetAutoHideBehavior(GetParam());
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
// Start watching hotseat state before swipping up the shelf, so hotseat
// change expectation match for both auto-hidden and always-shown shelf.
HotseatStateWatcher watcher(GetShelfLayoutManager());
// Make sure shelf (and overview button) are visible - this is moves the
// hotseat into kExtended state.
if (GetParam() == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS)
SwipeUpOnShelf();
gfx::Point overview_button_center = GetPrimaryShelf()
->shelf_widget()
->status_area_widget()
->overview_button_tray()
->GetBoundsInScreen()
.CenterPoint();
// Start going to overview - use non zero animation so transition is not
// immediate.
{
ui::ScopedAnimationDurationScaleMode regular_animations(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
GetEventGenerator()->GestureTapAt(overview_button_center);
}
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
GetAppListTestHelper()->CheckVisibility(false);
// Hotseat should be extended as overview is starting.
watcher.CheckEqual({HotseatState::kExtended});
// Tapping overview button again should go back to the app window.
GetEventGenerator()->GestureTapAt(overview_button_center);
EXPECT_FALSE(overview_controller->InOverviewSession());
GetAppListTestHelper()->CheckVisibility(false);
EXPECT_TRUE(ShelfConfig::Get()->is_in_app());
// The hotseat is expected to be hidden.
watcher.CheckEqual({HotseatState::kExtended, HotseatState::kHidden});
}
// Tests transition to home screen initiated while transition from app window to
// overview is in progress.
TEST_P(HotseatShelfLayoutManagerTest, GoHomeDuringInAppToOverviewTransition) {
GetPrimaryShelf()->SetAutoHideBehavior(GetParam());
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
// Start watching hotseat state before swipping up the shelf, so hotseat
// change expectation match for both auto-hidden and always-shown shelf.
HotseatStateWatcher watcher(GetShelfLayoutManager());
// Make sure shelf (and overview button) are visible - this is moves the
// hotseat into kExtended state.
if (GetParam() == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS)
SwipeUpOnShelf();
gfx::Point overview_button_center = GetPrimaryShelf()
->shelf_widget()
->status_area_widget()
->overview_button_tray()
->GetBoundsInScreen()
.CenterPoint();
// Start going to overview - use non zero animation so transition is not
// immediate.
{
ui::ScopedAnimationDurationScaleMode regular_animations(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
GetEventGenerator()->GestureTapAt(overview_button_center);
}
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
GetAppListTestHelper()->CheckVisibility(false);
// Hotseat should be extended as overview is starting.
watcher.CheckEqual({HotseatState::kExtended});
// Press home button - expect transition to home (with hotseat in kShown
// state, and in app shelf hidden).
views::View* home_button = GetPrimaryShelf()->shelf_widget()->GetHomeButton();
GetEventGenerator()->GestureTapAt(
home_button->GetBoundsInScreen().CenterPoint());
GetAppListTestHelper()->CheckVisibility(true);
EXPECT_FALSE(overview_controller->InOverviewSession());
EXPECT_FALSE(ShelfConfig::Get()->is_in_app());
watcher.CheckEqual({HotseatState::kExtended, HotseatState::kShown});
}
// Tests that in-app -> overview results in only one state change with an
// autohidden shelf.
TEST_F(HotseatShelfLayoutManagerTest,
......
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