OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 class NativeScrollBarTest : public ViewsTestBase { | 49 class NativeScrollBarTest : public ViewsTestBase { |
50 public: | 50 public: |
51 NativeScrollBarTest() | 51 NativeScrollBarTest() |
52 : widget_(NULL), | 52 : widget_(NULL), |
53 scrollbar_(NULL), | 53 scrollbar_(NULL), |
54 controller_(NULL) { | 54 controller_(NULL) { |
55 } | 55 } |
56 | 56 |
57 virtual void SetUp() { | 57 virtual void SetUp() { |
58 Widget::SetPureViews(true); | |
59 ViewsTestBase::SetUp(); | 58 ViewsTestBase::SetUp(); |
60 controller_.reset(new TestScrollBarController()); | 59 controller_.reset(new TestScrollBarController()); |
61 | 60 |
62 ASSERT_FALSE(scrollbar_); | 61 ASSERT_FALSE(scrollbar_); |
63 native_scrollbar_ = new NativeScrollBar(true); | 62 native_scrollbar_ = new NativeScrollBar(true); |
64 native_scrollbar_->SetBounds(0, 0, 100, 100); | 63 native_scrollbar_->SetBounds(0, 0, 100, 100); |
65 native_scrollbar_->set_controller(controller_.get()); | 64 native_scrollbar_->set_controller(controller_.get()); |
66 | 65 |
67 widget_ = new Widget; | 66 widget_ = new Widget; |
68 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 67 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
69 params.bounds = gfx::Rect(0, 0, 100, 100); | 68 params.bounds = gfx::Rect(0, 0, 100, 100); |
70 widget_->Init(params); | 69 widget_->Init(params); |
71 View* container = new View(); | 70 View* container = new View(); |
72 widget_->SetContentsView(container); | 71 widget_->SetContentsView(container); |
73 container->AddChildView(native_scrollbar_); | 72 container->AddChildView(native_scrollbar_); |
74 | 73 |
75 scrollbar_ = | 74 scrollbar_ = |
76 static_cast<NativeScrollBarViews*>(native_scrollbar_->native_wrapper_); | 75 static_cast<NativeScrollBarViews*>(native_scrollbar_->native_wrapper_); |
77 scrollbar_->SetBounds(0, 0, 100, 100); | 76 scrollbar_->SetBounds(0, 0, 100, 100); |
78 scrollbar_->Update(100, 200, 0); | 77 scrollbar_->Update(100, 200, 0); |
79 | 78 |
80 track_size_ = scrollbar_->GetTrackBounds().width(); | 79 track_size_ = scrollbar_->GetTrackBounds().width(); |
81 } | 80 } |
82 | 81 |
83 virtual void TearDown() { | 82 virtual void TearDown() { |
84 widget_->Close(); | 83 widget_->Close(); |
85 ViewsTestBase::TearDown(); | 84 ViewsTestBase::TearDown(); |
86 Widget::SetPureViews(false); | |
87 } | 85 } |
88 | 86 |
89 protected: | 87 protected: |
90 Widget* widget_; | 88 Widget* widget_; |
91 | 89 |
92 // This is the native scrollbar the Views one wraps around. | 90 // This is the native scrollbar the Views one wraps around. |
93 NativeScrollBar* native_scrollbar_; | 91 NativeScrollBar* native_scrollbar_; |
94 | 92 |
95 // This is the Views scrollbar. | 93 // This is the Views scrollbar. |
96 BaseScrollBar* scrollbar_; | 94 BaseScrollBar* scrollbar_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 EXPECT_EQ(controller_->last_position, 0); | 138 EXPECT_EQ(controller_->last_position, 0); |
141 | 139 |
142 scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_NEXT_PAGE); | 140 scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_NEXT_PAGE); |
143 EXPECT_EQ(controller_->last_position, 20); | 141 EXPECT_EQ(controller_->last_position, 20); |
144 | 142 |
145 scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_PREV_PAGE); | 143 scrollbar_->ScrollByAmount(BaseScrollBar::SCROLL_PREV_PAGE); |
146 EXPECT_EQ(controller_->last_position, 0); | 144 EXPECT_EQ(controller_->last_position, 0); |
147 } | 145 } |
148 | 146 |
149 } // namespace views | 147 } // namespace views |
OLD | NEW |