| 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/test/display_manager_test_api.h" | 5 #include "ash/test/display_manager_test_api.h" |
| 6 | 6 |
| 7 #include <cstdarg> | 7 #include <cstdarg> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| 11 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
| 12 #include "ash/display/display_util.h" | |
| 13 #include "ash/display/extended_mouse_warp_controller.h" | 12 #include "ash/display/extended_mouse_warp_controller.h" |
| 14 #include "ash/display/mouse_cursor_event_filter.h" | 13 #include "ash/display/mouse_cursor_event_filter.h" |
| 15 #include "ash/display/unified_mouse_warp_controller.h" | 14 #include "ash/display/unified_mouse_warp_controller.h" |
| 16 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
| 17 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 18 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 19 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 20 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
| 22 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
| 23 #include "ui/display/manager/display_layout_builder.h" | 22 #include "ui/display/manager/display_layout_builder.h" |
| 23 #include "ui/display/manager/display_manager_utilities.h" |
| 24 #include "ui/display/manager/managed_display_info.h" | 24 #include "ui/display/manager/managed_display_info.h" |
| 25 #include "ui/events/test/event_generator.h" | 25 #include "ui/events/test/event_generator.h" |
| 26 | 26 |
| 27 namespace ash { | 27 namespace ash { |
| 28 namespace test { | 28 namespace test { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 DisplayInfoList CreateDisplayInfoListFromString( | 31 DisplayInfoList CreateDisplayInfoListFromString( |
| 32 const std::string specs, | 32 const std::string specs, |
| 33 DisplayManager* display_manager) { | 33 DisplayManager* display_manager) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() { | 151 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() { |
| 152 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); | 152 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool SetDisplayResolution(int64_t display_id, const gfx::Size& resolution) { | 155 bool SetDisplayResolution(int64_t display_id, const gfx::Size& resolution) { |
| 156 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 156 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 157 const ui::ManagedDisplayInfo& info = | 157 const ui::ManagedDisplayInfo& info = |
| 158 display_manager->GetDisplayInfo(display_id); | 158 display_manager->GetDisplayInfo(display_id); |
| 159 scoped_refptr<ui::ManagedDisplayMode> mode = | 159 scoped_refptr<ui::ManagedDisplayMode> mode = |
| 160 GetDisplayModeForResolution(info, resolution); | 160 ui::GetDisplayModeForResolution(info, resolution); |
| 161 if (!mode) | 161 if (!mode) |
| 162 return false; | 162 return false; |
| 163 return display_manager->SetDisplayMode(display_id, mode); | 163 return display_manager->SetDisplayMode(display_id, mode); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SwapPrimaryDisplay() { | 166 void SwapPrimaryDisplay() { |
| 167 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) | 167 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) |
| 168 return; | 168 return; |
| 169 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 169 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
| 170 ScreenUtil::GetSecondaryDisplay().id()); | 170 ScreenUtil::GetSecondaryDisplay().id()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 std::unique_ptr<display::DisplayLayout> CreateDisplayLayout( | 173 std::unique_ptr<display::DisplayLayout> CreateDisplayLayout( |
| 174 display::DisplayPlacement::Position position, | 174 display::DisplayPlacement::Position position, |
| 175 int offset) { | 175 int offset) { |
| 176 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 176 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 177 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); | 177 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 178 | 178 |
| 179 display::DisplayLayoutBuilder builder( | 179 display::DisplayLayoutBuilder builder( |
| 180 display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 180 display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 181 builder.SetSecondaryPlacement(ScreenUtil::GetSecondaryDisplay().id(), | 181 builder.SetSecondaryPlacement(ScreenUtil::GetSecondaryDisplay().id(), |
| 182 position, offset); | 182 position, offset); |
| 183 return builder.Build(); | 183 return builder.Build(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 display::DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2) { | 186 display::DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2) { |
| 187 display::DisplayIdList list; | 187 display::DisplayIdList list; |
| 188 list.push_back(id1); | 188 list.push_back(id1); |
| 189 list.push_back(id2); | 189 list.push_back(id2); |
| 190 SortDisplayIdList(&list); | 190 ui::SortDisplayIdList(&list); |
| 191 return list; | 191 return list; |
| 192 } | 192 } |
| 193 | 193 |
| 194 display::DisplayIdList CreateDisplayIdListN(size_t count, ...) { | 194 display::DisplayIdList CreateDisplayIdListN(size_t count, ...) { |
| 195 display::DisplayIdList list; | 195 display::DisplayIdList list; |
| 196 va_list args; | 196 va_list args; |
| 197 va_start(args, count); | 197 va_start(args, count); |
| 198 for (size_t i = 0; i < count; i++) { | 198 for (size_t i = 0; i < count; i++) { |
| 199 int64_t id = va_arg(args, int64_t); | 199 int64_t id = va_arg(args, int64_t); |
| 200 list.push_back(id); | 200 list.push_back(id); |
| 201 } | 201 } |
| 202 SortDisplayIdList(&list); | 202 ui::SortDisplayIdList(&list); |
| 203 return list; | 203 return list; |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace test | 206 } // namespace test |
| 207 } // namespace ash | 207 } // namespace ash |
| OLD | NEW |