Commit 71135040 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: The window selector item close button is not properly updated.

Test: manual
Bug: 871985
Change-Id: I3747ce934f186acd677252ce22d748f4fe853907
Reviewed-on: https://chromium-review.googlesource.com/1166326
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581902}
parent 6d46d04b
......@@ -347,13 +347,16 @@ class WindowSelectorItem::CaptionContainerView : public views::View {
gfx::Rect backdrop_bounds() const { return backdrop_bounds_; }
void SetHeaderVisibility(HeaderVisibility visibility) {
DCHECK(close_button_->layer());
DCHECK(header_view_->layer());
// Set the close button invisible if the rest of the header is to be shown.
// If the rest of the header is to be hidden, set the close visiblilty to
// true as |header_view_|'s opacity will be 0.f, hiding the close button.
close_button_->SetVisible(visibility !=
HeaderVisibility::kCloseButtonInvisibleOnly);
// Make the close button invisible if the rest of the header is to be shown.
// If the rest of the header is to be hidden, make the close button visible
// as |header_view_|'s opacity will be 0.f, hiding the close button. Modify
// |close_button_|'s opacity instead of visibilty so the flex from its
// sibling views do not mess up its layout.
close_button_->layer()->SetOpacity(
visibility == HeaderVisibility::kCloseButtonInvisibleOnly ? 0.f : 1.f);
const bool visible = visibility != HeaderVisibility::kInvisible;
AnimateLayerOpacity(header_view_->layer(), visible);
}
......@@ -917,8 +920,8 @@ OverviewAnimationType WindowSelectorItem::GetExitTransformAnimationType() {
: OVERVIEW_ANIMATION_RESTORE_WINDOW_ZERO;
}
bool WindowSelectorItem::GetCloseButtonVisibilityForTesting() const {
return close_button_->visible();
float WindowSelectorItem::GetCloseButtonVisibilityForTesting() const {
return close_button_->layer()->opacity();
}
float WindowSelectorItem::GetTitlebarOpacityForTesting() const {
......
......@@ -238,7 +238,7 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
bool animating_to_close() const { return animating_to_close_; }
void set_animating_to_close(bool val) { animating_to_close_ = val; }
bool GetCloseButtonVisibilityForTesting() const;
float GetCloseButtonVisibilityForTesting() const;
float GetTitlebarOpacityForTesting() const;
gfx::Rect GetShadowBoundsForTesting();
......
......@@ -2541,16 +2541,17 @@ TEST_F(WindowSelectorTest, WindowItemTitleCloseVisibilityOnDrag) {
WindowSelectorItem* item1 = GetWindowItemForWindow(0, window1.get());
WindowSelectorItem* item2 = GetWindowItemForWindow(0, window2.get());
// Start the drag on |item1|. Verify the dragged item, |item1| has both the
// close button and titlebar hidden. All other items, |item2| should only have
// the close button hidden.
// close button and titlebar hidden. The close button opacity however is
// opaque as its a child of the header which handles fading away the whole
// header. All other items, |item2| should only have the close button hidden.
ui::test::EventGenerator* generator = GetEventGenerator();
generator->MoveMouseTo(item1->target_bounds().CenterPoint());
generator->PressLeftButton();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0.f, item1->GetTitlebarOpacityForTesting());
EXPECT_TRUE(item1->GetCloseButtonVisibilityForTesting());
EXPECT_EQ(1.f, item1->GetCloseButtonVisibilityForTesting());
EXPECT_EQ(1.f, item2->GetTitlebarOpacityForTesting());
EXPECT_FALSE(item2->GetCloseButtonVisibilityForTesting());
EXPECT_EQ(0.f, item2->GetCloseButtonVisibilityForTesting());
// Drag |item1| in a way so that |window1| does not get activated (drags
// within a certain threshold count as clicks). Verify the close button and
......@@ -2559,9 +2560,9 @@ TEST_F(WindowSelectorTest, WindowItemTitleCloseVisibilityOnDrag) {
generator->ReleaseLeftButton();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1.f, item1->GetTitlebarOpacityForTesting());
EXPECT_TRUE(item1->GetCloseButtonVisibilityForTesting());
EXPECT_EQ(1.f, item1->GetCloseButtonVisibilityForTesting());
EXPECT_EQ(1.f, item2->GetTitlebarOpacityForTesting());
EXPECT_TRUE(item2->GetCloseButtonVisibilityForTesting());
EXPECT_EQ(1.f, item2->GetCloseButtonVisibilityForTesting());
}
// Tests that overview widgets are stacked in the correct order.
......
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