Commit c31cb125 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Move notifications down when lower notifications fade out

Need to move notifications down whenever there is free space below.

Bug: 920110
Change-Id: Ib49a4e22ee1cbb287095125fc29c623e47d20339
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1638142Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668427}
parent ae5abd88
......@@ -239,18 +239,15 @@ void MessagePopupCollection::TransitionFromAnimation() {
// If the animation is finished, transition to IDLE.
state_ = State::IDLE;
} else if (state_ == State::FADE_OUT && !popup_items_.empty()) {
if ((HasAddedPopup() && CollapseAllPopups()) || !inverse_) {
// If FADE_OUT animation is finished and we still have remaining popups,
// we have to MOVE_DOWN them.
// If we're going to add a new popup after this MOVE_DOWN, do the collapse
// animation at the same time. Otherwise it will take another MOVE_DOWN.
if (HasAddedPopup())
CollapseAllPopups();
// If FADE_OUT animation is finished and we still have remaining popups,
// we have to MOVE_DOWN them.
state_ = State::MOVE_DOWN;
MoveDownPopups();
} else {
// If there's no collapsable popups and |inverse_| is on, there's nothing
// to do after FADE_OUT.
state_ = State::IDLE;
}
} else if (state_ == State::MOVE_UP_FOR_INVERSE) {
for (auto& item : popup_items_)
item.is_animating = item.will_fade_in;
......
......@@ -585,6 +585,9 @@ TEST_F(MessagePopupCollectionTest, NotificationsMoveUpForInverse) {
EXPECT_EQ(ids[1], GetPopup(ids[1])->id());
EXPECT_TRUE(IsAnimating());
// MOVE_DOWN
AnimateToEnd();
gfx::Rect before = GetPopup(ids[1])->GetBoundsInScreen();
// MOVE_UP_FOR_INVERSE
......@@ -610,6 +613,44 @@ TEST_F(MessagePopupCollectionTest, NotificationsMoveUpForInverse) {
EXPECT_FALSE(IsAnimating());
}
TEST_F(MessagePopupCollectionTest, NotificationsMoveDownForEmptySpace) {
popup_collection()->set_inverse();
std::vector<std::string> ids;
for (size_t i = 0; i < kMaxVisiblePopupNotifications; ++i)
ids.push_back(AddNotification());
AnimateUntilIdle();
EXPECT_EQ(kMaxVisiblePopupNotifications, GetPopupCounts());
EXPECT_FALSE(IsAnimating());
// Dismiss bottom most notification
gfx::Rect dismissed = GetPopup(ids.back())->GetBoundsInScreen();
MessageCenter::Get()->MarkSinglePopupAsShown(ids.back(), false);
// FADE_OUT
AnimateToMiddle();
EXPECT_GT(1.0f, GetPopup(ids.back())->GetOpacity());
EXPECT_EQ(ids[2], GetPopup(ids.back())->id());
AnimateToEnd();
EXPECT_EQ(ids[1], GetPopup(ids[1])->id());
gfx::Rect before = GetPopup(ids[1])->GetBoundsInScreen();
// MOVE_DOWN
AnimateToMiddle();
gfx::Rect moving = GetPopup(ids[1])->GetBoundsInScreen();
EXPECT_GT(moving.bottom(), before.bottom());
EXPECT_GT(dismissed.bottom(), moving.bottom());
AnimateToEnd();
gfx::Rect after = GetPopup(ids[1])->GetBoundsInScreen();
EXPECT_EQ(after, dismissed);
EXPECT_FALSE(IsAnimating());
}
TEST_F(MessagePopupCollectionTest, PopupResized) {
std::vector<std::string> ids;
for (size_t i = 0; i < kMaxVisiblePopupNotifications; ++i)
......
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