| 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/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/display/display_info.h" | 11 #include "ash/display/display_info.h" |
| 12 #include "ash/display/display_layout_builder.h" | |
| 13 #include "ash/display/display_layout_store.h" | 12 #include "ash/display/display_layout_store.h" |
| 14 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/display_util.h" | 14 #include "ash/display/display_util.h" |
| 16 #include "ash/display/extended_mouse_warp_controller.h" | 15 #include "ash/display/extended_mouse_warp_controller.h" |
| 17 #include "ash/display/mouse_cursor_event_filter.h" | 16 #include "ash/display/mouse_cursor_event_filter.h" |
| 18 #include "ash/display/unified_mouse_warp_controller.h" | 17 #include "ash/display/unified_mouse_warp_controller.h" |
| 19 #include "ash/screen_util.h" | 18 #include "ash/screen_util.h" |
| 20 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 21 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| 22 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
| 23 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 24 #include "ui/aura/window_event_dispatcher.h" | 23 #include "ui/aura/window_event_dispatcher.h" |
| 24 #include "ui/display/manager/display_layout_builder.h" |
| 25 #include "ui/events/test/event_generator.h" | 25 #include "ui/events/test/event_generator.h" |
| 26 #include "ui/gfx/display.h" | 26 #include "ui/gfx/display.h" |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 namespace test { | 29 namespace test { |
| 30 typedef std::vector<gfx::Display> DisplayList; | |
| 31 typedef DisplayInfo DisplayInfo; | |
| 32 typedef std::vector<DisplayInfo> DisplayInfoList; | |
| 33 | |
| 34 namespace { | 30 namespace { |
| 35 | 31 |
| 36 std::vector<DisplayInfo> CreateDisplayInfoListFromString( | 32 std::vector<DisplayInfo> CreateDisplayInfoListFromString( |
| 37 const std::string specs, | 33 const std::string specs, |
| 38 DisplayManager* display_manager) { | 34 DisplayManager* display_manager) { |
| 39 std::vector<DisplayInfo> display_info_list; | 35 std::vector<DisplayInfo> display_info_list; |
| 40 std::vector<std::string> parts = base::SplitString( | 36 std::vector<std::string> parts = base::SplitString( |
| 41 specs, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 37 specs, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 42 size_t index = 0; | 38 size_t index = 0; |
| 43 | 39 |
| 44 DisplayList list = display_manager->IsInUnifiedMode() | 40 display::DisplayList list = |
| 45 ? display_manager->software_mirroring_display_list() | 41 display_manager->IsInUnifiedMode() |
| 46 : display_manager->active_display_list(); | 42 ? display_manager->software_mirroring_display_list() |
| 43 : display_manager->active_display_list(); |
| 47 | 44 |
| 48 for (std::vector<std::string>::const_iterator iter = parts.begin(); | 45 for (std::vector<std::string>::const_iterator iter = parts.begin(); |
| 49 iter != parts.end(); ++iter, ++index) { | 46 iter != parts.end(); ++iter, ++index) { |
| 50 int64_t id = (index < list.size()) ? list[index].id() | 47 int64_t id = (index < list.size()) ? list[index].id() |
| 51 : gfx::Display::kInvalidDisplayID; | 48 : gfx::Display::kInvalidDisplayID; |
| 52 display_info_list.push_back( | 49 display_info_list.push_back( |
| 53 DisplayInfo::CreateFromSpecWithID(*iter, id)); | 50 DisplayInfo::CreateFromSpecWithID(*iter, id)); |
| 54 } | 51 } |
| 55 return display_info_list; | 52 return display_info_list; |
| 56 } | 53 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return display_manager->SetDisplayMode(display_id, mode); | 164 return display_manager->SetDisplayMode(display_id, mode); |
| 168 } | 165 } |
| 169 | 166 |
| 170 void SwapPrimaryDisplay() { | 167 void SwapPrimaryDisplay() { |
| 171 if (gfx::Screen::GetScreen()->GetNumDisplays() <= 1) | 168 if (gfx::Screen::GetScreen()->GetNumDisplays() <= 1) |
| 172 return; | 169 return; |
| 173 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 170 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
| 174 ScreenUtil::GetSecondaryDisplay().id()); | 171 ScreenUtil::GetSecondaryDisplay().id()); |
| 175 } | 172 } |
| 176 | 173 |
| 177 scoped_ptr<DisplayLayout> CreateDisplayLayout( | 174 scoped_ptr<display::DisplayLayout> CreateDisplayLayout( |
| 178 DisplayPlacement::Position position, | 175 display::DisplayPlacement::Position position, |
| 179 int offset) { | 176 int offset) { |
| 180 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 177 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 181 DisplayIdList list = display_manager->GetCurrentDisplayIdList(); | 178 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 182 | 179 |
| 183 DisplayLayoutBuilder builder( | 180 display::DisplayLayoutBuilder builder( |
| 184 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); | 181 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 185 builder.SetSecondaryPlacement(ScreenUtil::GetSecondaryDisplay().id(), | 182 builder.SetSecondaryPlacement(ScreenUtil::GetSecondaryDisplay().id(), |
| 186 position, offset); | 183 position, offset); |
| 187 return builder.Build(); | 184 return builder.Build(); |
| 188 } | 185 } |
| 189 | 186 |
| 190 DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2) { | 187 display::DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2) { |
| 191 DisplayIdList list; | 188 display::DisplayIdList list; |
| 192 list.push_back(id1); | 189 list.push_back(id1); |
| 193 list.push_back(id2); | 190 list.push_back(id2); |
| 194 SortDisplayIdList(&list); | 191 SortDisplayIdList(&list); |
| 195 return list; | 192 return list; |
| 196 } | 193 } |
| 197 | 194 |
| 198 DisplayIdList CreateDisplayIdListN(size_t count, ...) { | 195 display::DisplayIdList CreateDisplayIdListN(size_t count, ...) { |
| 199 DisplayIdList list; | 196 display::DisplayIdList list; |
| 200 va_list args; | 197 va_list args; |
| 201 va_start(args, count); | 198 va_start(args, count); |
| 202 for (size_t i = 0; i < count; i++) { | 199 for (size_t i = 0; i < count; i++) { |
| 203 int64_t id = va_arg(args, int64_t); | 200 int64_t id = va_arg(args, int64_t); |
| 204 list.push_back(id); | 201 list.push_back(id); |
| 205 } | 202 } |
| 206 SortDisplayIdList(&list); | 203 SortDisplayIdList(&list); |
| 207 return list; | 204 return list; |
| 208 } | 205 } |
| 209 | 206 |
| 210 } // namespace test | 207 } // namespace test |
| 211 } // namespace ash | 208 } // namespace ash |
| OLD | NEW |