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

Edge case where shelf background is not reshown for hotseat transition

Fixes an edge case where opaque shelf background doesn't get reshown
after it's hidden for transition from home screen.
The opaque background is hidden when transition from kShown hotseat
state starts, and reshown once it ends. In both cases ShelfView checks
the original hotseat state to determine whether the opaque background
state should be updated.

This does not work if the original hotseat transition is interrupted by
another hotseat state change (to kShown state, as only transitions
from/to shown state are animated) - in this case hosteat transition
animator stops observing implicit animations before it updates the
animating backgrounf transform, so it doesn't send the end notification
for initial transition. Once the second animation finishes, the shelf
widget delegate will only see the end notification for the second
transition, and given the hotseat state is not kShown, it will not
update the opaque background visibility.

(If the user exits tablet mode before going to home screen again, they
will see completely transparent shelf).

BUG=1044751

Change-Id: I07e15126215c908831ad24b4aeb525eb2ef66513
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032008Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737216}
parent bb207f67
...@@ -401,7 +401,10 @@ void ShelfWidget::DelegateView::OnHotseatTransitionAnimationEnded( ...@@ -401,7 +401,10 @@ void ShelfWidget::DelegateView::OnHotseatTransitionAnimationEnded(
HotseatState from_state, HotseatState from_state,
HotseatState to_state) { HotseatState to_state) {
ShowAnimatingBackground(false); ShowAnimatingBackground(false);
if (from_state == HotseatState::kShown) // NOTE: The from and to state may not match the transition states for which
// the background was hidden (if the original animation got interrupted by
// another transition, only the later animation end will be reported).
if (hide_background_for_transitions_)
ShowOpaqueBackground(); ShowOpaqueBackground();
} }
......
...@@ -530,6 +530,68 @@ TEST_F(ShelfWidgetTest, ScreenLockStopsHotseatTransitionAnimation) { ...@@ -530,6 +530,68 @@ TEST_F(ShelfWidgetTest, ScreenLockStopsHotseatTransitionAnimation) {
gfx::Rect(360, 18, 80, 4)); gfx::Rect(360, 18, 80, 4));
} }
// Tests the shelf widget's opaque background gets reshown if hotseat transition
// from kShown state gets interrupted by a transition back to kShown state.
TEST_F(ShelfWidgetTest,
OpaqueBackgroundReshownAfterTransitionFromHomeChangesBackToHome) {
Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true);
UpdateDisplay("800x800");
ASSERT_FALSE(GetShelfWidget()->GetDragHandle()->GetVisible());
ASSERT_FALSE(GetShelfWidget()->GetOpaqueBackground()->visible());
ui::ScopedAnimationDurationScaleMode non_zero_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// Create a window to transition to the in-app shelf.
auto window = AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 800, 800));
ASSERT_FALSE(GetShelfWidget()->GetDragHandle()->GetVisible());
ASSERT_FALSE(GetShelfWidget()->GetOpaqueBackground()->visible());
ASSERT_TRUE(GetShelfWidget()->GetAnimatingBackground()->visible());
ASSERT_TRUE(GetShelfWidget()
->GetAnimatingBackground()
->GetAnimator()
->is_animating());
const gfx::Rect animating_background_bounds =
GetShelfWidget()->GetAnimatingBackground()->bounds();
EXPECT_NE(GetShelfWidget()->GetAnimatingBackground()->transform(),
GetShelfWidget()->GetAnimatingBackground()->GetTargetTransform());
EXPECT_EQ(gfx::Transform(),
GetShelfWidget()->GetAnimatingBackground()->GetTargetTransform());
// Go back home before the transition to in-app shelf finishes.
window->Hide();
// The shelf background should still be animating at this point, but to
// different bounds.
ASSERT_FALSE(GetShelfWidget()->GetDragHandle()->GetVisible());
ASSERT_FALSE(GetShelfWidget()->GetOpaqueBackground()->visible());
ASSERT_TRUE(GetShelfWidget()->GetAnimatingBackground()->visible());
ASSERT_TRUE(GetShelfWidget()
->GetAnimatingBackground()
->GetAnimator()
->is_animating());
EXPECT_NE(animating_background_bounds,
GetShelfWidget()->GetAnimatingBackground()->bounds());
EXPECT_EQ(gfx::Transform(),
GetShelfWidget()->GetAnimatingBackground()->GetTargetTransform());
// Run the current animation to the end, end verify the opaque background is
// reshown after ending tablet mode.
GetShelfWidget()->GetAnimatingBackground()->GetAnimator()->StopAnimating();
ASSERT_FALSE(GetShelfWidget()->GetDragHandle()->GetVisible());
ASSERT_FALSE(GetShelfWidget()->GetOpaqueBackground()->visible());
ASSERT_FALSE(GetShelfWidget()->GetAnimatingBackground()->visible());
Shell::Get()->tablet_mode_controller()->SetEnabledForTest(false);
EXPECT_FALSE(GetShelfWidget()->GetDragHandle()->GetVisible());
ASSERT_TRUE(GetShelfWidget()->GetOpaqueBackground()->visible());
ASSERT_FALSE(GetShelfWidget()->GetAnimatingBackground()->visible());
}
class ShelfWidgetAfterLoginTest : public AshTestBase { class ShelfWidgetAfterLoginTest : public AshTestBase {
public: public:
ShelfWidgetAfterLoginTest() { set_start_session(false); } ShelfWidgetAfterLoginTest() { set_start_session(false); }
......
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