Commit 780827b6 authored by mukai's avatar mukai Committed by Commit bot

Adds (native) annotation to the display settings.

BUG=409492
R=oshima@chromium.org
TEST=ash_unittests, manually

Review URL: https://codereview.chromium.org/562413002

Cr-Commit-Position: refs/heads/master@{#294662}
parent 30ddbd00
...@@ -87,7 +87,7 @@ std::vector<DisplayMode> DisplayChangeObserver::GetInternalDisplayModeList( ...@@ -87,7 +87,7 @@ std::vector<DisplayMode> DisplayChangeObserver::GetInternalDisplayModeList(
for (size_t i = 0; i < ui_scales.size(); ++i) { for (size_t i = 0; i < ui_scales.size(); ++i) {
DisplayMode mode = native_mode; DisplayMode mode = native_mode;
mode.ui_scale = ui_scales[i]; mode.ui_scale = ui_scales[i];
mode.native = (ui_scales[i] == 1.0f); mode.native = (ui_scales[i] == display_info.device_scale_factor());
display_mode_list.push_back(mode); display_mode_list.push_back(mode);
} }
......
...@@ -129,6 +129,111 @@ TEST_F(DisplayChangeObserverTest, GetInternalDisplayModeList) { ...@@ -129,6 +129,111 @@ TEST_F(DisplayChangeObserverTest, GetInternalDisplayModeList) {
EXPECT_EQ(display_modes[4].refresh_rate, 60); EXPECT_EQ(display_modes[4].refresh_rate, 60);
} }
TEST_F(DisplayChangeObserverTest, GetInternalHiDPIDisplayModeList) {
ScopedVector<const ui::DisplayMode> modes;
// Data picked from peppy.
modes.push_back(new ui::DisplayMode(gfx::Size(2560, 1700), false, 60));
modes.push_back(new ui::DisplayMode(gfx::Size(2048, 1536), false, 60));
modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1440), false, 60));
ui::TestDisplaySnapshot display_snapshot;
display_snapshot.set_modes(modes.get());
display_snapshot.set_native_mode(modes[0]);
DisplayConfigurator::DisplayState output;
output.display = &display_snapshot;
DisplayInfo info;
info.SetBounds(gfx::Rect(0, 0, 2560, 1700));
info.set_device_scale_factor(2.0f);
std::vector<DisplayMode> display_modes =
DisplayChangeObserver::GetInternalDisplayModeList(info, output);
ASSERT_EQ(8u, display_modes.size());
EXPECT_EQ("2560x1700", display_modes[0].size.ToString());
EXPECT_FALSE(display_modes[0].native);
EXPECT_NEAR(display_modes[0].ui_scale, 0.5, 0.01);
EXPECT_EQ(display_modes[0].refresh_rate, 60);
EXPECT_EQ("2560x1700", display_modes[1].size.ToString());
EXPECT_FALSE(display_modes[1].native);
EXPECT_NEAR(display_modes[1].ui_scale, 0.625, 0.01);
EXPECT_EQ(display_modes[1].refresh_rate, 60);
EXPECT_EQ("2560x1700", display_modes[2].size.ToString());
EXPECT_FALSE(display_modes[2].native);
EXPECT_NEAR(display_modes[2].ui_scale, 0.8, 0.01);
EXPECT_EQ(display_modes[2].refresh_rate, 60);
EXPECT_EQ("2560x1700", display_modes[3].size.ToString());
EXPECT_FALSE(display_modes[3].native);
EXPECT_NEAR(display_modes[3].ui_scale, 1.0, 0.01);
EXPECT_EQ(display_modes[3].refresh_rate, 60);
EXPECT_EQ("2560x1700", display_modes[4].size.ToString());
EXPECT_FALSE(display_modes[4].native);
EXPECT_NEAR(display_modes[4].ui_scale, 1.125, 0.01);
EXPECT_EQ(display_modes[4].refresh_rate, 60);
EXPECT_EQ("2560x1700", display_modes[5].size.ToString());
EXPECT_FALSE(display_modes[5].native);
EXPECT_NEAR(display_modes[5].ui_scale, 1.25, 0.01);
EXPECT_EQ(display_modes[5].refresh_rate, 60);
EXPECT_EQ("2560x1700", display_modes[6].size.ToString());
EXPECT_FALSE(display_modes[6].native);
EXPECT_NEAR(display_modes[6].ui_scale, 1.5, 0.01);
EXPECT_EQ(display_modes[6].refresh_rate, 60);
EXPECT_EQ("2560x1700", display_modes[7].size.ToString());
EXPECT_TRUE(display_modes[7].native);
EXPECT_NEAR(display_modes[7].ui_scale, 2.0, 0.01);
EXPECT_EQ(display_modes[7].refresh_rate, 60);
}
TEST_F(DisplayChangeObserverTest, GetInternalDisplayModeList1_25) {
ScopedVector<const ui::DisplayMode> modes;
// Data picked from peppy.
modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1080), false, 60));
ui::TestDisplaySnapshot display_snapshot;
display_snapshot.set_modes(modes.get());
display_snapshot.set_native_mode(modes[0]);
DisplayConfigurator::DisplayState output;
output.display = &display_snapshot;
DisplayInfo info;
info.SetBounds(gfx::Rect(0, 0, 1920, 1080));
info.set_device_scale_factor(1.25);
std::vector<DisplayMode> display_modes =
DisplayChangeObserver::GetInternalDisplayModeList(info, output);
ASSERT_EQ(5u, display_modes.size());
EXPECT_EQ("1920x1080", display_modes[0].size.ToString());
EXPECT_FALSE(display_modes[0].native);
EXPECT_NEAR(display_modes[0].ui_scale, 0.5, 0.01);
EXPECT_EQ(display_modes[0].refresh_rate, 60);
EXPECT_EQ("1920x1080", display_modes[1].size.ToString());
EXPECT_FALSE(display_modes[1].native);
EXPECT_NEAR(display_modes[1].ui_scale, 0.625, 0.01);
EXPECT_EQ(display_modes[1].refresh_rate, 60);
EXPECT_EQ("1920x1080", display_modes[2].size.ToString());
EXPECT_FALSE(display_modes[2].native);
EXPECT_NEAR(display_modes[2].ui_scale, 0.8, 0.01);
EXPECT_EQ(display_modes[2].refresh_rate, 60);
EXPECT_EQ("1920x1080", display_modes[3].size.ToString());
EXPECT_FALSE(display_modes[3].native);
EXPECT_NEAR(display_modes[3].ui_scale, 1.0, 0.01);
EXPECT_EQ(display_modes[3].refresh_rate, 60);
EXPECT_EQ("1920x1080", display_modes[4].size.ToString());
EXPECT_TRUE(display_modes[4].native);
EXPECT_NEAR(display_modes[4].ui_scale, 1.25, 0.01);
EXPECT_EQ(display_modes[4].refresh_rate, 60);
}
TEST_F(DisplayChangeObserverTest, GetExternalDisplayModeList4K) { TEST_F(DisplayChangeObserverTest, GetExternalDisplayModeList4K) {
ScopedVector<const ui::DisplayMode> modes; ScopedVector<const ui::DisplayMode> modes;
modes.push_back(new ui::DisplayMode(gfx::Size(3840, 2160), false, 30)); modes.push_back(new ui::DisplayMode(gfx::Size(3840, 2160), false, 30));
......
...@@ -2075,6 +2075,9 @@ Press any key to continue exploring. ...@@ -2075,6 +2075,9 @@ Press any key to continue exploring.
<message name="IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION_ANNOTATION_BEST" desc="The text shown for resolution options to annotate this is the best resolution."> <message name="IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION_ANNOTATION_BEST" desc="The text shown for resolution options to annotate this is the best resolution.">
(Best) (Best)
</message> </message>
<message name="IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION_ANNOTATION_NATIVE" desc="The text shown for resolution options to annotate this is the native resolution.">
(Native)
</message>
<message name="IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_STANDARD_ORIENTATION" desc="The default value of display orientation option item."> <message name="IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_STANDARD_ORIENTATION" desc="The default value of display orientation option item.">
Standard Standard
</message> </message>
......
...@@ -617,6 +617,9 @@ cr.define('options', function() { ...@@ -617,6 +617,9 @@ cr.define('options', function() {
if (display.resolutions[i].isBest) { if (display.resolutions[i].isBest) {
option.textContent += ' ' + option.textContent += ' ' +
loadTimeData.getString('annotateBest'); loadTimeData.getString('annotateBest');
} else if (display.resolutions[i].isNative) {
option.textContent += ' ' +
loadTimeData.getString('annotateNative');
} }
if (display.resolutions[i].deviceScaleFactor && previousOption && if (display.resolutions[i].deviceScaleFactor && previousOption &&
previousOption.textContent == option.textContent) { previousOption.textContent == option.textContent) {
......
...@@ -123,6 +123,7 @@ bool ConvertValueToDisplayMode(const base::DictionaryValue* dict, ...@@ -123,6 +123,7 @@ bool ConvertValueToDisplayMode(const base::DictionaryValue* dict,
base::DictionaryValue* ConvertDisplayModeToValue(int64 display_id, base::DictionaryValue* ConvertDisplayModeToValue(int64 display_id,
const ash::DisplayMode& mode) { const ash::DisplayMode& mode) {
bool is_internal = GetDisplayManager()->IsInternalDisplayId(display_id);
base::DictionaryValue* result = new base::DictionaryValue(); base::DictionaryValue* result = new base::DictionaryValue();
gfx::Size size_dip = mode.GetSizeInDIP(); gfx::Size size_dip = mode.GetSizeInDIP();
result->SetInteger("width", size_dip.width()); result->SetInteger("width", size_dip.width());
...@@ -132,7 +133,9 @@ base::DictionaryValue* ConvertDisplayModeToValue(int64 display_id, ...@@ -132,7 +133,9 @@ base::DictionaryValue* ConvertDisplayModeToValue(int64 display_id,
result->SetDouble("deviceScaleFactor", mode.device_scale_factor); result->SetDouble("deviceScaleFactor", mode.device_scale_factor);
result->SetDouble("scale", mode.ui_scale); result->SetDouble("scale", mode.ui_scale);
result->SetDouble("refreshRate", mode.refresh_rate); result->SetDouble("refreshRate", mode.refresh_rate);
result->SetBoolean("isBest", mode.native); result->SetBoolean(
"isBest", is_internal ? (mode.ui_scale == 1.0f) : mode.native);
result->SetBoolean("isNative", mode.native);
result->SetBoolean( result->SetBoolean(
"selected", mode.IsEquivalent( "selected", mode.IsEquivalent(
GetDisplayManager()->GetActiveModeForDisplayId(display_id))); GetDisplayManager()->GetActiveModeForDisplayId(display_id)));
...@@ -178,6 +181,8 @@ void DisplayOptionsHandler::GetLocalizedValues( ...@@ -178,6 +181,8 @@ void DisplayOptionsHandler::GetLocalizedValues(
IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_SET_PRIMARY)); IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_SET_PRIMARY));
localized_strings->SetString("annotateBest", l10n_util::GetStringUTF16( localized_strings->SetString("annotateBest", l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION_ANNOTATION_BEST)); IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION_ANNOTATION_BEST));
localized_strings->SetString("annotateNative", l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_RESOLUTION_ANNOTATION_NATIVE));
localized_strings->SetString("orientation0", l10n_util::GetStringUTF16( localized_strings->SetString("orientation0", l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_STANDARD_ORIENTATION)); IDS_OPTIONS_SETTINGS_DISPLAY_OPTIONS_STANDARD_ORIENTATION));
localized_strings->SetString("orientation90", l10n_util::GetStringUTF16( localized_strings->SetString("orientation90", l10n_util::GetStringUTF16(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment