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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 class TestObserver : public DisplayController::Observer, | 61 class TestObserver : public DisplayController::Observer, |
62 public gfx::DisplayObserver, | 62 public gfx::DisplayObserver, |
63 public aura::client::FocusChangeObserver, | 63 public aura::client::FocusChangeObserver, |
64 public aura::client::ActivationChangeObserver { | 64 public aura::client::ActivationChangeObserver { |
65 public: | 65 public: |
66 TestObserver() | 66 TestObserver() |
67 : changing_count_(0), | 67 : changing_count_(0), |
68 changed_count_(0), | 68 changed_count_(0), |
69 bounds_changed_count_(0), | 69 bounds_changed_count_(0), |
| 70 rotation_changed_count_(0), |
| 71 workarea_changed_count_(0), |
70 changed_display_id_(0), | 72 changed_display_id_(0), |
71 focus_changed_count_(0), | 73 focus_changed_count_(0), |
72 activation_changed_count_(0) { | 74 activation_changed_count_(0) { |
73 Shell::GetInstance()->display_controller()->AddObserver(this); | 75 Shell::GetInstance()->display_controller()->AddObserver(this); |
74 Shell::GetScreen()->AddObserver(this); | 76 Shell::GetScreen()->AddObserver(this); |
75 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> | 77 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> |
76 AddObserver(this); | 78 AddObserver(this); |
77 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 79 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
78 AddObserver(this); | 80 AddObserver(this); |
79 } | 81 } |
80 | 82 |
81 virtual ~TestObserver() { | 83 virtual ~TestObserver() { |
82 Shell::GetInstance()->display_controller()->RemoveObserver(this); | 84 Shell::GetInstance()->display_controller()->RemoveObserver(this); |
83 Shell::GetScreen()->RemoveObserver(this); | 85 Shell::GetScreen()->RemoveObserver(this); |
84 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> | 86 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> |
85 RemoveObserver(this); | 87 RemoveObserver(this); |
86 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 88 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
87 RemoveObserver(this); | 89 RemoveObserver(this); |
88 } | 90 } |
89 | 91 |
90 // Overridden from DisplayController::Observer | 92 // Overridden from DisplayController::Observer |
91 virtual void OnDisplayConfigurationChanging() OVERRIDE { | 93 virtual void OnDisplayConfigurationChanging() OVERRIDE { |
92 ++changing_count_; | 94 ++changing_count_; |
93 } | 95 } |
94 virtual void OnDisplayConfigurationChanged() OVERRIDE { | 96 virtual void OnDisplayConfigurationChanged() OVERRIDE { |
95 ++changed_count_; | 97 ++changed_count_; |
96 } | 98 } |
97 | 99 |
98 // Overrideen from gfx::DisplayObserver | 100 // Overrideen from gfx::DisplayObserver |
99 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { | 101 virtual void OnDisplayMetricsChanged(const gfx::Display& display, |
| 102 uint32_t metrics) OVERRIDE { |
100 changed_display_id_ = display.id(); | 103 changed_display_id_ = display.id(); |
101 bounds_changed_count_ ++; | 104 if (metrics & DISPLAY_METRIC_BOUNDS) |
| 105 ++bounds_changed_count_; |
| 106 if (metrics & DISPLAY_METRIC_ROTATION) |
| 107 ++rotation_changed_count_; |
| 108 if (metrics & DISPLAY_METRIC_WORK_AREA) |
| 109 ++workarea_changed_count_; |
102 } | 110 } |
103 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { | 111 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { |
104 } | 112 } |
105 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { | 113 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { |
106 } | 114 } |
107 | 115 |
108 // Overridden from aura::client::FocusChangeObserver | 116 // Overridden from aura::client::FocusChangeObserver |
109 virtual void OnWindowFocused(aura::Window* gained_focus, | 117 virtual void OnWindowFocused(aura::Window* gained_focus, |
110 aura::Window* lost_focus) OVERRIDE { | 118 aura::Window* lost_focus) OVERRIDE { |
111 focus_changed_count_++; | 119 focus_changed_count_++; |
(...skipping 12 matching lines...) Expand all Loading... |
124 int CountAndReset() { | 132 int CountAndReset() { |
125 EXPECT_EQ(changing_count_, changed_count_); | 133 EXPECT_EQ(changing_count_, changed_count_); |
126 changed_count_ = 0; | 134 changed_count_ = 0; |
127 return Resetter<int>(&changing_count_).value(); | 135 return Resetter<int>(&changing_count_).value(); |
128 } | 136 } |
129 | 137 |
130 int64 GetBoundsChangedCountAndReset() { | 138 int64 GetBoundsChangedCountAndReset() { |
131 return Resetter<int>(&bounds_changed_count_).value(); | 139 return Resetter<int>(&bounds_changed_count_).value(); |
132 } | 140 } |
133 | 141 |
| 142 int64 GetRotationChangedCountAndReset() { |
| 143 return Resetter<int>(&rotation_changed_count_).value(); |
| 144 } |
| 145 |
| 146 int64 GetWorkareaChangedCountAndReset() { |
| 147 return Resetter<int>(&workarea_changed_count_).value(); |
| 148 } |
| 149 |
134 int64 GetChangedDisplayIdAndReset() { | 150 int64 GetChangedDisplayIdAndReset() { |
135 return Resetter<int64>(&changed_display_id_).value(); | 151 return Resetter<int64>(&changed_display_id_).value(); |
136 } | 152 } |
137 | 153 |
138 int GetFocusChangedCountAndReset() { | 154 int GetFocusChangedCountAndReset() { |
139 return Resetter<int>(&focus_changed_count_).value(); | 155 return Resetter<int>(&focus_changed_count_).value(); |
140 } | 156 } |
141 | 157 |
142 int GetActivationChangedCountAndReset() { | 158 int GetActivationChangedCountAndReset() { |
143 return Resetter<int>(&activation_changed_count_).value(); | 159 return Resetter<int>(&activation_changed_count_).value(); |
144 } | 160 } |
145 | 161 |
146 private: | 162 private: |
147 int changing_count_; | 163 int changing_count_; |
148 int changed_count_; | 164 int changed_count_; |
149 | 165 |
150 int bounds_changed_count_; | 166 int bounds_changed_count_; |
| 167 int rotation_changed_count_; |
| 168 int workarea_changed_count_; |
151 int64 changed_display_id_; | 169 int64 changed_display_id_; |
152 | 170 |
153 int focus_changed_count_; | 171 int focus_changed_count_; |
154 int activation_changed_count_; | 172 int activation_changed_count_; |
155 | 173 |
156 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 174 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
157 }; | 175 }; |
158 | 176 |
159 gfx::Display GetPrimaryDisplay() { | 177 gfx::Display GetPrimaryDisplay() { |
160 return Shell::GetScreen()->GetDisplayNearestWindow( | 178 return Shell::GetScreen()->GetDisplayNearestWindow( |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 return; | 398 return; |
381 | 399 |
382 // Creates windows to catch activation change event. | 400 // Creates windows to catch activation change event. |
383 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 401 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
384 w1->Focus(); | 402 w1->Focus(); |
385 | 403 |
386 TestObserver observer; | 404 TestObserver observer; |
387 UpdateDisplay("500x500,400x400"); | 405 UpdateDisplay("500x500,400x400"); |
388 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 406 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
389 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 407 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 408 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
390 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 409 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
391 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 410 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
392 gfx::Insets insets(5, 5, 5, 5); | 411 gfx::Insets insets(5, 5, 5, 5); |
393 int64 secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); | 412 int64 secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); |
394 Shell::GetInstance()->display_manager()->UpdateWorkAreaOfDisplay( | 413 Shell::GetInstance()->display_manager()->UpdateWorkAreaOfDisplay( |
395 secondary_display_id, insets); | 414 secondary_display_id, insets); |
396 | 415 |
397 // Default layout is RIGHT. | 416 // Default layout is RIGHT. |
398 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 417 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
399 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString()); | 418 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString()); |
400 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString()); | 419 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString()); |
401 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 420 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
402 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 421 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
403 | 422 |
404 // Layout the secondary display to the bottom of the primary. | 423 // Layout the secondary display to the bottom of the primary. |
405 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); | 424 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); |
406 EXPECT_EQ(1, observer.CountAndReset()); | 425 EXPECT_EQ(1, observer.CountAndReset()); |
407 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 426 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 427 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
408 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 428 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
409 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 429 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
410 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 430 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
411 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 431 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
412 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString()); | 432 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString()); |
413 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString()); | 433 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString()); |
414 | 434 |
415 // Layout the secondary display to the left of the primary. | 435 // Layout the secondary display to the left of the primary. |
416 SetSecondaryDisplayLayout(DisplayLayout::LEFT); | 436 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
417 EXPECT_EQ(1, observer.CountAndReset()); | 437 EXPECT_EQ(1, observer.CountAndReset()); |
418 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 438 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 439 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
419 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 440 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
420 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 441 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
421 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 442 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
422 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 443 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
423 EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString()); | 444 EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString()); |
424 EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString()); | 445 EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString()); |
425 | 446 |
426 // Layout the secondary display to the top of the primary. | 447 // Layout the secondary display to the top of the primary. |
427 SetSecondaryDisplayLayout(DisplayLayout::TOP); | 448 SetSecondaryDisplayLayout(DisplayLayout::TOP); |
428 EXPECT_EQ(1, observer.CountAndReset()); | 449 EXPECT_EQ(1, observer.CountAndReset()); |
429 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 450 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 451 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
430 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 452 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
431 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 453 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
432 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 454 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
433 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 455 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
434 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString()); | 456 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString()); |
435 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString()); | 457 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString()); |
436 | 458 |
437 // Layout to the right with an offset. | 459 // Layout to the right with an offset. |
438 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, 300); | 460 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, 300); |
439 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 461 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
440 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 462 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 463 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
441 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 464 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
442 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 465 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
443 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 466 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
444 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 467 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
445 EXPECT_EQ("500,300 400x400", GetSecondaryDisplay().bounds().ToString()); | 468 EXPECT_EQ("500,300 400x400", GetSecondaryDisplay().bounds().ToString()); |
446 | 469 |
447 // Keep the minimum 100. | 470 // Keep the minimum 100. |
448 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, 490); | 471 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, 490); |
449 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 472 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
450 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 473 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 474 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
451 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 475 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
452 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 476 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
453 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 477 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
454 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 478 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
455 EXPECT_EQ("500,400 400x400", GetSecondaryDisplay().bounds().ToString()); | 479 EXPECT_EQ("500,400 400x400", GetSecondaryDisplay().bounds().ToString()); |
456 | 480 |
457 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, -400); | 481 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, -400); |
458 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 482 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
459 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 483 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 484 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
460 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 485 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
461 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 486 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
462 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 487 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
463 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 488 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
464 EXPECT_EQ("500,-300 400x400", GetSecondaryDisplay().bounds().ToString()); | 489 EXPECT_EQ("500,-300 400x400", GetSecondaryDisplay().bounds().ToString()); |
465 | 490 |
466 // Layout to the bottom with an offset. | 491 // Layout to the bottom with an offset. |
467 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -200); | 492 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -200); |
468 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 493 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
469 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 494 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 495 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
470 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 496 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
471 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 497 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
472 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 498 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
473 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 499 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
474 EXPECT_EQ("-200,500 400x400", GetSecondaryDisplay().bounds().ToString()); | 500 EXPECT_EQ("-200,500 400x400", GetSecondaryDisplay().bounds().ToString()); |
475 | 501 |
476 // Keep the minimum 100. | 502 // Keep the minimum 100. |
477 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, 490); | 503 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, 490); |
478 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 504 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
479 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 505 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 506 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
480 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 507 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
481 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 508 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
482 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 509 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
483 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 510 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
484 EXPECT_EQ("400,500 400x400", GetSecondaryDisplay().bounds().ToString()); | 511 EXPECT_EQ("400,500 400x400", GetSecondaryDisplay().bounds().ToString()); |
485 | 512 |
486 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -400); | 513 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -400); |
487 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); | 514 EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset()); |
488 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 515 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 516 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
489 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 517 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
490 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 518 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
491 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 519 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
492 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 520 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
493 EXPECT_EQ("-300,500 400x400", GetSecondaryDisplay().bounds().ToString()); | 521 EXPECT_EQ("-300,500 400x400", GetSecondaryDisplay().bounds().ToString()); |
494 | 522 |
495 // Setting the same layout shouldn't invoke observers. | 523 // Setting the same layout shouldn't invoke observers. |
496 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -400); | 524 SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -400); |
497 EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset()); | 525 EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset()); |
498 EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset()); | 526 EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset()); |
| 527 EXPECT_EQ(0, observer.GetWorkareaChangedCountAndReset()); |
499 EXPECT_EQ(0, observer.CountAndReset()); // resize and add | 528 EXPECT_EQ(0, observer.CountAndReset()); // resize and add |
500 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 529 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
501 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 530 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
502 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); | 531 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); |
503 EXPECT_EQ("-300,500 400x400", GetSecondaryDisplay().bounds().ToString()); | 532 EXPECT_EQ("-300,500 400x400", GetSecondaryDisplay().bounds().ToString()); |
504 | 533 |
505 UpdateDisplay("500x500"); | 534 UpdateDisplay("500x500"); |
506 EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); | 535 EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); |
507 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); | 536 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); |
508 } | 537 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 EXPECT_EQ("0,0 250x250", w1->bounds().ToString()); | 581 EXPECT_EQ("0,0 250x250", w1->bounds().ToString()); |
553 // Dock mode. | 582 // Dock mode. |
554 TestObserver observer; | 583 TestObserver observer; |
555 display_info_list.clear(); | 584 display_info_list.clear(); |
556 display_info_list.push_back(external_display_info); | 585 display_info_list.push_back(external_display_info); |
557 display_manager->OnNativeDisplaysChanged(display_info_list); | 586 display_manager->OnNativeDisplaysChanged(display_info_list); |
558 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 587 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
559 EXPECT_EQ(1U, display_manager->num_connected_displays()); | 588 EXPECT_EQ(1U, display_manager->num_connected_displays()); |
560 EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset()); | 589 EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset()); |
561 EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset()); | 590 EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset()); |
| 591 EXPECT_EQ(0, observer.GetWorkareaChangedCountAndReset()); |
562 EXPECT_EQ(1, observer.CountAndReset()); | 592 EXPECT_EQ(1, observer.CountAndReset()); |
563 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 593 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
564 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 594 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
565 | 595 |
566 EXPECT_TRUE(window_state->IsFullscreen()); | 596 EXPECT_TRUE(window_state->IsFullscreen()); |
567 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); | 597 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); |
568 } | 598 } |
569 | 599 |
570 TEST_F(DisplayControllerTest, BoundsUpdated) { | 600 TEST_F(DisplayControllerTest, BoundsUpdated) { |
571 if (!SupportsMultipleDisplays()) | 601 if (!SupportsMultipleDisplays()) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 EXPECT_EQ("0,0 200x250", GetPrimaryDisplay().bounds().ToString()); | 650 EXPECT_EQ("0,0 200x250", GetPrimaryDisplay().bounds().ToString()); |
621 EXPECT_EQ("0,250 300x300", GetSecondaryDisplay().bounds().ToString()); | 651 EXPECT_EQ("0,250 300x300", GetSecondaryDisplay().bounds().ToString()); |
622 | 652 |
623 // No change | 653 // No change |
624 UpdateDisplay("400x500*2,300x300"); | 654 UpdateDisplay("400x500*2,300x300"); |
625 EXPECT_EQ(0, observer.CountAndReset()); | 655 EXPECT_EQ(0, observer.CountAndReset()); |
626 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 656 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
627 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 657 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
628 | 658 |
629 // Rotation | 659 // Rotation |
| 660 observer.GetRotationChangedCountAndReset(); // we only want to reset. |
630 int64 primary_id = GetPrimaryDisplay().id(); | 661 int64 primary_id = GetPrimaryDisplay().id(); |
631 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); | 662 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); |
| 663 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
632 EXPECT_EQ(1, observer.CountAndReset()); | 664 EXPECT_EQ(1, observer.CountAndReset()); |
633 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 665 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
634 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 666 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
635 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); | 667 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); |
| 668 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); |
636 EXPECT_EQ(0, observer.CountAndReset()); | 669 EXPECT_EQ(0, observer.CountAndReset()); |
637 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 670 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
638 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 671 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
639 | 672 |
640 // UI scale is eanbled only on internal display. | 673 // UI scale is eanbled only on internal display. |
641 int64 secondary_id = GetSecondaryDisplay().id(); | 674 int64 secondary_id = GetSecondaryDisplay().id(); |
642 gfx::Display::SetInternalDisplayId(secondary_id); | 675 gfx::Display::SetInternalDisplayId(secondary_id); |
643 display_manager->SetDisplayUIScale(secondary_id, 1.125f); | 676 display_manager->SetDisplayUIScale(secondary_id, 1.125f); |
644 EXPECT_EQ(1, observer.CountAndReset()); | 677 EXPECT_EQ(1, observer.CountAndReset()); |
645 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 678 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1058 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1026 TestEventHandler event_handler; | 1059 TestEventHandler event_handler; |
1027 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1060 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1028 | 1061 |
1029 UpdateDisplay("120x200,300x400*2"); | 1062 UpdateDisplay("120x200,300x400*2"); |
1030 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1063 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
1031 int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); | 1064 int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); |
1032 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1065 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1033 aura::test::EventGenerator generator1(root_windows[0]); | 1066 aura::test::EventGenerator generator1(root_windows[0]); |
1034 | 1067 |
| 1068 TestObserver observer; |
1035 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1069 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
1036 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1070 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
1037 EXPECT_EQ("120,0 150x200", | 1071 EXPECT_EQ("120,0 150x200", |
1038 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1072 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1039 generator1.MoveMouseToInHost(50, 40); | 1073 generator1.MoveMouseToInHost(50, 40); |
1040 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); | 1074 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); |
1041 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); | 1075 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); |
1042 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 1076 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
| 1077 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); |
1043 | 1078 |
1044 display_manager->SetDisplayRotation(display1.id(), | 1079 display_manager->SetDisplayRotation(display1.id(), |
1045 gfx::Display::ROTATE_90); | 1080 gfx::Display::ROTATE_90); |
1046 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1081 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
1047 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1082 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
1048 EXPECT_EQ("200,0 150x200", | 1083 EXPECT_EQ("200,0 150x200", |
1049 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1084 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1050 generator1.MoveMouseToInHost(50, 40); | 1085 generator1.MoveMouseToInHost(50, 40); |
1051 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); | 1086 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); |
1052 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 1087 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
1053 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 1088 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
| 1089 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
1054 | 1090 |
1055 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); | 1091 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); |
1056 display_manager->SetLayoutForCurrentDisplays(display_layout); | 1092 display_manager->SetLayoutForCurrentDisplays(display_layout); |
1057 EXPECT_EQ("50,120 150x200", | 1093 EXPECT_EQ("50,120 150x200", |
1058 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1094 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1059 | 1095 |
1060 display_manager->SetDisplayRotation(display2_id, | 1096 display_manager->SetDisplayRotation(display2_id, |
1061 gfx::Display::ROTATE_270); | 1097 gfx::Display::ROTATE_270); |
1062 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1098 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
1063 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1099 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
1064 EXPECT_EQ("50,120 200x150", | 1100 EXPECT_EQ("50,120 200x150", |
1065 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1101 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1066 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 1102 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
1067 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 1103 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
| 1104 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
1068 | 1105 |
1069 #if !defined(OS_WIN) | 1106 #if !defined(OS_WIN) |
1070 aura::test::EventGenerator generator2(root_windows[1]); | 1107 aura::test::EventGenerator generator2(root_windows[1]); |
1071 generator2.MoveMouseToInHost(50, 40); | 1108 generator2.MoveMouseToInHost(50, 40); |
1072 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); | 1109 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); |
1073 display_manager->SetDisplayRotation(display1.id(), | 1110 display_manager->SetDisplayRotation(display1.id(), |
1074 gfx::Display::ROTATE_180); | 1111 gfx::Display::ROTATE_180); |
1075 | 1112 |
1076 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1113 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
1077 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1114 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
1078 // Dislay must share at least 100, so the x's offset becomes 20. | 1115 // Dislay must share at least 100, so the x's offset becomes 20. |
1079 EXPECT_EQ("20,200 200x150", | 1116 EXPECT_EQ("20,200 200x150", |
1080 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1117 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1081 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); | 1118 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); |
1082 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 1119 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
| 1120 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
1083 | 1121 |
1084 generator1.MoveMouseToInHost(50, 40); | 1122 generator1.MoveMouseToInHost(50, 40); |
1085 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); | 1123 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); |
1086 #endif | 1124 #endif |
1087 | 1125 |
1088 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1126 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
1089 } | 1127 } |
1090 | 1128 |
1091 TEST_F(DisplayControllerTest, ScaleRootWindow) { | 1129 TEST_F(DisplayControllerTest, ScaleRootWindow) { |
1092 if (!SupportsMultipleDisplays()) | 1130 if (!SupportsMultipleDisplays()) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); | 1331 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); |
1294 | 1332 |
1295 // Switching back to single display. | 1333 // Switching back to single display. |
1296 UpdateDisplay("300x400"); | 1334 UpdateDisplay("300x400"); |
1297 EXPECT_EQ("aura_root_0", GetXWindowName( | 1335 EXPECT_EQ("aura_root_0", GetXWindowName( |
1298 Shell::GetPrimaryRootWindow()->GetHost())); | 1336 Shell::GetPrimaryRootWindow()->GetHost())); |
1299 } | 1337 } |
1300 #endif | 1338 #endif |
1301 | 1339 |
1302 } // namespace ash | 1340 } // namespace ash |
OLD | NEW |