Commit cf57e8b1 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

Fix BrowserActionContainer chevron visibility regression

https://codereview.chromium.org/476873002 introduced a regression where
shrinking the size of the extensions toolbar to 0 would not show the chevron
anymore.  Fix the regression, and add a test so it doesn't happen again.

BUG=407134

Review URL: https://codereview.chromium.org/492503004

Cr-Commit-Position: refs/heads/master@{#291754}
parent 8125f1d1
...@@ -318,7 +318,10 @@ void BrowserActionsContainer::RemoveObserver( ...@@ -318,7 +318,10 @@ void BrowserActionsContainer::RemoveObserver(
} }
gfx::Size BrowserActionsContainer::GetPreferredSize() const { gfx::Size BrowserActionsContainer::GetPreferredSize() const {
size_t icon_count = GetIconCount(); // Note: We can't use GetIconCount() for the main bar, since we may also
// have to include items that are in the chevron's overflow.
size_t icon_count =
in_overflow_mode() ? GetIconCount() : browser_action_views_.size();
// If there are no actions to show, or we are in overflow mode and the main // If there are no actions to show, or we are in overflow mode and the main
// container is already showing them all, then no further work is required. // container is already showing them all, then no further work is required.
......
...@@ -217,6 +217,18 @@ IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, Visibility) { ...@@ -217,6 +217,18 @@ IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, Visibility) {
EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
EXPECT_EQ(idA, browser_actions_bar()->GetExtensionId(0)); EXPECT_EQ(idA, browser_actions_bar()->GetExtensionId(0));
// Shrink the browser actions bar to zero visible icons.
// No icons should be visible, but we *should* show the chevron and have a
// non-empty size.
browser_actions_bar()->SetIconVisibilityCount(0);
EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions());
BrowserActionsContainer* container =
BrowserView::GetBrowserViewForBrowser(browser())
->toolbar()->browser_actions();
ASSERT_TRUE(container->chevron());
EXPECT_TRUE(container->chevron()->visible());
EXPECT_FALSE(container->GetPreferredSize().IsEmpty());
} }
IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, ForceHide) { IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, ForceHide) {
......
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