Commit 14763b9f authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Update shelf state when shelf config changes

Shelf config change may cause hotseat state change, so we should update
the hotseat state (which is done in ShelfLayoutManager::SetState) when
the shelf config changes, otherwise, the hotseat state change may lag
behind the shelf layout change.

For example, layout may hide the opaque shelf background if config
changes to non-in-app shelf, and animating background animation starts
when the hotseat state changes. So, if the hotseat state change lags
after the shelf layout change for long enough, we might see a flash of
animating shelf background after the opaque shelf background has been
hidden.

This was noticed while implementing swipe to overview/home with VK
shown (when swiping to go home, the animating shelf would occasionally
pop up with a delay) - added a test for sequence of events in that case.

(Note that this means that the hotseat state may get calculated before
app list visibility on tablet mode change, so add back logic that moved
hotseat in kShownHomeLauncher state if the home should be visible at
that point in time).

BUG=b:145704293

Change-Id: I4e6ce883eed8674159b03c25336fd82c9d20c50d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090757
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747552}
parent f4a513cb
......@@ -1136,6 +1136,7 @@ float ShelfLayoutManager::GetOpacity() const {
}
void ShelfLayoutManager::OnShelfConfigUpdated() {
SetState(state_.visibility_state);
LayoutShelf(/*animate=*/true);
MaybeUpdateShelfBackground(AnimationChangeType::IMMEDIATE);
UpdateContextualNudges();
......@@ -1296,7 +1297,9 @@ HotseatState ShelfLayoutManager::CalculateHotseatState(
((overview_controller && overview_controller->InOverviewSession()) ||
overview_mode_will_start_) &&
!overview_controller->IsCompletingShutdownAnimations();
const bool app_list_visible = app_list_controller->GetTargetVisibility();
const bool app_list_visible =
app_list_controller->GetTargetVisibility() ||
app_list_controller->ShouldHomeLauncherBeVisible();
// TODO(https://crbug.com/1058205): Test this behavior.
if (ShelfConfig::Get()->is_virtual_keyboard_shown())
......
......@@ -19,6 +19,7 @@
#include "ash/home_screen/drag_window_from_shelf_controller_test_api.h"
#include "ash/home_screen/home_launcher_gesture_handler.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/keyboard/keyboard_controller_impl.h"
#include "ash/keyboard/ui/keyboard_ui.h"
#include "ash/keyboard/ui/keyboard_ui_controller.h"
#include "ash/keyboard/ui/keyboard_util.h"
......@@ -26,6 +27,7 @@
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_test_api.h"
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_item.h"
......@@ -37,6 +39,7 @@
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/drag_handle.h"
#include "ash/shelf/home_button.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_app_button.h"
......@@ -2835,6 +2838,69 @@ TEST_F(ShelfLayoutManagerWindowDraggingTest, FlingHomeInSplitModeWithOverview) {
InAppShelfGestures::kSwipeUpToShow, 0);
}
// Tests that hotseat transition animation is not delayed (i.e. that it happens
// as soon as shelf opaque background changes) when virtual keyboard is hidden,
// and the user swipes from shelf to home.
TEST_F(ShelfLayoutManagerWindowDraggingTest,
NoDelayedAnimatingBackgroundForTransitionFromVirtualKeyboardToHome) {
std::unique_ptr<aura::Window> window1 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window1.get());
std::unique_ptr<aura::Window> window2 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window2.get());
// Show virtual keyboard.
KeyboardController* const keyboard_controller =
Shell::Get()->keyboard_controller();
keyboard_controller->SetEnableFlag(
keyboard::KeyboardEnableFlag::kShelfEnabled);
keyboard_controller->ShowKeyboard();
// Verify the shelf state.
EXPECT_TRUE(GetShelfWidget()->GetOpaqueBackground()->visible());
EXPECT_TRUE(GetShelfWidget()->GetDragHandle()->GetVisible());
ASSERT_FALSE(GetShelfWidget()->GetAnimatingBackground()->visible());
ASSERT_FALSE(GetShelfWidget()
->GetAnimatingBackground()
->GetAnimator()
->is_animating());
EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
// Make animations not end immediately for the rest of the test (so the test
// can test whether the animating shelf background is animating).
ui::ScopedAnimationDurationScaleMode non_zero_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
const gfx::Rect shelf_widget_bounds =
GetShelfWidget()->GetWindowBoundsInScreen();
const int shelf_size = ShelfConfig::Get()->shelf_size();
const int hotseat_size = ShelfConfig::Get()->hotseat_size();
const int hotseat_padding_size = ShelfConfig::Get()->hotseat_bottom_padding();
// Simulate virtual keyboard closing, and a swipe from shelf to home.
StartScroll(shelf_widget_bounds.bottom_right());
keyboard_controller->HideKeyboard(HideReason::kUser);
UpdateScroll(-shelf_size - 3 * hotseat_size - hotseat_padding_size);
EndScroll(
true /* is_fling */,
-(DragWindowFromShelfController::kVelocityToHomeScreenThreshold + 10));
// Verify that the shelf background start animating immediately.
EXPECT_FALSE(GetShelfWidget()->GetOpaqueBackground()->visible());
EXPECT_FALSE(GetShelfWidget()->GetDragHandle()->GetVisible());
ASSERT_TRUE(GetShelfWidget()->GetAnimatingBackground()->visible());
ASSERT_TRUE(GetShelfWidget()
->GetAnimatingBackground()
->GetAnimator()
->is_animating());
keyboard_controller->ClearEnableFlag(
keyboard::KeyboardEnableFlag::kShelfEnabled);
}
// Test that if shelf if hidden or auto-hide hidden, drag window from shelf is a
// no-op.
// TODO(1024163): This test consistently crashes.
......
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