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

Side by Side Diff: ui/views/controls/slider_unittest.cc

Issue 681883002: 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/slider.h ('k') | ui/views/controls/styled_label.h » ('j') | 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/slider.h" 5 #include "ui/views/controls/slider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/events/event.h" 15 #include "ui/events/event.h"
16 #include "ui/events/gesture_event_details.h" 16 #include "ui/events/gesture_event_details.h"
17 #include "ui/events/test/event_generator.h" 17 #include "ui/events/test/event_generator.h"
18 #include "ui/views/test/slider_test_api.h" 18 #include "ui/views/test/slider_test_api.h"
19 #include "ui/views/test/views_test_base.h" 19 #include "ui/views/test/views_test_base.h"
20 #include "ui/views/view.h" 20 #include "ui/views/view.h"
21 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 #include "ui/views/widget/widget_delegate.h" 22 #include "ui/views/widget/widget_delegate.h"
23 23
24 namespace { 24 namespace {
25 25
26 // A views::SliderListener that tracks simple event call history. 26 // A views::SliderListener that tracks simple event call history.
27 class TestSliderListener : public views::SliderListener { 27 class TestSliderListener : public views::SliderListener {
28 public: 28 public:
29 TestSliderListener(); 29 TestSliderListener();
30 virtual ~TestSliderListener(); 30 ~TestSliderListener() override;
31 31
32 int last_event_epoch() { 32 int last_event_epoch() {
33 return last_event_epoch_; 33 return last_event_epoch_;
34 } 34 }
35 35
36 int last_drag_started_epoch() { 36 int last_drag_started_epoch() {
37 return last_drag_started_epoch_; 37 return last_drag_started_epoch_;
38 } 38 }
39 39
40 int last_drag_ended_epoch() { 40 int last_drag_ended_epoch() {
41 return last_drag_ended_epoch_; 41 return last_drag_ended_epoch_;
42 } 42 }
43 43
44 views::Slider* last_drag_started_sender() { 44 views::Slider* last_drag_started_sender() {
45 return last_drag_started_sender_; 45 return last_drag_started_sender_;
46 } 46 }
47 47
48 views::Slider* last_drag_ended_sender() { 48 views::Slider* last_drag_ended_sender() {
49 return last_drag_ended_sender_; 49 return last_drag_ended_sender_;
50 } 50 }
51 51
52 // Resets the state of this as if it were newly created. 52 // Resets the state of this as if it were newly created.
53 virtual void ResetCallHistory(); 53 virtual void ResetCallHistory();
54 54
55 // views::SliderListener: 55 // views::SliderListener:
56 virtual void SliderValueChanged(views::Slider* sender, 56 void SliderValueChanged(views::Slider* sender,
57 float value, 57 float value,
58 float old_value, 58 float old_value,
59 views::SliderChangeReason reason) override; 59 views::SliderChangeReason reason) override;
60 virtual void SliderDragStarted(views::Slider* sender) override; 60 void SliderDragStarted(views::Slider* sender) override;
61 virtual void SliderDragEnded(views::Slider* sender) override; 61 void SliderDragEnded(views::Slider* sender) override;
62 62
63 private: 63 private:
64 // The epoch of the last event. 64 // The epoch of the last event.
65 int last_event_epoch_; 65 int last_event_epoch_;
66 // The epoch of the last time SliderDragStarted was called. 66 // The epoch of the last time SliderDragStarted was called.
67 int last_drag_started_epoch_; 67 int last_drag_started_epoch_;
68 // The epoch of the last time SliderDragEnded was called. 68 // The epoch of the last time SliderDragEnded was called.
69 int last_drag_ended_epoch_; 69 int last_drag_ended_epoch_;
70 // The sender from the last SliderDragStarted call. 70 // The sender from the last SliderDragStarted call.
71 views::Slider* last_drag_started_sender_; 71 views::Slider* last_drag_started_sender_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 } // namespace 116 } // namespace
117 117
118 namespace views { 118 namespace views {
119 119
120 // Base test fixture for Slider tests. 120 // Base test fixture for Slider tests.
121 class SliderTest : public views::ViewsTestBase { 121 class SliderTest : public views::ViewsTestBase {
122 public: 122 public:
123 explicit SliderTest(Slider::Orientation orientation); 123 explicit SliderTest(Slider::Orientation orientation);
124 virtual ~SliderTest(); 124 ~SliderTest() override;
125 125
126 protected: 126 protected:
127 Slider* slider() { 127 Slider* slider() {
128 return slider_; 128 return slider_;
129 } 129 }
130 130
131 TestSliderListener& slider_listener() { 131 TestSliderListener& slider_listener() {
132 return slider_listener_; 132 return slider_listener_;
133 } 133 }
134 134
135 int max_x() { 135 int max_x() {
136 return max_x_; 136 return max_x_;
137 } 137 }
138 138
139 int max_y() { 139 int max_y() {
140 return max_y_; 140 return max_y_;
141 } 141 }
142 142
143 virtual void ClickAt(int x, int y); 143 virtual void ClickAt(int x, int y);
144 144
145 // testing::Test: 145 // testing::Test:
146 virtual void SetUp() override; 146 void SetUp() override;
147 virtual void TearDown() override; 147 void TearDown() override;
148 148
149 ui::test::EventGenerator* event_generator() { 149 ui::test::EventGenerator* event_generator() {
150 return event_generator_.get(); 150 return event_generator_.get();
151 } 151 }
152 152
153 private: 153 private:
154 // The Slider's orientation 154 // The Slider's orientation
155 Slider::Orientation orientation_; 155 Slider::Orientation orientation_;
156 // The Slider to be tested. 156 // The Slider to be tested.
157 Slider* slider_; 157 Slider* slider_;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 void SliderTest::ClickAt(int x, int y) { 219 void SliderTest::ClickAt(int x, int y) {
220 gfx::Point point(x, y); 220 gfx::Point point(x, y);
221 event_generator_->MoveMouseTo(point); 221 event_generator_->MoveMouseTo(point);
222 event_generator_->ClickLeftButton(); 222 event_generator_->ClickLeftButton();
223 } 223 }
224 224
225 // Test fixture for horizontally oriented slider tests. 225 // Test fixture for horizontally oriented slider tests.
226 class HorizontalSliderTest : public SliderTest { 226 class HorizontalSliderTest : public SliderTest {
227 public: 227 public:
228 HorizontalSliderTest(); 228 HorizontalSliderTest();
229 virtual ~HorizontalSliderTest(); 229 ~HorizontalSliderTest() override;
230 230
231 private: 231 private:
232 DISALLOW_COPY_AND_ASSIGN(HorizontalSliderTest); 232 DISALLOW_COPY_AND_ASSIGN(HorizontalSliderTest);
233 }; 233 };
234 234
235 HorizontalSliderTest::HorizontalSliderTest() 235 HorizontalSliderTest::HorizontalSliderTest()
236 : SliderTest(Slider::HORIZONTAL) { 236 : SliderTest(Slider::HORIZONTAL) {
237 } 237 }
238 238
239 HorizontalSliderTest::~HorizontalSliderTest() { 239 HorizontalSliderTest::~HorizontalSliderTest() {
240 } 240 }
241 241
242 // Test fixture for vertically oriented slider tests. 242 // Test fixture for vertically oriented slider tests.
243 class VerticalSliderTest : public SliderTest { 243 class VerticalSliderTest : public SliderTest {
244 public: 244 public:
245 VerticalSliderTest(); 245 VerticalSliderTest();
246 virtual ~VerticalSliderTest(); 246 ~VerticalSliderTest() override;
247 247
248 private: 248 private:
249 DISALLOW_COPY_AND_ASSIGN(VerticalSliderTest); 249 DISALLOW_COPY_AND_ASSIGN(VerticalSliderTest);
250 }; 250 };
251 251
252 VerticalSliderTest::VerticalSliderTest() 252 VerticalSliderTest::VerticalSliderTest()
253 : SliderTest(Slider::VERTICAL) { 253 : SliderTest(Slider::VERTICAL) {
254 } 254 }
255 255
256 VerticalSliderTest::~VerticalSliderTest() { 256 VerticalSliderTest::~VerticalSliderTest() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 2 /* move_x */, 0 /* move_y */); 373 2 /* move_x */, 0 /* move_y */);
374 374
375 EXPECT_EQ(1, slider_listener().last_drag_started_epoch()); 375 EXPECT_EQ(1, slider_listener().last_drag_started_epoch());
376 EXPECT_GT(slider_listener().last_drag_ended_epoch(), 376 EXPECT_GT(slider_listener().last_drag_ended_epoch(),
377 slider_listener().last_drag_started_epoch()); 377 slider_listener().last_drag_started_epoch());
378 EXPECT_EQ(slider(), slider_listener().last_drag_started_sender()); 378 EXPECT_EQ(slider(), slider_listener().last_drag_started_sender());
379 EXPECT_EQ(slider(), slider_listener().last_drag_ended_sender()); 379 EXPECT_EQ(slider(), slider_listener().last_drag_ended_sender());
380 } 380 }
381 381
382 } // namespace views 382 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/slider.h ('k') | ui/views/controls/styled_label.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698