| 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/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/aura/monitor.h" | 14 #include "ui/aura/monitor_observer.h" |
| 15 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
| 17 #include "ui/gfx/monitor.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 namespace test { | 20 namespace test { |
| 20 | 21 |
| 21 using std::vector; | 22 using std::vector; |
| 22 using std::string; | 23 using std::string; |
| 23 using aura::Monitor; | 24 using gfx::Monitor; |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 vector<const aura::Monitor*> CreateMonitorsFromString( | 28 vector<const Monitor*> CreateMonitorsFromString( |
| 28 const std::string specs) { | 29 const std::string specs) { |
| 29 vector<const aura::Monitor*> monitors; | 30 vector<const Monitor*> monitors; |
| 30 vector<string> parts; | 31 vector<string> parts; |
| 31 base::SplitString(specs, ',', &parts); | 32 base::SplitString(specs, ',', &parts); |
| 32 for (vector<string>::const_iterator iter = parts.begin(); | 33 for (vector<string>::const_iterator iter = parts.begin(); |
| 33 iter != parts.end(); ++iter) { | 34 iter != parts.end(); ++iter) { |
| 34 monitors.push_back(aura::MonitorManager::CreateMonitorFromSpec(*iter)); | 35 monitors.push_back(aura::MonitorManager::CreateMonitorFromSpec(*iter)); |
| 35 } | 36 } |
| 36 return monitors; | 37 return monitors; |
| 37 } | 38 } |
| 38 | 39 |
| 39 } // namespace | 40 } // namespace |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ++removed_count_; | 93 ++removed_count_; |
| 93 } | 94 } |
| 94 | 95 |
| 95 // aura::WindowObserver overrides: | 96 // aura::WindowObserver overrides: |
| 96 virtual void OnWindowDestroying(aura::Window* window) { | 97 virtual void OnWindowDestroying(aura::Window* window) { |
| 97 ASSERT_EQ(Shell::GetRootWindow(), window); | 98 ASSERT_EQ(Shell::GetRootWindow(), window); |
| 98 root_window_destroyed_ = true; | 99 root_window_destroyed_ = true; |
| 99 } | 100 } |
| 100 | 101 |
| 101 void UpdateMonitor(const std::string str) { | 102 void UpdateMonitor(const std::string str) { |
| 102 vector<const aura::Monitor*> monitors = CreateMonitorsFromString(str); | 103 vector<const Monitor*> monitors = CreateMonitorsFromString(str); |
| 103 monitor_manager()->OnNativeMonitorsChanged(monitors); | 104 monitor_manager()->OnNativeMonitorsChanged(monitors); |
| 104 STLDeleteContainerPointers(monitors.begin(), monitors.end()); | 105 STLDeleteContainerPointers(monitors.begin(), monitors.end()); |
| 105 } | 106 } |
| 106 | 107 |
| 107 private: | 108 private: |
| 108 vector<const Monitor*> changed_; | 109 vector<const Monitor*> changed_; |
| 109 vector<const Monitor*> added_; | 110 vector<const Monitor*> added_; |
| 110 size_t removed_count_; | 111 size_t removed_count_; |
| 111 bool root_window_destroyed_; | 112 bool root_window_destroyed_; |
| 112 | 113 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 reset(); | 224 reset(); |
| 224 | 225 |
| 225 internal::MultiMonitorManager::CycleMonitor(); | 226 internal::MultiMonitorManager::CycleMonitor(); |
| 226 EXPECT_EQ(1U, monitor_manager()->GetNumMonitors()); | 227 EXPECT_EQ(1U, monitor_manager()->GetNumMonitors()); |
| 227 EXPECT_EQ("0 0 0", GetCountSummary()); | 228 EXPECT_EQ("0 0 0", GetCountSummary()); |
| 228 reset(); | 229 reset(); |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace test | 232 } // namespace test |
| 232 } // namespace ash | 233 } // namespace ash |
| OLD | NEW |