Commit dea3a2af authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Pre-refresh cleanup for tab_strip.cc.

Fixes tests broken in Touchable Refresh and changes them from being tested in
Touchable to Touchable Refresh.

Also does some other cleanups.  This does not remove flags added during refresh
(e.g. NTB position); those will be added separately.

Bug: 814847
Change-Id: I8c31a0421c65c4cd46f287d9e67aa17645089703
Reviewed-on: https://chromium-review.googlesource.com/1232882Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592529}
parent cb130794
...@@ -49,8 +49,8 @@ class NewTabButton : public views::ImageButton, ...@@ -49,8 +49,8 @@ class NewTabButton : public views::ImageButton,
void CloseBubble(); void CloseBubble();
// Called when the tab strip transitions to/from single tab mode, the frame // Called when the tab strip transitions to/from single tab mode, the frame
// state changes or the accent color changes. Under Refresh this function will // state changes or the accent color changes. Updates the glyph colors for
// update the glyph colors for the best contrast on the background. // the best contrast on the background.
void FrameColorsChanged(); void FrameColorsChanged();
void AnimateInkDropToStateForTesting(views::InkDropState state); void AnimateInkDropToStateForTesting(views::InkDropState state);
...@@ -82,7 +82,7 @@ class NewTabButton : public views::ImageButton, ...@@ -82,7 +82,7 @@ class NewTabButton : public views::ImageButton,
// views::WidgetObserver: // views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override; void OnWidgetDestroying(views::Widget* widget) override;
// Returns the radius to use for the button corners (in newer material UI). // Returns the radius to use for the button corners.
int GetCornerRadius() const; int GetCornerRadius() const;
// Paints the fill region of the button into |canvas|. // Paints the fill region of the button into |canvas|.
......
This diff is collapsed.
...@@ -68,9 +68,6 @@ class TabStrip : public views::View, ...@@ -68,9 +68,6 @@ class TabStrip : public views::View,
explicit TabStrip(std::unique_ptr<TabStripController> controller); explicit TabStrip(std::unique_ptr<TabStripController> controller);
~TabStrip() override; ~TabStrip() override;
// Returns the gap size between the pinned tabs and the non-pinned tabs.
static int GetPinnedToNonPinnedOffset();
// Add and remove observers to changes within this TabStrip. // Add and remove observers to changes within this TabStrip.
void AddObserver(TabStripObserver* observer); void AddObserver(TabStripObserver* observer);
void RemoveObserver(TabStripObserver* observer); void RemoveObserver(TabStripObserver* observer);
......
...@@ -59,8 +59,6 @@ int CalculateBoundsForPinnedTabs(const TabSizeInfo& tab_size_info, ...@@ -59,8 +59,6 @@ int CalculateBoundsForPinnedTabs(const TabSizeInfo& tab_size_info,
tab_height); tab_height);
next_x += tab_size_info.pinned_tab_width - tab_size_info.tab_overlap; next_x += tab_size_info.pinned_tab_width - tab_size_info.tab_overlap;
} }
if (num_pinned_tabs)
next_x += tab_size_info.pinned_to_normal_offset;
return next_x; return next_x;
} }
......
...@@ -30,9 +30,6 @@ struct TabSizeInfo { ...@@ -30,9 +30,6 @@ struct TabSizeInfo {
// previous tab's width minus the |tab_overlap|, e.g. // previous tab's width minus the |tab_overlap|, e.g.
// next_tab_x = previous_tab.bounds().right() - tab_overlap. // next_tab_x = previous_tab.bounds().right() - tab_overlap.
int tab_overlap; int tab_overlap;
// Additional offset between the last pinned tab and the first normal tab.
int pinned_to_normal_offset;
}; };
// Calculates the bounds of the pinned tabs. This assumes |tabs_bounds| is the // Calculates the bounds of the pinned tabs. This assumes |tabs_bounds| is the
......
...@@ -35,7 +35,6 @@ TEST(TabStripLayoutTest, Tests) { ...@@ -35,7 +35,6 @@ TEST(TabStripLayoutTest, Tests) {
tab_size_info.min_inactive_width = 14; tab_size_info.min_inactive_width = 14;
tab_size_info.standard_size = gfx::Size(100, 10); tab_size_info.standard_size = gfx::Size(100, 10);
tab_size_info.tab_overlap = 4; tab_size_info.tab_overlap = 4;
tab_size_info.pinned_to_normal_offset = 6;
struct TestCases { struct TestCases {
int num_pinned_tabs; int num_pinned_tabs;
...@@ -57,19 +56,19 @@ TEST(TabStripLayoutTest, Tests) { ...@@ -57,19 +56,19 @@ TEST(TabStripLayoutTest, Tests) {
{3, 3, 0, 0, 1000, "0 10, 6 10, 12 10", 100, 100}, {3, 3, 0, 0, 1000, "0 10, 6 10, 12 10", 100, 100},
// Ample space, one pinned and two normal tabs. // Ample space, one pinned and two normal tabs.
{1, 3, 0, 0, 1000, "0 10, 12 100, 108 100", 100, 100}, {1, 3, 0, 0, 1000, "0 10, 6 100, 102 100", 100, 100},
// Resize between min and max, no pinned and no rounding. // Resize between min and max, no pinned and no rounding.
{0, 4, 0, 0, 100, "0 28, 24 28, 48 28, 72 28", 28, 28}, {0, 4, 0, 0, 100, "0 28, 24 28, 48 28, 72 28", 28, 28},
// Resize between min and max, pinned and no rounding. // Resize between min and max, pinned and no rounding.
{1, 3, 0, 0, 100, "0 10, 12 46, 54 46", 46, 46}, {1, 3, 0, 0, 100, "0 10, 6 49, 51 49", 49, 49},
// Resize between min and max, no pinned, rounding. // Resize between min and max, no pinned, rounding.
{0, 4, 0, 0, 102, "0 29, 25 29, 50 28, 74 28", 28, 28}, {0, 4, 0, 0, 102, "0 29, 25 29, 50 28, 74 28", 28, 28},
// Resize between min and max, pinned and rounding. // Resize between min and max, pinned and rounding.
{1, 3, 0, 0, 101, "0 10, 12 47, 55 46", 46, 46}, {1, 3, 0, 0, 101, "0 10, 6 50, 52 49", 49, 49},
// Resize between active/inactive width, only one tab. // Resize between active/inactive width, only one tab.
{0, 1, 0, 0, 15, "0 20", 20, 15}, {0, 1, 0, 0, 15, "0 20", 20, 15},
...@@ -82,10 +81,10 @@ TEST(TabStripLayoutTest, Tests) { ...@@ -82,10 +81,10 @@ TEST(TabStripLayoutTest, Tests) {
// Resize between active/inactive width, one pinned and active, no // Resize between active/inactive width, one pinned and active, no
// rounding. // rounding.
{1, 6, 0, 0, 91, "0 10, 12 19, 27 19, 42 19, 57 19, 72 19", 20, 19}, {1, 6, 0, 0, 85, "0 10, 6 19, 21 19, 36 19, 51 19, 66 19", 20, 19},
// Resize between active/inactive width, one pinned and active, rounding. // Resize between active/inactive width, one pinned and active, rounding.
{1, 6, 0, 0, 92, "0 10, 12 20, 28 19, 43 19, 58 19, 73 19", 20, 19}, {1, 6, 0, 0, 86, "0 10, 6 20, 22 19, 37 19, 52 19, 67 19", 20, 19},
// Not enough space, all pinned. // Not enough space, all pinned.
{3, 3, 0, 0, 10, "0 10, 6 10, 12 10", 100, 100}, {3, 3, 0, 0, 10, "0 10, 6 10, 12 10", 100, 100},
...@@ -94,7 +93,7 @@ TEST(TabStripLayoutTest, Tests) { ...@@ -94,7 +93,7 @@ TEST(TabStripLayoutTest, Tests) {
{0, 3, 0, 0, 10, "0 20, 16 14, 26 14", 20, 14}, {0, 3, 0, 0, 10, "0 20, 16 14, 26 14", 20, 14},
// Not enough space (for minimum widths), one pinned and two normal. // Not enough space (for minimum widths), one pinned and two normal.
{1, 3, 0, 0, 10, "0 10, 12 14, 22 14", 20, 14}, {1, 3, 0, 0, 10, "0 10, 6 14, 16 14", 20, 14},
}; };
for (size_t i = 0; i < arraysize(test_cases); ++i) { for (size_t i = 0; i < arraysize(test_cases); ++i) {
......
...@@ -150,7 +150,8 @@ class TabStripTest : public ChromeViewsTestBase, ...@@ -150,7 +150,8 @@ class TabStripTest : public ChromeViewsTestBase,
void SetUp() override { void SetUp() override {
if (GetParam()) { if (GetParam()) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kTopChromeMD, switches::kTopChromeMDMaterialTouchOptimized); switches::kTopChromeMD,
switches::kTopChromeMDMaterialRefreshTouchOptimized);
} }
ChromeViewsTestBase::SetUp(); ChromeViewsTestBase::SetUp();
...@@ -379,12 +380,6 @@ TEST_P(TabStripTest, VisibilityInOverflow) { ...@@ -379,12 +380,6 @@ TEST_P(TabStripTest, VisibilityInOverflow) {
// across the strip at the top, middle, and bottom, events will target each tab // across the strip at the top, middle, and bottom, events will target each tab
// in order. // in order.
TEST_P(TabStripTest, TabForEventWhenStacked) { TEST_P(TabStripTest, TabForEventWhenStacked) {
if (GetParam()) {
// TODO(malaykeshav): Fix test failure in touch-optimized UI mode.
// https://crbug.com/814847.
return;
}
tab_strip_->SetBounds(0, 0, 250, GetLayoutConstant(TAB_HEIGHT)); tab_strip_->SetBounds(0, 0, 250, GetLayoutConstant(TAB_HEIGHT));
controller_->AddTab(0, false); controller_->AddTab(0, false);
...@@ -416,13 +411,8 @@ TEST_P(TabStripTest, TabForEventWhenStacked) { ...@@ -416,13 +411,8 @@ TEST_P(TabStripTest, TabForEventWhenStacked) {
// Tests that the tab close buttons of non-active tabs are hidden when // Tests that the tab close buttons of non-active tabs are hidden when
// the tabstrip is in stacked tab mode. // the tabstrip is in stacked tab mode.
TEST_P(TabStripTest, TabCloseButtonVisibilityWhenStacked) { TEST_P(TabStripTest, TabCloseButtonVisibilityWhenStacked) {
if (GetParam()) { // Touch-optimized UI requires a larger width for tabs to show close buttons.
// TODO(malaykeshav): Fix test failure in touch-optimized UI mode. tab_strip_->SetBounds(0, 0, GetParam() ? 442 : 346, 20);
// https://crbug.com/814847.
return;
}
tab_strip_->SetBounds(0, 0, 360, 20);
controller_->AddTab(0, false); controller_->AddTab(0, false);
controller_->AddTab(1, true); controller_->AddTab(1, true);
controller_->AddTab(2, false); controller_->AddTab(2, false);
...@@ -490,15 +480,10 @@ TEST_P(TabStripTest, TabCloseButtonVisibilityWhenStacked) { ...@@ -490,15 +480,10 @@ TEST_P(TabStripTest, TabCloseButtonVisibilityWhenStacked) {
// the tabstrip is not in stacked tab mode and the tab sizes are shrunk // the tabstrip is not in stacked tab mode and the tab sizes are shrunk
// into small sizes. // into small sizes.
TEST_P(TabStripTest, TabCloseButtonVisibilityWhenNotStacked) { TEST_P(TabStripTest, TabCloseButtonVisibilityWhenNotStacked) {
if (GetParam()) {
// TODO(malaykeshav): Fix test failure in touch-optimized UI mode.
// https://crbug.com/814847.
return;
}
// Set the tab strip width to be wide enough for three tabs to show all // Set the tab strip width to be wide enough for three tabs to show all
// three icons, but not enough for five tabs to show all three icons. // three icons, but not enough for five tabs to show all three icons.
tab_strip_->SetBounds(0, 0, 360, 20); // Touch-optimized UI requires a larger width for tabs to show close buttons.
tab_strip_->SetBounds(0, 0, GetParam() ? 442 : 346, 20);
controller_->AddTab(0, false); controller_->AddTab(0, false);
controller_->AddTab(1, true); controller_->AddTab(1, true);
controller_->AddTab(2, false); controller_->AddTab(2, 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