summaryrefslogtreecommitdiffstats
path: root/ash/monitor
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-24 05:07:35 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-24 05:07:35 +0000
commitf5ffdd6d4fc7685ab53fe6b3ec3dbc95e096e212 (patch)
treeec147c1886446f65a61eb6585ac5c9c79f911392 /ash/monitor
parentc691139a2747f30575b6728bfd082f1b7397d6f4 (diff)
downloadchromium_src-f5ffdd6d4fc7685ab53fe6b3ec3dbc95e096e212.zip
chromium_src-f5ffdd6d4fc7685ab53fe6b3ec3dbc95e096e212.tar.gz
chromium_src-f5ffdd6d4fc7685ab53fe6b3ec3dbc95e096e212.tar.bz2
Revert 128684 - Appears to have an infinite loop in a unit test due to not adhering to a post-condition.
Don't delete Primary monitor and it's root window when # of monitors goes zero. BUG=none TEST=nonoe Review URL: http://codereview.chromium.org/9835068 TBR=oshima@chromium.org Review URL: https://chromiumcodereview.appspot.com/9837080 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/monitor')
-rw-r--r--ash/monitor/monitor_controller.cc14
-rw-r--r--ash/monitor/multi_monitor_manager.cc6
-rw-r--r--ash/monitor/multi_monitor_manager_unittest.cc57
3 files changed, 6 insertions, 71 deletions
diff --git a/ash/monitor/monitor_controller.cc b/ash/monitor/monitor_controller.cc
index 9574c9d..397e5ab 100644
--- a/ash/monitor/monitor_controller.cc
+++ b/ash/monitor/monitor_controller.cc
@@ -58,11 +58,6 @@ void MonitorController::OnMonitorBoundsChanged(const aura::Monitor* monitor) {
}
void MonitorController::OnMonitorAdded(aura::Monitor* monitor) {
- if (root_windows_.empty()) {
- root_windows_[monitor] = Shell::GetRootWindow();
- Shell::GetRootWindow()->SetHostBounds(monitor->bounds());
- return;
- }
aura::RootWindow* root = aura::Env::GetInstance()->monitor_manager()->
CreateRootWindowForMonitor(monitor);
root_windows_[monitor] = root;
@@ -71,13 +66,8 @@ void MonitorController::OnMonitorAdded(aura::Monitor* monitor) {
void MonitorController::OnMonitorRemoved(const aura::Monitor* monitor) {
aura::RootWindow* root = root_windows_[monitor];
- DCHECK(root);
- // Monitor for root window will be deleted when the Primary RootWindow
- // is deleted by the Shell.
- if (root != Shell::GetRootWindow()) {
- root_windows_.erase(monitor);
- delete root;
- }
+ root_windows_.erase(monitor);
+ delete root;
}
void MonitorController::Init() {
diff --git a/ash/monitor/multi_monitor_manager.cc b/ash/monitor/multi_monitor_manager.cc
index 36242af..8ed2de9 100644
--- a/ash/monitor/multi_monitor_manager.cc
+++ b/ash/monitor/multi_monitor_manager.cc
@@ -90,10 +90,8 @@ void MultiMonitorManager::OnNativeMonitorsChanged(
NotifyMonitorAdded(monitor);
}
} else {
- // Monitors are removed. We keep the monitor for the primary
- // monitor (at index 0) because it needs the monitor information
- // even if it doesn't exit.
- while (monitors_.size() > new_monitors.size() && monitors_.size() > 1) {
+ // Monitors are removed.
+ while (monitors_.size() > new_monitors.size()) {
Monitor* monitor = monitors_.back();
// Monitor object is deleted in OnWindowDestroying.
NotifyMonitorRemoved(monitor);
diff --git a/ash/monitor/multi_monitor_manager_unittest.cc b/ash/monitor/multi_monitor_manager_unittest.cc
index e163831..336f91c 100644
--- a/ash/monitor/multi_monitor_manager_unittest.cc
+++ b/ash/monitor/multi_monitor_manager_unittest.cc
@@ -13,7 +13,6 @@
#include "ui/aura/env.h"
#include "ui/aura/monitor.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/window_observer.h"
namespace ash {
namespace test {
@@ -39,22 +38,16 @@ vector<const aura::Monitor*> CreateMonitorsFromString(
} // namespace
class MultiMonitorManagerTest : public test::AshTestBase,
- public aura::MonitorObserver,
- public aura::WindowObserver {
+ public aura::MonitorObserver {
public:
- MultiMonitorManagerTest()
- : removed_count_(0U),
- root_window_destroyed_(false) {
- }
+ MultiMonitorManagerTest() : removed_count_(0U) {}
virtual ~MultiMonitorManagerTest() {}
virtual void SetUp() OVERRIDE {
AshTestBase::SetUp();
monitor_manager()->AddObserver(this);
- Shell::GetRootWindow()->AddObserver(this);
}
virtual void TearDown() OVERRIDE {
- Shell::GetRootWindow()->RemoveObserver(this);
monitor_manager()->RemoveObserver(this);
AshTestBase::TearDown();
}
@@ -74,11 +67,6 @@ class MultiMonitorManagerTest : public test::AshTestBase,
changed_.clear();
added_.clear();
removed_count_ = 0U;
- root_window_destroyed_ = false;
- }
-
- bool root_window_destroyed() const {
- return root_window_destroyed_;
}
// aura::MonitorObserver overrides:
@@ -92,12 +80,6 @@ class MultiMonitorManagerTest : public test::AshTestBase,
++removed_count_;
}
- // aura::WindowObserver overrides:
- virtual void OnWindowDestroying(aura::Window* window) {
- ASSERT_EQ(Shell::GetRootWindow(), window);
- root_window_destroyed_ = true;
- }
-
void UpdateMonitor(const std::string str) {
vector<const aura::Monitor*> monitors = CreateMonitorsFromString(str);
monitor_manager()->OnNativeMonitorsChanged(monitors);
@@ -108,7 +90,6 @@ class MultiMonitorManagerTest : public test::AshTestBase,
vector<const Monitor*> changed_;
vector<const Monitor*> added_;
size_t removed_count_;
- bool root_window_destroyed_;
DISALLOW_COPY_AND_ASSIGN(MultiMonitorManagerTest);
};
@@ -154,40 +135,6 @@ TEST_F(MultiMonitorManagerTest, NativeMonitorTest) {
EXPECT_EQ("1 0 1", GetCountSummary());
EXPECT_EQ(monitor_manager()->GetMonitorAt(0), changed()[0]);
EXPECT_EQ("0,0 800x300", changed()[0]->bounds().ToString());
- reset();
-
- // # of monitor can go to zero when screen is off.
- const vector<const Monitor*> empty;
- monitor_manager()->OnNativeMonitorsChanged(empty);
- EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
- EXPECT_EQ("0 0 0", GetCountSummary());
- EXPECT_FALSE(root_window_destroyed());
- // Monitor configuration stays the same
- EXPECT_EQ("0,0 800x300", changed()[0]->bounds().ToString());
- reset();
-
- // Connect to monitor again
- UpdateMonitor("100+100-500x400");
- EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
- EXPECT_EQ("1 0 0", GetCountSummary());
- EXPECT_FALSE(root_window_destroyed());
- EXPECT_EQ("100,100 500x400", changed()[0]->bounds().ToString());
- reset();
-
- // Go back to zero and wake up with multiple monitors.
- monitor_manager()->OnNativeMonitorsChanged(empty);
- EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
- EXPECT_FALSE(root_window_destroyed());
- reset();
-
- // Add secondary.
- UpdateMonitor("0+0-1000x600,1000+0-600x400");
- EXPECT_EQ(2U, monitor_manager()->GetNumMonitors());
- EXPECT_EQ("0,0 1000x600",
- monitor_manager()->GetMonitorAt(0)->bounds().ToString());
- EXPECT_EQ("1000,0 600x400",
- monitor_manager()->GetMonitorAt(1)->bounds().ToString());
- reset();
aura::MonitorManager::set_use_fullscreen_host_window(false);
}