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/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 for (std::vector<std::string>::const_iterator iter = parts.begin(); | 37 for (std::vector<std::string>::const_iterator iter = parts.begin(); |
38 iter != parts.end(); ++iter, ++index) { | 38 iter != parts.end(); ++iter, ++index) { |
39 int64_t id = (index < list.size()) ? list[index].id() | 39 int64_t id = (index < list.size()) ? list[index].id() |
40 : display::Display::kInvalidDisplayID; | 40 : display::Display::kInvalidDisplayID; |
41 display_info_list.push_back( | 41 display_info_list.push_back( |
42 display::ManagedDisplayInfo::CreateFromSpecWithID(*iter, id)); | 42 display::ManagedDisplayInfo::CreateFromSpecWithID(*iter, id)); |
43 } | 43 } |
44 return display_info_list; | 44 return display_info_list; |
45 } | 45 } |
46 | 46 |
| 47 scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForUIScale( |
| 48 const display::ManagedDisplayInfo& info, |
| 49 float ui_scale) { |
| 50 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = |
| 51 info.display_modes(); |
| 52 auto iter = std::find_if( |
| 53 modes.begin(), modes.end(), |
| 54 [ui_scale](const scoped_refptr<display::ManagedDisplayMode>& mode) { |
| 55 return mode->ui_scale() == ui_scale; |
| 56 }); |
| 57 if (iter == modes.end()) |
| 58 return scoped_refptr<display::ManagedDisplayMode>(); |
| 59 return *iter; |
| 60 } |
| 61 |
47 } // namespace | 62 } // namespace |
48 | 63 |
49 DisplayManagerTestApi::DisplayManagerTestApi(DisplayManager* display_manager) | 64 DisplayManagerTestApi::DisplayManagerTestApi(DisplayManager* display_manager) |
50 : display_manager_(display_manager) {} | 65 : display_manager_(display_manager) {} |
51 | 66 |
52 DisplayManagerTestApi::~DisplayManagerTestApi() {} | 67 DisplayManagerTestApi::~DisplayManagerTestApi() {} |
53 | 68 |
54 void DisplayManagerTestApi::UpdateDisplay(const std::string& display_specs) { | 69 void DisplayManagerTestApi::UpdateDisplay(const std::string& display_specs) { |
55 DisplayInfoList display_info_list = | 70 DisplayInfoList display_info_list = |
56 CreateDisplayInfoListFromString(display_specs, display_manager_); | 71 CreateDisplayInfoListFromString(display_specs, display_manager_); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 const std::vector<ui::ColorCalibrationProfile>& profiles) { | 121 const std::vector<ui::ColorCalibrationProfile>& profiles) { |
107 display_manager_->display_info_[display_id].set_available_color_profiles( | 122 display_manager_->display_info_[display_id].set_available_color_profiles( |
108 profiles); | 123 profiles); |
109 } | 124 } |
110 | 125 |
111 const display::ManagedDisplayInfo& | 126 const display::ManagedDisplayInfo& |
112 DisplayManagerTestApi::GetInternalManagedDisplayInfo(int64_t display_id) { | 127 DisplayManagerTestApi::GetInternalManagedDisplayInfo(int64_t display_id) { |
113 return display_manager_->display_info_[display_id]; | 128 return display_manager_->display_info_[display_id]; |
114 } | 129 } |
115 | 130 |
| 131 bool DisplayManagerTestApi::SetDisplayUIScale(int64_t id, float ui_scale) { |
| 132 if (!display_manager_->IsActiveDisplayId(id) || |
| 133 !display::Display::IsInternalDisplayId(id)) { |
| 134 return false; |
| 135 } |
| 136 const display::ManagedDisplayInfo& info = |
| 137 display_manager_->GetDisplayInfo(id); |
| 138 |
| 139 scoped_refptr<display::ManagedDisplayMode> mode = |
| 140 GetDisplayModeForUIScale(info, ui_scale); |
| 141 if (!mode) |
| 142 return false; |
| 143 return display_manager_->SetDisplayMode(id, mode); |
| 144 } |
| 145 |
116 ScopedDisable125DSFForUIScaling::ScopedDisable125DSFForUIScaling() { | 146 ScopedDisable125DSFForUIScaling::ScopedDisable125DSFForUIScaling() { |
117 display::ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(false); | 147 display::ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(false); |
118 } | 148 } |
119 | 149 |
120 ScopedDisable125DSFForUIScaling::~ScopedDisable125DSFForUIScaling() { | 150 ScopedDisable125DSFForUIScaling::~ScopedDisable125DSFForUIScaling() { |
121 display::ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(true); | 151 display::ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(true); |
122 } | 152 } |
123 | 153 |
124 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId( | 154 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId( |
125 DisplayManager* display_manager, | 155 DisplayManager* display_manager, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 for (size_t i = 0; i < count; i++) { | 199 for (size_t i = 0; i < count; i++) { |
170 int64_t id = va_arg(args, int64_t); | 200 int64_t id = va_arg(args, int64_t); |
171 list.push_back(id); | 201 list.push_back(id); |
172 } | 202 } |
173 display::SortDisplayIdList(&list); | 203 display::SortDisplayIdList(&list); |
174 return list; | 204 return list; |
175 } | 205 } |
176 | 206 |
177 } // namespace test | 207 } // namespace test |
178 } // namespace ash | 208 } // namespace ash |
OLD | NEW |