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

Side by Side Diff: ash/display/display_controller_unittest.cc

Issue 685543003: 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 | « ash/display/display_controller.h ('k') | ash/display/display_manager_unittest.cc » ('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 "ash/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_info.h" 8 #include "ash/display/display_info.h"
9 #include "ash/display/display_layout_store.h" 9 #include "ash/display/display_layout_store.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 focus_changed_count_(0), 73 focus_changed_count_(0),
74 activation_changed_count_(0) { 74 activation_changed_count_(0) {
75 Shell::GetInstance()->display_controller()->AddObserver(this); 75 Shell::GetInstance()->display_controller()->AddObserver(this);
76 Shell::GetScreen()->AddObserver(this); 76 Shell::GetScreen()->AddObserver(this);
77 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> 77 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())->
78 AddObserver(this); 78 AddObserver(this);
79 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 79 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
80 AddObserver(this); 80 AddObserver(this);
81 } 81 }
82 82
83 virtual ~TestObserver() { 83 ~TestObserver() override {
84 Shell::GetInstance()->display_controller()->RemoveObserver(this); 84 Shell::GetInstance()->display_controller()->RemoveObserver(this);
85 Shell::GetScreen()->RemoveObserver(this); 85 Shell::GetScreen()->RemoveObserver(this);
86 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> 86 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())->
87 RemoveObserver(this); 87 RemoveObserver(this);
88 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 88 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
89 RemoveObserver(this); 89 RemoveObserver(this);
90 } 90 }
91 91
92 // Overridden from DisplayController::Observer 92 // Overridden from DisplayController::Observer
93 virtual void OnDisplayConfigurationChanging() override { 93 void OnDisplayConfigurationChanging() override { ++changing_count_; }
94 ++changing_count_; 94 void OnDisplayConfigurationChanged() override { ++changed_count_; }
95 }
96 virtual void OnDisplayConfigurationChanged() override {
97 ++changed_count_;
98 }
99 95
100 // Overrideen from gfx::DisplayObserver 96 // Overrideen from gfx::DisplayObserver
101 virtual void OnDisplayMetricsChanged(const gfx::Display& display, 97 void OnDisplayMetricsChanged(const gfx::Display& display,
102 uint32_t metrics) override { 98 uint32_t metrics) override {
103 changed_display_id_ = display.id(); 99 changed_display_id_ = display.id();
104 if (metrics & DISPLAY_METRIC_BOUNDS) 100 if (metrics & DISPLAY_METRIC_BOUNDS)
105 ++bounds_changed_count_; 101 ++bounds_changed_count_;
106 if (metrics & DISPLAY_METRIC_ROTATION) 102 if (metrics & DISPLAY_METRIC_ROTATION)
107 ++rotation_changed_count_; 103 ++rotation_changed_count_;
108 if (metrics & DISPLAY_METRIC_WORK_AREA) 104 if (metrics & DISPLAY_METRIC_WORK_AREA)
109 ++workarea_changed_count_; 105 ++workarea_changed_count_;
110 } 106 }
111 virtual void OnDisplayAdded(const gfx::Display& new_display) override { 107 void OnDisplayAdded(const gfx::Display& new_display) override {}
112 } 108 void OnDisplayRemoved(const gfx::Display& old_display) override {}
113 virtual void OnDisplayRemoved(const gfx::Display& old_display) override {
114 }
115 109
116 // Overridden from aura::client::FocusChangeObserver 110 // Overridden from aura::client::FocusChangeObserver
117 virtual void OnWindowFocused(aura::Window* gained_focus, 111 void OnWindowFocused(aura::Window* gained_focus,
118 aura::Window* lost_focus) override { 112 aura::Window* lost_focus) override {
119 focus_changed_count_++; 113 focus_changed_count_++;
120 } 114 }
121 115
122 // Overridden from aura::client::ActivationChangeObserver 116 // Overridden from aura::client::ActivationChangeObserver
123 virtual void OnWindowActivated(aura::Window* gained_active, 117 void OnWindowActivated(aura::Window* gained_active,
124 aura::Window* lost_active) override { 118 aura::Window* lost_active) override {
125 activation_changed_count_++; 119 activation_changed_count_++;
126 } 120 }
127 virtual void OnAttemptToReactivateWindow( 121 void OnAttemptToReactivateWindow(aura::Window* request_active,
128 aura::Window* request_active, 122 aura::Window* actual_active) override {}
129 aura::Window* actual_active) override {
130 }
131 123
132 int CountAndReset() { 124 int CountAndReset() {
133 EXPECT_EQ(changing_count_, changed_count_); 125 EXPECT_EQ(changing_count_, changed_count_);
134 changed_count_ = 0; 126 changed_count_ = 0;
135 return Resetter<int>(&changing_count_).value(); 127 return Resetter<int>(&changing_count_).value();
136 } 128 }
137 129
138 int64 GetBoundsChangedCountAndReset() { 130 int64 GetBoundsChangedCountAndReset() {
139 return Resetter<int>(&bounds_changed_count_).value(); 131 return Resetter<int>(&bounds_changed_count_).value();
140 } 132 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 189 }
198 190
199 void SetDefaultDisplayLayout(DisplayLayout::Position position) { 191 void SetDefaultDisplayLayout(DisplayLayout::Position position) {
200 Shell::GetInstance()->display_manager()->layout_store()-> 192 Shell::GetInstance()->display_manager()->layout_store()->
201 SetDefaultDisplayLayout(DisplayLayout(position, 0)); 193 SetDefaultDisplayLayout(DisplayLayout(position, 0));
202 } 194 }
203 195
204 class DisplayControllerShutdownTest : public test::AshTestBase { 196 class DisplayControllerShutdownTest : public test::AshTestBase {
205 public: 197 public:
206 DisplayControllerShutdownTest() {} 198 DisplayControllerShutdownTest() {}
207 virtual ~DisplayControllerShutdownTest() {} 199 ~DisplayControllerShutdownTest() override {}
208 200
209 virtual void TearDown() override { 201 void TearDown() override {
210 test::AshTestBase::TearDown(); 202 test::AshTestBase::TearDown();
211 if (!SupportsMultipleDisplays()) 203 if (!SupportsMultipleDisplays())
212 return; 204 return;
213 205
214 // Make sure that primary display is accessible after shutdown. 206 // Make sure that primary display is accessible after shutdown.
215 gfx::Display primary = Shell::GetScreen()->GetPrimaryDisplay(); 207 gfx::Display primary = Shell::GetScreen()->GetPrimaryDisplay();
216 EXPECT_EQ("0,0 444x333", primary.bounds().ToString()); 208 EXPECT_EQ("0,0 444x333", primary.bounds().ToString());
217 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 209 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays());
218 } 210 }
219 211
220 private: 212 private:
221 DISALLOW_COPY_AND_ASSIGN(DisplayControllerShutdownTest); 213 DISALLOW_COPY_AND_ASSIGN(DisplayControllerShutdownTest);
222 }; 214 };
223 215
224 class StartupHelper : public test::TestShellDelegate, 216 class StartupHelper : public test::TestShellDelegate,
225 public DisplayController::Observer { 217 public DisplayController::Observer {
226 public: 218 public:
227 StartupHelper() : displays_initialized_(false) {} 219 StartupHelper() : displays_initialized_(false) {}
228 virtual ~StartupHelper() {} 220 ~StartupHelper() override {}
229 221
230 // ash::ShellSelegate: 222 // ash::ShellSelegate:
231 virtual void PreInit() override { 223 void PreInit() override {
232 Shell::GetInstance()->display_controller()->AddObserver(this); 224 Shell::GetInstance()->display_controller()->AddObserver(this);
233 } 225 }
234 226
235 // ash::DisplayController::Observer: 227 // ash::DisplayController::Observer:
236 virtual void OnDisplaysInitialized() override { 228 void OnDisplaysInitialized() override {
237 DCHECK(!displays_initialized_); 229 DCHECK(!displays_initialized_);
238 displays_initialized_ = true; 230 displays_initialized_ = true;
239 } 231 }
240 232
241 bool displays_initialized() const { 233 bool displays_initialized() const {
242 return displays_initialized_; 234 return displays_initialized_;
243 } 235 }
244 236
245 private: 237 private:
246 bool displays_initialized_; 238 bool displays_initialized_;
247 239
248 DISALLOW_COPY_AND_ASSIGN(StartupHelper); 240 DISALLOW_COPY_AND_ASSIGN(StartupHelper);
249 }; 241 };
250 242
251 class DisplayControllerStartupTest : public test::AshTestBase { 243 class DisplayControllerStartupTest : public test::AshTestBase {
252 public: 244 public:
253 DisplayControllerStartupTest() : startup_helper_(new StartupHelper) {} 245 DisplayControllerStartupTest() : startup_helper_(new StartupHelper) {}
254 virtual ~DisplayControllerStartupTest() {} 246 ~DisplayControllerStartupTest() override {}
255 247
256 // ash::test::AshTestBase: 248 // ash::test::AshTestBase:
257 virtual void SetUp() override { 249 void SetUp() override {
258 ash_test_helper()->set_test_shell_delegate(startup_helper_); 250 ash_test_helper()->set_test_shell_delegate(startup_helper_);
259 test::AshTestBase::SetUp(); 251 test::AshTestBase::SetUp();
260 } 252 }
261 virtual void TearDown() override { 253 void TearDown() override {
262 Shell::GetInstance()->display_controller()->RemoveObserver(startup_helper_); 254 Shell::GetInstance()->display_controller()->RemoveObserver(startup_helper_);
263 test::AshTestBase::TearDown(); 255 test::AshTestBase::TearDown();
264 } 256 }
265 257
266 const StartupHelper* startup_helper() const { return startup_helper_; } 258 const StartupHelper* startup_helper() const { return startup_helper_; }
267 259
268 private: 260 private:
269 StartupHelper* startup_helper_; // Owned by ash::Shell. 261 StartupHelper* startup_helper_; // Owned by ash::Shell.
270 262
271 DISALLOW_COPY_AND_ASSIGN(DisplayControllerStartupTest); 263 DISALLOW_COPY_AND_ASSIGN(DisplayControllerStartupTest);
272 }; 264 };
273 265
274 class TestEventHandler : public ui::EventHandler { 266 class TestEventHandler : public ui::EventHandler {
275 public: 267 public:
276 TestEventHandler() : target_root_(NULL), 268 TestEventHandler() : target_root_(NULL),
277 touch_radius_x_(0.0), 269 touch_radius_x_(0.0),
278 touch_radius_y_(0.0), 270 touch_radius_y_(0.0),
279 scroll_x_offset_(0.0), 271 scroll_x_offset_(0.0),
280 scroll_y_offset_(0.0), 272 scroll_y_offset_(0.0),
281 scroll_x_offset_ordinal_(0.0), 273 scroll_x_offset_ordinal_(0.0),
282 scroll_y_offset_ordinal_(0.0) {} 274 scroll_y_offset_ordinal_(0.0) {}
283 virtual ~TestEventHandler() {} 275 ~TestEventHandler() override {}
284 276
285 virtual void OnMouseEvent(ui::MouseEvent* event) override { 277 void OnMouseEvent(ui::MouseEvent* event) override {
286 if (event->flags() & ui::EF_IS_SYNTHESIZED && 278 if (event->flags() & ui::EF_IS_SYNTHESIZED &&
287 event->type() != ui::ET_MOUSE_EXITED && 279 event->type() != ui::ET_MOUSE_EXITED &&
288 event->type() != ui::ET_MOUSE_ENTERED) { 280 event->type() != ui::ET_MOUSE_ENTERED) {
289 return; 281 return;
290 } 282 }
291 aura::Window* target = static_cast<aura::Window*>(event->target()); 283 aura::Window* target = static_cast<aura::Window*>(event->target());
292 mouse_location_ = event->root_location(); 284 mouse_location_ = event->root_location();
293 target_root_ = target->GetRootWindow(); 285 target_root_ = target->GetRootWindow();
294 event->StopPropagation(); 286 event->StopPropagation();
295 } 287 }
296 288
297 virtual void OnTouchEvent(ui::TouchEvent* event) override { 289 void OnTouchEvent(ui::TouchEvent* event) override {
298 aura::Window* target = static_cast<aura::Window*>(event->target()); 290 aura::Window* target = static_cast<aura::Window*>(event->target());
299 // Only record when the target is the background which covers 291 // Only record when the target is the background which covers
300 // entire root window. 292 // entire root window.
301 if (target->name() != kDesktopBackgroundView) 293 if (target->name() != kDesktopBackgroundView)
302 return; 294 return;
303 touch_radius_x_ = event->radius_x(); 295 touch_radius_x_ = event->radius_x();
304 touch_radius_y_ = event->radius_y(); 296 touch_radius_y_ = event->radius_y();
305 event->StopPropagation(); 297 event->StopPropagation();
306 } 298 }
307 299
308 virtual void OnScrollEvent(ui::ScrollEvent* event) override { 300 void OnScrollEvent(ui::ScrollEvent* event) override {
309 aura::Window* target = static_cast<aura::Window*>(event->target()); 301 aura::Window* target = static_cast<aura::Window*>(event->target());
310 // Only record when the target is the background which covers 302 // Only record when the target is the background which covers
311 // entire root window. 303 // entire root window.
312 if (target->name() != kDesktopBackgroundView) 304 if (target->name() != kDesktopBackgroundView)
313 return; 305 return;
314 306
315 if (event->type() == ui::ET_SCROLL) { 307 if (event->type() == ui::ET_SCROLL) {
316 scroll_x_offset_ = event->x_offset(); 308 scroll_x_offset_ = event->x_offset();
317 scroll_y_offset_ = event->y_offset(); 309 scroll_y_offset_ = event->y_offset();
318 scroll_x_offset_ordinal_ = event->x_offset_ordinal(); 310 scroll_x_offset_ordinal_ = event->x_offset_ordinal();
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); 1327 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost()));
1336 1328
1337 // Switching back to single display. 1329 // Switching back to single display.
1338 UpdateDisplay("300x400"); 1330 UpdateDisplay("300x400");
1339 EXPECT_EQ("aura_root_0", GetXWindowName( 1331 EXPECT_EQ("aura_root_0", GetXWindowName(
1340 Shell::GetPrimaryRootWindow()->GetHost())); 1332 Shell::GetPrimaryRootWindow()->GetHost()));
1341 } 1333 }
1342 #endif 1334 #endif
1343 1335
1344 } // namespace ash 1336 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.h ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698