Commit 461b2743 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

[Tab Scrolling] Round out tab strip region view unittests.

- Update tests to verify tabstrip is not larger than parent when growing
- Add a test to ensure the grab handle space is always visible
- Update new tab button always visible test to match this
- Rename kTabStripWidth to kTabStripRegionViewWidth

Bug: 1141674
Change-Id: I7fa527ed836c78ea9a3c1958715dc83ba7893a2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536238Reviewed-by: default avatarTaylor Bergquist <tbergquist@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827999}
parent a4b670d5
...@@ -41,6 +41,10 @@ class TabStripRegionView final : public views::AccessiblePaneView, ...@@ -41,6 +41,10 @@ class TabStripRegionView final : public views::AccessiblePaneView,
TabSearchButton* tab_search_button() { return tab_search_button_; } TabSearchButton* tab_search_button() { return tab_search_button_; }
views::View* reserved_grab_handle_space_for_testing() {
return reserved_grab_handle_space_;
}
// views::AccessiblePaneView: // views::AccessiblePaneView:
const char* GetClassName() const override; const char* GetClassName() const override;
void ChildPreferredSizeChanged(views::View* child) override; void ChildPreferredSizeChanged(views::View* child) override;
......
...@@ -93,22 +93,35 @@ class TabStripRegionViewTest : public TabStripRegionViewTestBase, ...@@ -93,22 +93,35 @@ class TabStripRegionViewTest : public TabStripRegionViewTestBase,
~TabStripRegionViewTest() override = default; ~TabStripRegionViewTest() override = default;
}; };
TEST_P(TabStripRegionViewTest, NewTabButtonStaysVisible) { TEST_P(TabStripRegionViewTest, GrabHandleSpaceStaysVisible) {
const int kTabStripWidth = 500; const int kTabStripRegionViewWidth = 500;
tab_strip_region_view_->SetBounds(0, 0, kTabStripWidth, 20); tab_strip_region_view_->SetBounds(0, 0, kTabStripRegionViewWidth, 20);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i) {
controller_->AddTab(i, (i == 0)); controller_->AddTab(i, (i == 0));
CompleteAnimationAndLayout();
EXPECT_LE(tab_strip_region_view_->reserved_grab_handle_space_for_testing()
->bounds()
.right(),
kTabStripRegionViewWidth);
}
}
CompleteAnimationAndLayout(); TEST_P(TabStripRegionViewTest, NewTabButtonStaysVisible) {
const int kTabStripRegionViewWidth = 500;
tab_strip_region_view_->SetBounds(0, 0, kTabStripRegionViewWidth, 20);
EXPECT_LE(tab_strip_region_view_->new_tab_button()->bounds().right(), for (int i = 0; i < 100; ++i) {
kTabStripWidth); controller_->AddTab(i, (i == 0));
CompleteAnimationAndLayout();
EXPECT_LE(tab_strip_region_view_->new_tab_button()->bounds().right(),
kTabStripRegionViewWidth);
}
} }
TEST_P(TabStripRegionViewTest, NewTabButtonRightOfTabs) { TEST_P(TabStripRegionViewTest, NewTabButtonRightOfTabs) {
const int kTabStripWidth = 500; const int kTabStripRegionViewWidth = 500;
tab_strip_region_view_->SetBounds(0, 0, kTabStripWidth, 20); tab_strip_region_view_->SetBounds(0, 0, kTabStripRegionViewWidth, 20);
controller_->AddTab(0, true); controller_->AddTab(0, true);
...@@ -119,8 +132,8 @@ TEST_P(TabStripRegionViewTest, NewTabButtonRightOfTabs) { ...@@ -119,8 +132,8 @@ TEST_P(TabStripRegionViewTest, NewTabButtonRightOfTabs) {
} }
TEST_P(TabStripRegionViewTest, NewTabButtonInkDrop) { TEST_P(TabStripRegionViewTest, NewTabButtonInkDrop) {
constexpr int kTabStripWidth = 500; constexpr int kTabStripRegionViewWidth = 500;
tab_strip_region_view_->SetBounds(0, 0, kTabStripWidth, tab_strip_region_view_->SetBounds(0, 0, kTabStripRegionViewWidth,
GetLayoutConstant(TAB_HEIGHT)); GetLayoutConstant(TAB_HEIGHT));
// Add a few tabs and simulate the new tab button's ink drop animation. This // Add a few tabs and simulate the new tab button's ink drop animation. This
...@@ -194,6 +207,7 @@ TEST_F(TabStripRegionViewTestWithScrollingDisabled, ...@@ -194,6 +207,7 @@ TEST_F(TabStripRegionViewTestWithScrollingDisabled,
while (GetInactiveTabWidth() > minimum_active_width) { while (GetInactiveTabWidth() > minimum_active_width) {
controller_->AddTab(0, false); controller_->AddTab(0, false);
CompleteAnimationAndLayout(); CompleteAnimationAndLayout();
EXPECT_LT(tab_strip_->width(), tab_strip_region_view_->width());
} }
// Add a few more tabs after the tabstrip is full to ensure tabs added // Add a few more tabs after the tabstrip is full to ensure tabs added
...@@ -233,6 +247,7 @@ TEST_F(TabStripRegionViewTestWithScrollingEnabled, ...@@ -233,6 +247,7 @@ TEST_F(TabStripRegionViewTestWithScrollingEnabled,
while (GetInactiveTabWidth() > minimum_active_width) { while (GetInactiveTabWidth() > minimum_active_width) {
controller_->AddTab(0, false); controller_->AddTab(0, false);
CompleteAnimationAndLayout(); CompleteAnimationAndLayout();
EXPECT_LT(tab_strip_->width(), tab_strip_region_view_->width());
} }
// Add a few more tabs after the tabstrip is full to ensure the tabstrip // Add a few more tabs after the tabstrip is full to ensure the tabstrip
......
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