Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Unified Diff: ui/views/controls/scrollbar/scrollbar_unittest.cc

Issue 1769553003: Guard against division by zero for useless scroll bars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/scrollbar/scrollbar_unittest.cc
diff --git a/ui/views/controls/scrollbar/scrollbar_unittest.cc b/ui/views/controls/scrollbar/scrollbar_unittest.cc
index 4bfab107428badafa9674de437d5b1508c0c0628..84471929234f8271eb7746b6f8bc893eb3f96548 100644
--- a/ui/views/controls/scrollbar/scrollbar_unittest.cc
+++ b/ui/views/controls/scrollbar/scrollbar_unittest.cc
@@ -175,4 +175,28 @@ TEST_F(NativeScrollBarTest, ScrollToEndAfterShrinkAndExpand) {
EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1));
}
+TEST_F(NativeScrollBarTest, ThumbFullLengthOfTrack) {
+ // Shrink content so that it fits within the viewport.
+ scrollbar_->Update(100, 10, 0);
+ EXPECT_EQ(scrollbar_->GetTrackBounds().width(),
+ scrollbar_->GetThumbSizeForTest());
+ // Emulate a click on the full size scroll bar.
+ scrollbar_->ScrollToThumbPosition(0, false);
+ EXPECT_EQ(0, scrollbar_->GetPosition());
+ // Emulate a key down.
+ scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_NEXT_LINE);
+ EXPECT_EQ(0, scrollbar_->GetPosition());
+
+ // Expand content so that it fits *exactly* within the viewport.
+ scrollbar_->Update(100, 100, 0);
+ EXPECT_EQ(scrollbar_->GetTrackBounds().width(),
+ scrollbar_->GetThumbSizeForTest());
+ // Emulate a click on the full size scroll bar.
+ scrollbar_->ScrollToThumbPosition(0, false);
+ EXPECT_EQ(0, scrollbar_->GetPosition());
+ // Emulate a key down.
+ scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_NEXT_LINE);
+ EXPECT_EQ(0, scrollbar_->GetPosition());
+}
+
} // namespace views
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698