| 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/monitor/multi_monitor_manager.h" | 5 #include "ash/monitor/multi_monitor_manager.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public: | 44 public: |
| 45 MultiMonitorManagerTest() | 45 MultiMonitorManagerTest() |
| 46 : removed_count_(0U), | 46 : removed_count_(0U), |
| 47 root_window_destroyed_(false) { | 47 root_window_destroyed_(false) { |
| 48 } | 48 } |
| 49 virtual ~MultiMonitorManagerTest() {} | 49 virtual ~MultiMonitorManagerTest() {} |
| 50 | 50 |
| 51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() OVERRIDE { |
| 52 AshTestBase::SetUp(); | 52 AshTestBase::SetUp(); |
| 53 monitor_manager()->AddObserver(this); | 53 monitor_manager()->AddObserver(this); |
| 54 Shell::GetRootWindow()->AddObserver(this); | 54 Shell::GetPrimaryRootWindow()->AddObserver(this); |
| 55 } | 55 } |
| 56 virtual void TearDown() OVERRIDE { | 56 virtual void TearDown() OVERRIDE { |
| 57 Shell::GetRootWindow()->RemoveObserver(this); | 57 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
| 58 monitor_manager()->RemoveObserver(this); | 58 monitor_manager()->RemoveObserver(this); |
| 59 AshTestBase::TearDown(); | 59 AshTestBase::TearDown(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 aura::MonitorManager* monitor_manager() { | 62 aura::MonitorManager* monitor_manager() { |
| 63 return aura::Env::GetInstance()->monitor_manager(); | 63 return aura::Env::GetInstance()->monitor_manager(); |
| 64 } | 64 } |
| 65 const vector<Monitor>& changed() const { return changed_; } | 65 const vector<Monitor>& changed() const { return changed_; } |
| 66 const vector<Monitor>& added() const { return added_; } | 66 const vector<Monitor>& added() const { return added_; } |
| 67 | 67 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 87 } | 87 } |
| 88 virtual void OnMonitorAdded(const Monitor& new_monitor) OVERRIDE { | 88 virtual void OnMonitorAdded(const Monitor& new_monitor) OVERRIDE { |
| 89 added_.push_back(new_monitor); | 89 added_.push_back(new_monitor); |
| 90 } | 90 } |
| 91 virtual void OnMonitorRemoved(const Monitor& old_monitor) OVERRIDE { | 91 virtual void OnMonitorRemoved(const Monitor& old_monitor) OVERRIDE { |
| 92 ++removed_count_; | 92 ++removed_count_; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // aura::WindowObserver overrides: | 95 // aura::WindowObserver overrides: |
| 96 virtual void OnWindowDestroying(aura::Window* window) { | 96 virtual void OnWindowDestroying(aura::Window* window) { |
| 97 ASSERT_EQ(Shell::GetRootWindow(), window); | 97 ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); |
| 98 root_window_destroyed_ = true; | 98 root_window_destroyed_ = true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void UpdateMonitor(const std::string str) { | 101 void UpdateMonitor(const std::string str) { |
| 102 vector<Monitor> monitors = CreateMonitorsFromString(str); | 102 vector<Monitor> monitors = CreateMonitorsFromString(str); |
| 103 monitor_manager()->OnNativeMonitorsChanged(monitors); | 103 monitor_manager()->OnNativeMonitorsChanged(monitors); |
| 104 } | 104 } |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 vector<Monitor> changed_; | 107 vector<Monitor> changed_; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 reset(); | 227 reset(); |
| 228 | 228 |
| 229 internal::MultiMonitorManager::CycleMonitor(); | 229 internal::MultiMonitorManager::CycleMonitor(); |
| 230 EXPECT_EQ(1U, monitor_manager()->GetNumMonitors()); | 230 EXPECT_EQ(1U, monitor_manager()->GetNumMonitors()); |
| 231 EXPECT_EQ("0 0 0", GetCountSummary()); | 231 EXPECT_EQ("0 0 0", GetCountSummary()); |
| 232 reset(); | 232 reset(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace test | 235 } // namespace test |
| 236 } // namespace ash | 236 } // namespace ash |
| OLD | NEW |