Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: ash/test/display_manager_test_api.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/test/cursor_manager_test_api.cc ('k') | ash/test/ui_controls_factory_ash.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_store.h" 12 #include "ash/display/display_layout_store.h"
13 #include "ash/display/display_manager.h" 13 #include "ash/display/display_manager.h"
14 #include "ash/display/display_util.h" 14 #include "ash/display/display_util.h"
15 #include "ash/display/extended_mouse_warp_controller.h" 15 #include "ash/display/extended_mouse_warp_controller.h"
16 #include "ash/display/mouse_cursor_event_filter.h" 16 #include "ash/display/mouse_cursor_event_filter.h"
17 #include "ash/display/unified_mouse_warp_controller.h" 17 #include "ash/display/unified_mouse_warp_controller.h"
18 #include "ash/screen_util.h" 18 #include "ash/screen_util.h"
19 #include "ash/shell.h" 19 #include "ash/shell.h"
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "base/strings/string_split.h" 21 #include "base/strings/string_split.h"
22 #include "ui/aura/env.h" 22 #include "ui/aura/env.h"
23 #include "ui/aura/window_event_dispatcher.h" 23 #include "ui/aura/window_event_dispatcher.h"
24 #include "ui/display/display.h"
24 #include "ui/display/manager/display_layout_builder.h" 25 #include "ui/display/manager/display_layout_builder.h"
25 #include "ui/events/test/event_generator.h" 26 #include "ui/events/test/event_generator.h"
26 #include "ui/gfx/display.h"
27 27
28 namespace ash { 28 namespace ash {
29 namespace test { 29 namespace test {
30 namespace { 30 namespace {
31 31
32 std::vector<DisplayInfo> CreateDisplayInfoListFromString( 32 std::vector<DisplayInfo> CreateDisplayInfoListFromString(
33 const std::string specs, 33 const std::string specs,
34 DisplayManager* display_manager) { 34 DisplayManager* display_manager) {
35 std::vector<DisplayInfo> display_info_list; 35 std::vector<DisplayInfo> display_info_list;
36 std::vector<std::string> parts = base::SplitString( 36 std::vector<std::string> parts = base::SplitString(
37 specs, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 37 specs, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
38 size_t index = 0; 38 size_t index = 0;
39 39
40 display::DisplayList list = 40 display::DisplayList list =
41 display_manager->IsInUnifiedMode() 41 display_manager->IsInUnifiedMode()
42 ? display_manager->software_mirroring_display_list() 42 ? display_manager->software_mirroring_display_list()
43 : display_manager->active_display_list(); 43 : display_manager->active_display_list();
44 44
45 for (std::vector<std::string>::const_iterator iter = parts.begin(); 45 for (std::vector<std::string>::const_iterator iter = parts.begin();
46 iter != parts.end(); ++iter, ++index) { 46 iter != parts.end(); ++iter, ++index) {
47 int64_t id = (index < list.size()) ? list[index].id() 47 int64_t id = (index < list.size()) ? list[index].id()
48 : gfx::Display::kInvalidDisplayID; 48 : display::Display::kInvalidDisplayID;
49 display_info_list.push_back( 49 display_info_list.push_back(
50 DisplayInfo::CreateFromSpecWithID(*iter, id)); 50 DisplayInfo::CreateFromSpecWithID(*iter, id));
51 } 51 }
52 return display_info_list; 52 return display_info_list;
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 // static 57 // static
58 bool DisplayManagerTestApi::TestIfMouseWarpsAt( 58 bool DisplayManagerTestApi::TestIfMouseWarpsAt(
59 ui::test::EventGenerator& event_generator, 59 ui::test::EventGenerator& event_generator,
60 const gfx::Point& point_in_screen) { 60 const gfx::Point& point_in_screen) {
61 DCHECK(!Shell::GetInstance()->display_manager()->IsInUnifiedMode()); 61 DCHECK(!Shell::GetInstance()->display_manager()->IsInUnifiedMode());
62 static_cast<ExtendedMouseWarpController*>( 62 static_cast<ExtendedMouseWarpController*>(
63 Shell::GetInstance() 63 Shell::GetInstance()
64 ->mouse_cursor_filter() 64 ->mouse_cursor_filter()
65 ->mouse_warp_controller_for_test()) 65 ->mouse_warp_controller_for_test())
66 ->allow_non_native_event_for_test(); 66 ->allow_non_native_event_for_test();
67 gfx::Screen* screen = gfx::Screen::GetScreen(); 67 display::Screen* screen = display::Screen::GetScreen();
68 gfx::Display original_display = 68 display::Display original_display =
69 screen->GetDisplayNearestPoint(point_in_screen); 69 screen->GetDisplayNearestPoint(point_in_screen);
70 event_generator.MoveMouseTo(point_in_screen); 70 event_generator.MoveMouseTo(point_in_screen);
71 return original_display.id() != 71 return original_display.id() !=
72 screen->GetDisplayNearestPoint( 72 screen->GetDisplayNearestPoint(
73 aura::Env::GetInstance()->last_mouse_location()) 73 aura::Env::GetInstance()->last_mouse_location())
74 .id(); 74 .id();
75 } 75 }
76 76
77 DisplayManagerTestApi::DisplayManagerTestApi() 77 DisplayManagerTestApi::DisplayManagerTestApi()
78 : display_manager_(Shell::GetInstance()->display_manager()) {} 78 : display_manager_(Shell::GetInstance()->display_manager()) {}
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 // TODO(msw): This seems to cause test hangs on Windows. http://crbug.com/584038 112 // TODO(msw): This seems to cause test hangs on Windows. http://crbug.com/584038
113 #if !defined(OS_WIN) 113 #if !defined(OS_WIN)
114 display_manager_->OnNativeDisplaysChanged(display_info_list); 114 display_manager_->OnNativeDisplaysChanged(display_info_list);
115 display_manager_->UpdateInternalDisplayModeListForTest(); 115 display_manager_->UpdateInternalDisplayModeListForTest();
116 display_manager_->RunPendingTasksForTest(); 116 display_manager_->RunPendingTasksForTest();
117 #endif 117 #endif
118 } 118 }
119 119
120 int64_t DisplayManagerTestApi::SetFirstDisplayAsInternalDisplay() { 120 int64_t DisplayManagerTestApi::SetFirstDisplayAsInternalDisplay() {
121 const gfx::Display& internal = display_manager_->active_display_list_[0]; 121 const display::Display& internal = display_manager_->active_display_list_[0];
122 SetInternalDisplayId(internal.id()); 122 SetInternalDisplayId(internal.id());
123 return gfx::Display::InternalDisplayId(); 123 return display::Display::InternalDisplayId();
124 } 124 }
125 125
126 void DisplayManagerTestApi::SetInternalDisplayId(int64_t id) { 126 void DisplayManagerTestApi::SetInternalDisplayId(int64_t id) {
127 gfx::Display::SetInternalDisplayId(id); 127 display::Display::SetInternalDisplayId(id);
128 display_manager_->UpdateInternalDisplayModeListForTest(); 128 display_manager_->UpdateInternalDisplayModeListForTest();
129 } 129 }
130 130
131 void DisplayManagerTestApi::DisableChangeDisplayUponHostResize() { 131 void DisplayManagerTestApi::DisableChangeDisplayUponHostResize() {
132 display_manager_->set_change_display_upon_host_resize(false); 132 display_manager_->set_change_display_upon_host_resize(false);
133 } 133 }
134 134
135 void DisplayManagerTestApi::SetAvailableColorProfiles( 135 void DisplayManagerTestApi::SetAvailableColorProfiles(
136 int64_t display_id, 136 int64_t display_id,
137 const std::vector<ui::ColorCalibrationProfile>& profiles) { 137 const std::vector<ui::ColorCalibrationProfile>& profiles) {
138 display_manager_->display_info_[display_id].set_available_color_profiles( 138 display_manager_->display_info_[display_id].set_available_color_profiles(
139 profiles); 139 profiles);
140 } 140 }
141 141
142 ScopedDisable125DSFForUIScaling::ScopedDisable125DSFForUIScaling() { 142 ScopedDisable125DSFForUIScaling::ScopedDisable125DSFForUIScaling() {
143 DisplayInfo::SetUse125DSFForUIScalingForTest(false); 143 DisplayInfo::SetUse125DSFForUIScalingForTest(false);
144 } 144 }
145 145
146 ScopedDisable125DSFForUIScaling::~ScopedDisable125DSFForUIScaling() { 146 ScopedDisable125DSFForUIScaling::~ScopedDisable125DSFForUIScaling() {
147 DisplayInfo::SetUse125DSFForUIScalingForTest(true); 147 DisplayInfo::SetUse125DSFForUIScalingForTest(true);
148 } 148 }
149 149
150 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(int64_t id) { 150 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(int64_t id) {
151 DisplayManagerTestApi().SetInternalDisplayId(id); 151 DisplayManagerTestApi().SetInternalDisplayId(id);
152 } 152 }
153 153
154 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() { 154 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() {
155 gfx::Display::SetInternalDisplayId(gfx::Display::kInvalidDisplayID); 155 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID);
156 } 156 }
157 157
158 bool SetDisplayResolution(int64_t display_id, const gfx::Size& resolution) { 158 bool SetDisplayResolution(int64_t display_id, const gfx::Size& resolution) {
159 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 159 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
160 const DisplayInfo& info = display_manager->GetDisplayInfo(display_id); 160 const DisplayInfo& info = display_manager->GetDisplayInfo(display_id);
161 DisplayMode mode; 161 DisplayMode mode;
162 if (!GetDisplayModeForResolution(info, resolution, &mode)) 162 if (!GetDisplayModeForResolution(info, resolution, &mode))
163 return false; 163 return false;
164 return display_manager->SetDisplayMode(display_id, mode); 164 return display_manager->SetDisplayMode(display_id, mode);
165 } 165 }
166 166
167 void SwapPrimaryDisplay() { 167 void SwapPrimaryDisplay() {
168 if (gfx::Screen::GetScreen()->GetNumDisplays() <= 1) 168 if (display::Screen::GetScreen()->GetNumDisplays() <= 1)
169 return; 169 return;
170 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( 170 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId(
171 ScreenUtil::GetSecondaryDisplay().id()); 171 ScreenUtil::GetSecondaryDisplay().id());
172 } 172 }
173 173
174 std::unique_ptr<display::DisplayLayout> CreateDisplayLayout( 174 std::unique_ptr<display::DisplayLayout> CreateDisplayLayout(
175 display::DisplayPlacement::Position position, 175 display::DisplayPlacement::Position position,
176 int offset) { 176 int offset) {
177 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 177 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
178 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); 178 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList();
179 179
180 display::DisplayLayoutBuilder builder( 180 display::DisplayLayoutBuilder builder(
181 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 181 display::Screen::GetScreen()->GetPrimaryDisplay().id());
182 builder.SetSecondaryPlacement(ScreenUtil::GetSecondaryDisplay().id(), 182 builder.SetSecondaryPlacement(ScreenUtil::GetSecondaryDisplay().id(),
183 position, offset); 183 position, offset);
184 return builder.Build(); 184 return builder.Build();
185 } 185 }
186 186
187 display::DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2) { 187 display::DisplayIdList CreateDisplayIdList2(int64_t id1, int64_t id2) {
188 display::DisplayIdList list; 188 display::DisplayIdList list;
189 list.push_back(id1); 189 list.push_back(id1);
190 list.push_back(id2); 190 list.push_back(id2);
191 SortDisplayIdList(&list); 191 SortDisplayIdList(&list);
192 return list; 192 return list;
193 } 193 }
194 194
195 display::DisplayIdList CreateDisplayIdListN(size_t count, ...) { 195 display::DisplayIdList CreateDisplayIdListN(size_t count, ...) {
196 display::DisplayIdList list; 196 display::DisplayIdList list;
197 va_list args; 197 va_list args;
198 va_start(args, count); 198 va_start(args, count);
199 for (size_t i = 0; i < count; i++) { 199 for (size_t i = 0; i < count; i++) {
200 int64_t id = va_arg(args, int64_t); 200 int64_t id = va_arg(args, int64_t);
201 list.push_back(id); 201 list.push_back(id);
202 } 202 }
203 SortDisplayIdList(&list); 203 SortDisplayIdList(&list);
204 return list; 204 return list;
205 } 205 }
206 206
207 } // namespace test 207 } // namespace test
208 } // namespace ash 208 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/cursor_manager_test_api.cc ('k') | ash/test/ui_controls_factory_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698