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

Side by Side Diff: ui/views/controls/scrollbar/scrollbar_unittest.cc

Issue 677563004: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/scrollbar/scroll_bar.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 void ScrollToPosition(views::ScrollBar* source, int position) override {
20 int position) override {
21 last_source = source; 20 last_source = source;
22 last_position = position; 21 last_position = position;
23 } 22 }
24 23
25 virtual int GetScrollIncrement(views::ScrollBar* source, 24 int GetScrollIncrement(views::ScrollBar* source,
26 bool is_page, 25 bool is_page,
27 bool is_positive) override { 26 bool is_positive) override {
28 last_source = source; 27 last_source = source;
29 last_is_page = is_page; 28 last_is_page = is_page;
30 last_is_positive = is_positive; 29 last_is_positive = is_positive;
31 30
32 if (is_page) 31 if (is_page)
33 return 20; 32 return 20;
34 return 10; 33 return 10;
35 } 34 }
36 35
37 // We save the last values in order to assert the corectness of the scroll 36 // We save the last values in order to assert the corectness of the scroll
38 // operation. 37 // operation.
39 views::ScrollBar* last_source; 38 views::ScrollBar* last_source;
40 bool last_is_positive; 39 bool last_is_positive;
41 bool last_is_page; 40 bool last_is_page;
42 int last_position; 41 int last_position;
43 }; 42 };
44 43
45 } // namespace 44 } // namespace
46 45
47 namespace views { 46 namespace views {
48 47
49 class NativeScrollBarTest : public ViewsTestBase { 48 class NativeScrollBarTest : public ViewsTestBase {
50 public: 49 public:
51 NativeScrollBarTest() : widget_(NULL), scrollbar_(NULL) {} 50 NativeScrollBarTest() : widget_(NULL), scrollbar_(NULL) {}
52 51
53 virtual void SetUp() { 52 void SetUp() override {
54 ViewsTestBase::SetUp(); 53 ViewsTestBase::SetUp();
55 controller_.reset(new TestScrollBarController()); 54 controller_.reset(new TestScrollBarController());
56 55
57 ASSERT_FALSE(scrollbar_); 56 ASSERT_FALSE(scrollbar_);
58 native_scrollbar_ = new NativeScrollBar(true); 57 native_scrollbar_ = new NativeScrollBar(true);
59 native_scrollbar_->SetBounds(0, 0, 100, 100); 58 native_scrollbar_->SetBounds(0, 0, 100, 100);
60 native_scrollbar_->set_controller(controller_.get()); 59 native_scrollbar_->set_controller(controller_.get());
61 60
62 widget_ = new Widget; 61 widget_ = new Widget;
63 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 62 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
64 params.bounds = gfx::Rect(0, 0, 100, 100); 63 params.bounds = gfx::Rect(0, 0, 100, 100);
65 widget_->Init(params); 64 widget_->Init(params);
66 View* container = new View(); 65 View* container = new View();
67 widget_->SetContentsView(container); 66 widget_->SetContentsView(container);
68 container->AddChildView(native_scrollbar_); 67 container->AddChildView(native_scrollbar_);
69 68
70 scrollbar_ = 69 scrollbar_ =
71 static_cast<NativeScrollBarViews*>(native_scrollbar_->native_wrapper_); 70 static_cast<NativeScrollBarViews*>(native_scrollbar_->native_wrapper_);
72 scrollbar_->SetBounds(0, 0, 100, 100); 71 scrollbar_->SetBounds(0, 0, 100, 100);
73 scrollbar_->Update(100, 200, 0); 72 scrollbar_->Update(100, 200, 0);
74 73
75 track_size_ = scrollbar_->GetTrackBounds().width(); 74 track_size_ = scrollbar_->GetTrackBounds().width();
76 } 75 }
77 76
78 virtual void TearDown() { 77 void TearDown() override {
79 widget_->Close(); 78 widget_->Close();
80 ViewsTestBase::TearDown(); 79 ViewsTestBase::TearDown();
81 } 80 }
82 81
83 protected: 82 protected:
84 Widget* widget_; 83 Widget* widget_;
85 84
86 // This is the native scrollbar the Views one wraps around. 85 // This is the native scrollbar the Views one wraps around.
87 NativeScrollBar* native_scrollbar_; 86 NativeScrollBar* native_scrollbar_;
88 87
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 scrollbar_->Update(100, 101, 0); 160 scrollbar_->Update(100, 101, 0);
162 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); 161 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1));
163 // Shrink and then re-exapnd the content. 162 // Shrink and then re-exapnd the content.
164 scrollbar_->Update(100, 100, 0); 163 scrollbar_->Update(100, 100, 0);
165 scrollbar_->Update(100, 101, 0); 164 scrollbar_->Update(100, 101, 0);
166 // Ensure the scrollbar allows scrolling to the end. 165 // Ensure the scrollbar allows scrolling to the end.
167 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1)); 166 EXPECT_TRUE(scrollbar_->ScrollByContentsOffset(-1));
168 } 167 }
169 168
170 } // namespace views 169 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/scroll_bar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698