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

Unified Diff: ash/test/display_manager_test_api.cc

Issue 2426103004: Specify a default display UI scale to reset the zoom to (Closed)
Patch Set: Working test Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/test/display_manager_test_api.h ('k') | ash/wm/ash_native_cursor_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/test/display_manager_test_api.cc
diff --git a/ash/test/display_manager_test_api.cc b/ash/test/display_manager_test_api.cc
index 1c101b17c5a92ae8de467903d6c955a29d5a0cda..d9455bdb06d112fd9707664c17689906baa6c487 100644
--- a/ash/test/display_manager_test_api.cc
+++ b/ash/test/display_manager_test_api.cc
@@ -44,6 +44,21 @@ DisplayInfoList CreateDisplayInfoListFromString(
return display_info_list;
}
+scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForUIScale(
+ const display::ManagedDisplayInfo& info,
+ float ui_scale) {
+ const display::ManagedDisplayInfo::ManagedDisplayModeList& modes =
+ info.display_modes();
+ auto iter = std::find_if(
+ modes.begin(), modes.end(),
+ [ui_scale](const scoped_refptr<display::ManagedDisplayMode>& mode) {
+ return mode->ui_scale() == ui_scale;
+ });
+ if (iter == modes.end())
+ return scoped_refptr<display::ManagedDisplayMode>();
+ return *iter;
+}
+
} // namespace
DisplayManagerTestApi::DisplayManagerTestApi(DisplayManager* display_manager)
@@ -113,6 +128,21 @@ DisplayManagerTestApi::GetInternalManagedDisplayInfo(int64_t display_id) {
return display_manager_->display_info_[display_id];
}
+bool DisplayManagerTestApi::SetDisplayUIScale(int64_t id, float ui_scale) {
+ if (!display_manager_->IsActiveDisplayId(id) ||
+ !display::Display::IsInternalDisplayId(id)) {
+ return false;
+ }
+ const display::ManagedDisplayInfo& info =
+ display_manager_->GetDisplayInfo(id);
+
+ scoped_refptr<display::ManagedDisplayMode> mode =
+ GetDisplayModeForUIScale(info, ui_scale);
+ if (!mode)
+ return false;
+ return display_manager_->SetDisplayMode(id, mode);
+}
+
ScopedDisable125DSFForUIScaling::ScopedDisable125DSFForUIScaling() {
display::ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(false);
}
« no previous file with comments | « ash/test/display_manager_test_api.h ('k') | ash/wm/ash_native_cursor_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698