Commit a01da5a4 authored by Tim Song's avatar Tim Song Committed by Commit Bot

Ash Tray: Update calculations for collapsing message center.

The current calculation for collapsing the message center when expanding the
quick settings is not the same as the calculation when creating the message
center. These should be consistent.

Additionally, the current calculation for the expanded quick settings height is
not correct either.

TEST=manual
BUG=1019926

Change-Id: I7ba344af148bea12ccaaf431c4b52c151f2b58ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891757Reviewed-by: default avatarAhmed Mehfooz <amehfooz@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712198}
parent c3f06af2
......@@ -214,6 +214,10 @@ void PageIndicatorView::SetExpandedAmount(double expanded_amount) {
layer()->SetOpacity(std::max(0., 6 * expanded_amount_ - 5.));
}
int PageIndicatorView::GetExpandedHeight() {
return buttons_container_->GetPreferredSize().height();
}
void PageIndicatorView::TotalPagesChanged(int previous_page_count,
int new_page_count) {
DCHECK(model_);
......
......@@ -29,6 +29,9 @@ class ASH_EXPORT PageIndicatorView : public views::View,
// Otherwise, it shows an intermediate state while animating.
void SetExpandedAmount(double expanded_amount);
// Returns the height of this view when the tray is fully expanded.
int GetExpandedHeight();
// views::View:
gfx::Size CalculatePreferredSize() const override;
void Layout() override;
......
......@@ -168,9 +168,13 @@ void UnifiedSystemTrayController::ToggleExpanded() {
if (bubble_)
bubble_->ExpandMessageCenter();
} else {
// Collapse the message center if screen height is limited.
// Collapse the message center if screen height is limited after expanding
// the quick settings to its full height.
// Note: This calculaton should be the same as
// UnifiedMessageCenterBubble::CalculateAvailableHeight().
if (bubble_ && bubble_->CalculateMaxHeight() -
unified_view_->GetExpandedSystemTrayHeight() <=
unified_view_->GetExpandedSystemTrayHeight() -
kUnifiedMessageCenterBubbleSpacing <
kMessageCenterCollapseThreshold) {
bubble_->CollapseMessageCenter();
}
......
......@@ -123,6 +123,8 @@ TEST_F(UnifiedSystemTrayControllerTest, ToggleExpanded) {
const int collapsed_height = view()->GetPreferredSize().height();
EXPECT_LT(collapsed_height, expanded_height);
EXPECT_FALSE(model()->IsExpandedOnOpen());
EXPECT_EQ(expanded_height, view()->GetExpandedSystemTrayHeight());
}
TEST_F(UnifiedSystemTrayControllerTest, EnsureExpanded_UserChooserShown) {
......
......@@ -426,7 +426,7 @@ int UnifiedSystemTrayView::GetExpandedSystemTrayHeight() const {
: 0) +
top_shortcuts_view_->GetPreferredSize().height() +
feature_pods_container_->GetExpandedHeight() +
page_indicator_view_->GetPreferredSize().height() +
page_indicator_view_->GetExpandedHeight() +
sliders_container_->GetExpandedHeight() +
system_info_view_->GetPreferredSize().height();
}
......
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