Chromium Code Reviews| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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), | 70 rotation_changed_count_(0), |
| 71 workarea_changed_count_(0), | 71 workarea_changed_count_(0), |
| 72 primary_changed_count_(0), | |
| 72 changed_display_id_(0), | 73 changed_display_id_(0), |
| 73 focus_changed_count_(0), | 74 focus_changed_count_(0), |
| 74 activation_changed_count_(0) { | 75 activation_changed_count_(0) { |
| 75 Shell::GetInstance()->display_controller()->AddObserver(this); | 76 Shell::GetInstance()->display_controller()->AddObserver(this); |
| 76 Shell::GetScreen()->AddObserver(this); | 77 Shell::GetScreen()->AddObserver(this); |
| 77 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> | 78 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> |
| 78 AddObserver(this); | 79 AddObserver(this); |
| 79 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 80 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| 80 AddObserver(this); | 81 AddObserver(this); |
| 81 } | 82 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 95 | 96 |
| 96 // Overrideen from gfx::DisplayObserver | 97 // Overrideen from gfx::DisplayObserver |
| 97 void OnDisplayMetricsChanged(const gfx::Display& display, | 98 void OnDisplayMetricsChanged(const gfx::Display& display, |
| 98 uint32_t metrics) override { | 99 uint32_t metrics) override { |
| 99 changed_display_id_ = display.id(); | 100 changed_display_id_ = display.id(); |
| 100 if (metrics & DISPLAY_METRIC_BOUNDS) | 101 if (metrics & DISPLAY_METRIC_BOUNDS) |
| 101 ++bounds_changed_count_; | 102 ++bounds_changed_count_; |
| 102 if (metrics & DISPLAY_METRIC_ROTATION) | 103 if (metrics & DISPLAY_METRIC_ROTATION) |
| 103 ++rotation_changed_count_; | 104 ++rotation_changed_count_; |
| 104 if (metrics & DISPLAY_METRIC_WORK_AREA) | 105 if (metrics & DISPLAY_METRIC_WORK_AREA) |
| 105 ++workarea_changed_count_; | 106 ++workarea_changed_count_; |
|
Jun Mukai
2014/11/20 01:34:19
increment primary_changed_count_?
oshima
2014/11/20 01:45:47
oops, fixed. looks like I run the test on wrong co
| |
| 106 } | 107 } |
| 107 void OnDisplayAdded(const gfx::Display& new_display) override {} | 108 void OnDisplayAdded(const gfx::Display& new_display) override {} |
| 108 void OnDisplayRemoved(const gfx::Display& old_display) override {} | 109 void OnDisplayRemoved(const gfx::Display& old_display) override {} |
| 109 | 110 |
| 110 // Overridden from aura::client::FocusChangeObserver | 111 // Overridden from aura::client::FocusChangeObserver |
| 111 void OnWindowFocused(aura::Window* gained_focus, | 112 void OnWindowFocused(aura::Window* gained_focus, |
| 112 aura::Window* lost_focus) override { | 113 aura::Window* lost_focus) override { |
| 113 focus_changed_count_++; | 114 focus_changed_count_++; |
| 114 } | 115 } |
| 115 | 116 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 132 } | 133 } |
| 133 | 134 |
| 134 int64 GetRotationChangedCountAndReset() { | 135 int64 GetRotationChangedCountAndReset() { |
| 135 return Resetter<int>(&rotation_changed_count_).value(); | 136 return Resetter<int>(&rotation_changed_count_).value(); |
| 136 } | 137 } |
| 137 | 138 |
| 138 int64 GetWorkareaChangedCountAndReset() { | 139 int64 GetWorkareaChangedCountAndReset() { |
| 139 return Resetter<int>(&workarea_changed_count_).value(); | 140 return Resetter<int>(&workarea_changed_count_).value(); |
| 140 } | 141 } |
| 141 | 142 |
| 143 int64 GetPrimaryChangedCountAndReset() { | |
| 144 return Resetter<int>(&primary_changed_count_).value(); | |
| 145 } | |
| 146 | |
| 142 int64 GetChangedDisplayIdAndReset() { | 147 int64 GetChangedDisplayIdAndReset() { |
| 143 return Resetter<int64>(&changed_display_id_).value(); | 148 return Resetter<int64>(&changed_display_id_).value(); |
| 144 } | 149 } |
| 145 | 150 |
| 146 int GetFocusChangedCountAndReset() { | 151 int GetFocusChangedCountAndReset() { |
| 147 return Resetter<int>(&focus_changed_count_).value(); | 152 return Resetter<int>(&focus_changed_count_).value(); |
| 148 } | 153 } |
| 149 | 154 |
| 150 int GetActivationChangedCountAndReset() { | 155 int GetActivationChangedCountAndReset() { |
| 151 return Resetter<int>(&activation_changed_count_).value(); | 156 return Resetter<int>(&activation_changed_count_).value(); |
| 152 } | 157 } |
| 153 | 158 |
| 154 private: | 159 private: |
| 155 int changing_count_; | 160 int changing_count_; |
| 156 int changed_count_; | 161 int changed_count_; |
| 157 | 162 |
| 158 int bounds_changed_count_; | 163 int bounds_changed_count_; |
| 159 int rotation_changed_count_; | 164 int rotation_changed_count_; |
| 160 int workarea_changed_count_; | 165 int workarea_changed_count_; |
| 166 int private_changed_count_; | |
| 161 int64 changed_display_id_; | 167 int64 changed_display_id_; |
| 162 | 168 |
| 163 int focus_changed_count_; | 169 int focus_changed_count_; |
| 164 int activation_changed_count_; | 170 int activation_changed_count_; |
| 165 | 171 |
| 166 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 172 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 167 }; | 173 }; |
| 168 | 174 |
| 169 gfx::Display GetPrimaryDisplay() { | 175 gfx::Display GetPrimaryDisplay() { |
| 170 return Shell::GetScreen()->GetDisplayNearestWindow( | 176 return Shell::GetScreen()->GetDisplayNearestWindow( |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 window_state->OnWMEvent(&toggle_fullscreen_event); | 580 window_state->OnWMEvent(&toggle_fullscreen_event); |
| 575 EXPECT_TRUE(window_state->IsFullscreen()); | 581 EXPECT_TRUE(window_state->IsFullscreen()); |
| 576 EXPECT_EQ("0,0 250x250", w1->bounds().ToString()); | 582 EXPECT_EQ("0,0 250x250", w1->bounds().ToString()); |
| 577 // Dock mode. | 583 // Dock mode. |
| 578 TestObserver observer; | 584 TestObserver observer; |
| 579 display_info_list.clear(); | 585 display_info_list.clear(); |
| 580 display_info_list.push_back(external_display_info); | 586 display_info_list.push_back(external_display_info); |
| 581 display_manager->OnNativeDisplaysChanged(display_info_list); | 587 display_manager->OnNativeDisplaysChanged(display_info_list); |
| 582 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 588 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
| 583 EXPECT_EQ(1U, display_manager->num_connected_displays()); | 589 EXPECT_EQ(1U, display_manager->num_connected_displays()); |
| 584 EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset()); | 590 // Observers are called due to primary change. |
| 585 EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset()); | 591 EXPECT_EQ(2, observer.GetChangedDisplayIdAndReset()); |
| 586 EXPECT_EQ(0, observer.GetWorkareaChangedCountAndReset()); | 592 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 593 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); | |
| 594 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset()); | |
| 587 EXPECT_EQ(1, observer.CountAndReset()); | 595 EXPECT_EQ(1, observer.CountAndReset()); |
| 588 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 596 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 589 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 597 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 590 | 598 |
| 591 EXPECT_TRUE(window_state->IsFullscreen()); | 599 EXPECT_TRUE(window_state->IsFullscreen()); |
| 592 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); | 600 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); |
| 593 } | 601 } |
| 594 | 602 |
| 595 TEST_F(DisplayControllerTest, BoundsUpdated) { | 603 TEST_F(DisplayControllerTest, BoundsUpdated) { |
| 596 if (!SupportsMultipleDisplays()) | 604 if (!SupportsMultipleDisplays()) |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1327 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); | 1335 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); |
| 1328 | 1336 |
| 1329 // Switching back to single display. | 1337 // Switching back to single display. |
| 1330 UpdateDisplay("300x400"); | 1338 UpdateDisplay("300x400"); |
| 1331 EXPECT_EQ("aura_root_0", GetXWindowName( | 1339 EXPECT_EQ("aura_root_0", GetXWindowName( |
| 1332 Shell::GetPrimaryRootWindow()->GetHost())); | 1340 Shell::GetPrimaryRootWindow()->GetHost())); |
| 1333 } | 1341 } |
| 1334 #endif | 1342 #endif |
| 1335 | 1343 |
| 1336 } // namespace ash | 1344 } // namespace ash |
| OLD | NEW |