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