| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "ui/views/controls/scrollbar/native_scroll_bar.h" | 6 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
| 7 #include "ui/views/controls/scrollbar/native_scroll_bar_views.h" | 7 #include "ui/views/controls/scrollbar/native_scroll_bar_views.h" |
| 8 #include "ui/views/controls/scrollbar/scroll_bar.h" | 8 #include "ui/views/controls/scrollbar/scroll_bar.h" |
| 9 #include "ui/views/test/views_test_base.h" | 9 #include "ui/views/test/views_test_base.h" |
| 10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // Scroll to the end of the content. | 168 // Scroll to the end of the content. |
| 169 scrollbar_->Update(100, 1001, 0); | 169 scrollbar_->Update(100, 1001, 0); |
| 170 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); | 170 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); |
| 171 // Shrink and then re-expand the content. | 171 // Shrink and then re-expand the content. |
| 172 scrollbar_->Update(100, 1000, 0); | 172 scrollbar_->Update(100, 1000, 0); |
| 173 scrollbar_->Update(100, 1001, 0); | 173 scrollbar_->Update(100, 1001, 0); |
| 174 // Ensure the scrollbar allows scrolling to the end. | 174 // Ensure the scrollbar allows scrolling to the end. |
| 175 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); | 175 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); |
| 176 } | 176 } |
| 177 | 177 |
| 178 TEST_F(NativeScrollBarTest, ThumbFullLengthOfTrack) { |
| 179 // Shrink content so that it fits within the viewport. |
| 180 scrollbar_->Update(100, 10, 0); |
| 181 EXPECT_EQ(scrollbar_->GetTrackBounds().width(), |
| 182 scrollbar_->GetThumbSizeForTest()); |
| 183 // Emulate a click on the full size scroll bar. |
| 184 scrollbar_->ScrollToThumbPosition(0, false); |
| 185 EXPECT_EQ(0, scrollbar_->GetPosition()); |
| 186 // Emulate a key down. |
| 187 scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_NEXT_LINE); |
| 188 EXPECT_EQ(0, scrollbar_->GetPosition()); |
| 189 |
| 190 // Expand content so that it fits *exactly* within the viewport. |
| 191 scrollbar_->Update(100, 100, 0); |
| 192 EXPECT_EQ(scrollbar_->GetTrackBounds().width(), |
| 193 scrollbar_->GetThumbSizeForTest()); |
| 194 // Emulate a click on the full size scroll bar. |
| 195 scrollbar_->ScrollToThumbPosition(0, false); |
| 196 EXPECT_EQ(0, scrollbar_->GetPosition()); |
| 197 // Emulate a key down. |
| 198 scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_NEXT_LINE); |
| 199 EXPECT_EQ(0, scrollbar_->GetPosition()); |
| 200 } |
| 201 |
| 178 } // namespace views | 202 } // namespace views |
| OLD | NEW |