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

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

Issue 2270553002: Move ash::DisplayInfo to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 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/ash_test_helper.cc ('k') | ash/touch/touch_observer_hud_unittest.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/common/ash_switches.h" 10 #include "ash/common/ash_switches.h"
11 #include "ash/common/display/display_info.h"
12 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
13 #include "ash/display/display_util.h" 12 #include "ash/display/display_util.h"
14 #include "ash/display/extended_mouse_warp_controller.h" 13 #include "ash/display/extended_mouse_warp_controller.h"
15 #include "ash/display/mouse_cursor_event_filter.h" 14 #include "ash/display/mouse_cursor_event_filter.h"
16 #include "ash/display/unified_mouse_warp_controller.h" 15 #include "ash/display/unified_mouse_warp_controller.h"
17 #include "ash/screen_util.h" 16 #include "ash/screen_util.h"
18 #include "ash/shell.h" 17 #include "ash/shell.h"
19 #include "base/command_line.h" 18 #include "base/command_line.h"
20 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
21 #include "ui/aura/env.h" 20 #include "ui/aura/env.h"
22 #include "ui/aura/window_event_dispatcher.h" 21 #include "ui/aura/window_event_dispatcher.h"
23 #include "ui/display/display.h" 22 #include "ui/display/display.h"
24 #include "ui/display/manager/display_layout_builder.h" 23 #include "ui/display/manager/display_layout_builder.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 std::vector<DisplayInfo> CreateDisplayInfoListFromString( 31 DisplayInfoList CreateDisplayInfoListFromString(
32 const std::string specs, 32 const std::string specs,
33 DisplayManager* display_manager) { 33 DisplayManager* display_manager) {
34 std::vector<DisplayInfo> display_info_list; 34 DisplayInfoList display_info_list;
35 std::vector<std::string> parts = base::SplitString( 35 std::vector<std::string> parts = base::SplitString(
36 specs, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 36 specs, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
37 size_t index = 0; 37 size_t index = 0;
38 38
39 display::DisplayList list = 39 display::DisplayList list =
40 display_manager->IsInUnifiedMode() 40 display_manager->IsInUnifiedMode()
41 ? display_manager->software_mirroring_display_list() 41 ? display_manager->software_mirroring_display_list()
42 : display_manager->active_display_list(); 42 : display_manager->active_display_list();
43 43
44 for (std::vector<std::string>::const_iterator iter = parts.begin(); 44 for (std::vector<std::string>::const_iterator iter = parts.begin();
45 iter != parts.end(); ++iter, ++index) { 45 iter != parts.end(); ++iter, ++index) {
46 int64_t id = (index < list.size()) ? list[index].id() 46 int64_t id = (index < list.size()) ? list[index].id()
47 : display::Display::kInvalidDisplayID; 47 : display::Display::kInvalidDisplayID;
48 display_info_list.push_back(DisplayInfo::CreateFromSpecWithID(*iter, id)); 48 display_info_list.push_back(
49 display::ManagedDisplayInfo::CreateFromSpecWithID(*iter, id));
49 } 50 }
50 return display_info_list; 51 return display_info_list;
51 } 52 }
52 53
53 } // namespace 54 } // namespace
54 55
55 // static 56 // static
56 bool DisplayManagerTestApi::TestIfMouseWarpsAt( 57 bool DisplayManagerTestApi::TestIfMouseWarpsAt(
57 ui::test::EventGenerator& event_generator, 58 ui::test::EventGenerator& event_generator,
58 const gfx::Point& point_in_screen) { 59 const gfx::Point& point_in_screen) {
(...skipping 13 matching lines...) Expand all
72 aura::Env::GetInstance()->last_mouse_location()) 73 aura::Env::GetInstance()->last_mouse_location())
73 .id(); 74 .id();
74 } 75 }
75 76
76 DisplayManagerTestApi::DisplayManagerTestApi() 77 DisplayManagerTestApi::DisplayManagerTestApi()
77 : display_manager_(Shell::GetInstance()->display_manager()) {} 78 : display_manager_(Shell::GetInstance()->display_manager()) {}
78 79
79 DisplayManagerTestApi::~DisplayManagerTestApi() {} 80 DisplayManagerTestApi::~DisplayManagerTestApi() {}
80 81
81 void DisplayManagerTestApi::UpdateDisplay(const std::string& display_specs) { 82 void DisplayManagerTestApi::UpdateDisplay(const std::string& display_specs) {
82 std::vector<DisplayInfo> display_info_list = 83 DisplayInfoList display_info_list =
83 CreateDisplayInfoListFromString(display_specs, display_manager_); 84 CreateDisplayInfoListFromString(display_specs, display_manager_);
84 bool is_host_origin_set = false; 85 bool is_host_origin_set = false;
85 for (size_t i = 0; i < display_info_list.size(); ++i) { 86 for (size_t i = 0; i < display_info_list.size(); ++i) {
86 const DisplayInfo& display_info = display_info_list[i]; 87 const display::ManagedDisplayInfo& display_info = display_info_list[i];
87 if (display_info.bounds_in_native().origin() != gfx::Point(0, 0)) { 88 if (display_info.bounds_in_native().origin() != gfx::Point(0, 0)) {
88 is_host_origin_set = true; 89 is_host_origin_set = true;
89 break; 90 break;
90 } 91 }
91 } 92 }
92 93
93 // On non-testing environment, when a secondary display is connected, a new 94 // On non-testing environment, when a secondary display is connected, a new
94 // native (i.e. X) window for the display is always created below the 95 // native (i.e. X) window for the display is always created below the
95 // previous one for GPU performance reasons. Try to emulate the behavior 96 // previous one for GPU performance reasons. Try to emulate the behavior
96 // unless host origins are explicitly set. 97 // unless host origins are explicitly set.
97 if (!is_host_origin_set) { 98 if (!is_host_origin_set) {
98 // Sart from (1,1) so that windows won't overlap with native mouse cursor. 99 // Sart from (1,1) so that windows won't overlap with native mouse cursor.
99 // See |AshTestBase::SetUp()|. 100 // See |AshTestBase::SetUp()|.
100 int next_y = 1; 101 int next_y = 1;
101 for (std::vector<DisplayInfo>::iterator iter = display_info_list.begin(); 102 for (DisplayInfoList::iterator iter = display_info_list.begin();
102 iter != display_info_list.end(); ++iter) { 103 iter != display_info_list.end(); ++iter) {
103 gfx::Rect bounds(iter->bounds_in_native().size()); 104 gfx::Rect bounds(iter->bounds_in_native().size());
104 bounds.set_x(1); 105 bounds.set_x(1);
105 bounds.set_y(next_y); 106 bounds.set_y(next_y);
106 next_y += bounds.height(); 107 next_y += bounds.height();
107 iter->SetBounds(bounds); 108 iter->SetBounds(bounds);
108 } 109 }
109 } 110 }
110 111
111 display_manager_->OnNativeDisplaysChanged(display_info_list); 112 display_manager_->OnNativeDisplaysChanged(display_info_list);
(...skipping 17 matching lines...) Expand all
129 } 130 }
130 131
131 void DisplayManagerTestApi::SetAvailableColorProfiles( 132 void DisplayManagerTestApi::SetAvailableColorProfiles(
132 int64_t display_id, 133 int64_t display_id,
133 const std::vector<ui::ColorCalibrationProfile>& profiles) { 134 const std::vector<ui::ColorCalibrationProfile>& profiles) {
134 display_manager_->display_info_[display_id].set_available_color_profiles( 135 display_manager_->display_info_[display_id].set_available_color_profiles(
135 profiles); 136 profiles);
136 } 137 }
137 138
138 ScopedDisable125DSFForUIScaling::ScopedDisable125DSFForUIScaling() { 139 ScopedDisable125DSFForUIScaling::ScopedDisable125DSFForUIScaling() {
139 DisplayInfo::SetUse125DSFForUIScalingForTest(false); 140 display::ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(false);
140 } 141 }
141 142
142 ScopedDisable125DSFForUIScaling::~ScopedDisable125DSFForUIScaling() { 143 ScopedDisable125DSFForUIScaling::~ScopedDisable125DSFForUIScaling() {
143 DisplayInfo::SetUse125DSFForUIScalingForTest(true); 144 display::ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(true);
144 } 145 }
145 146
146 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(int64_t id) { 147 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(int64_t id) {
147 DisplayManagerTestApi().SetInternalDisplayId(id); 148 DisplayManagerTestApi().SetInternalDisplayId(id);
148 } 149 }
149 150
150 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() { 151 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() {
151 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); 152 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID);
152 } 153 }
153 154
154 bool SetDisplayResolution(int64_t display_id, const gfx::Size& resolution) { 155 bool SetDisplayResolution(int64_t display_id, const gfx::Size& resolution) {
155 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 156 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
156 const DisplayInfo& info = display_manager->GetDisplayInfo(display_id); 157 const display::ManagedDisplayInfo& info =
157 scoped_refptr<ManagedDisplayMode> mode = 158 display_manager->GetDisplayInfo(display_id);
159 scoped_refptr<display::ManagedDisplayMode> mode =
158 GetDisplayModeForResolution(info, resolution); 160 GetDisplayModeForResolution(info, resolution);
159 if (!mode) 161 if (!mode)
160 return false; 162 return false;
161 return display_manager->SetDisplayMode(display_id, mode); 163 return display_manager->SetDisplayMode(display_id, mode);
162 } 164 }
163 165
164 void SwapPrimaryDisplay() { 166 void SwapPrimaryDisplay() {
165 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) 167 if (display::Screen::GetScreen()->GetNumDisplays() <= 1)
166 return; 168 return;
167 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( 169 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId(
(...skipping 28 matching lines...) Expand all
196 for (size_t i = 0; i < count; i++) { 198 for (size_t i = 0; i < count; i++) {
197 int64_t id = va_arg(args, int64_t); 199 int64_t id = va_arg(args, int64_t);
198 list.push_back(id); 200 list.push_back(id);
199 } 201 }
200 SortDisplayIdList(&list); 202 SortDisplayIdList(&list);
201 return list; 203 return list;
202 } 204 }
203 205
204 } // namespace test 206 } // namespace test
205 } // namespace ash 207 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/ash_test_helper.cc ('k') | ash/touch/touch_observer_hud_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698