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 "ui/views/controls/scrollbar/native_scroll_bar.h" | 5 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
6 #include "ui/views/controls/scrollbar/native_scroll_bar_views.h" | 6 #include "ui/views/controls/scrollbar/native_scroll_bar_views.h" |
7 #include "ui/views/controls/scrollbar/scroll_bar.h" | 7 #include "ui/views/controls/scrollbar/scroll_bar.h" |
8 #include "ui/views/test/views_test_base.h" | 8 #include "ui/views/test/views_test_base.h" |
9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 // The Scrollbar controller. This is the widget that should do the real | 13 // The Scrollbar controller. This is the widget that should do the real |
14 // scrolling of contents. | 14 // scrolling of contents. |
15 class TestScrollBarController : public views::ScrollBarController { | 15 class TestScrollBarController : public views::ScrollBarController { |
16 public: | 16 public: |
17 virtual ~TestScrollBarController() {} | 17 virtual ~TestScrollBarController() {} |
18 | 18 |
19 virtual void ScrollToPosition(views::ScrollBar* source, | 19 virtual void ScrollToPosition(views::ScrollBar* source, |
20 int position) OVERRIDE { | 20 int position) override { |
21 last_source = source; | 21 last_source = source; |
22 last_position = position; | 22 last_position = position; |
23 } | 23 } |
24 | 24 |
25 virtual int GetScrollIncrement(views::ScrollBar* source, | 25 virtual int GetScrollIncrement(views::ScrollBar* source, |
26 bool is_page, | 26 bool is_page, |
27 bool is_positive) OVERRIDE { | 27 bool is_positive) override { |
28 last_source = source; | 28 last_source = source; |
29 last_is_page = is_page; | 29 last_is_page = is_page; |
30 last_is_positive = is_positive; | 30 last_is_positive = is_positive; |
31 | 31 |
32 if (is_page) | 32 if (is_page) |
33 return 20; | 33 return 20; |
34 return 10; | 34 return 10; |
35 } | 35 } |
36 | 36 |
37 // We save the last values in order to assert the corectness of the scroll | 37 // We save the last values in order to assert the corectness of the scroll |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 scrollbar_->Update(100, 101, 0); | 161 scrollbar_->Update(100, 101, 0); |
162 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); | 162 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); |
163 // Shrink and then re-exapnd the content. | 163 // Shrink and then re-exapnd the content. |
164 scrollbar_->Update(100, 100, 0); | 164 scrollbar_->Update(100, 100, 0); |
165 scrollbar_->Update(100, 101, 0); | 165 scrollbar_->Update(100, 101, 0); |
166 // Ensure the scrollbar allows scrolling to the end. | 166 // Ensure the scrollbar allows scrolling to the end. |
167 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); | 167 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); |
168 } | 168 } |
169 | 169 |
170 } // namespace views | 170 } // namespace views |
OLD | NEW |