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

Unified Diff: ash/display/display_change_observer_chromeos_unittest.cc

Issue 417113012: Introduce user customization of external HighDPI mode for 4K monitor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 5 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/display/display_change_observer_chromeos.cc ('k') | ash/display/display_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_change_observer_chromeos_unittest.cc
diff --git a/ash/display/display_change_observer_chromeos_unittest.cc b/ash/display/display_change_observer_chromeos_unittest.cc
index b0df4ae43eb31ca9dba9e192469166b3a983d154..d274764d765daf99a63e899ffc47f745f83baa19 100644
--- a/ash/display/display_change_observer_chromeos_unittest.cc
+++ b/ash/display/display_change_observer_chromeos_unittest.cc
@@ -17,7 +17,7 @@ typedef testing::Test DisplayChangeObserverTest;
namespace ash {
-TEST_F(DisplayChangeObserverTest, GetDisplayModeList) {
+TEST_F(DisplayChangeObserverTest, GetExternalDisplayModeList) {
ScopedVector<const ui::DisplayMode> modes;
modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1200), false, 60));
@@ -48,37 +48,168 @@ TEST_F(DisplayChangeObserverTest, GetDisplayModeList) {
output.display = &display_snapshot;
std::vector<DisplayMode> display_modes =
- DisplayChangeObserver::GetDisplayModeList(output);
+ DisplayChangeObserver::GetExternalDisplayModeList(output);
ASSERT_EQ(6u, display_modes.size());
- EXPECT_EQ("1920x1200", display_modes[0].size.ToString());
- EXPECT_FALSE(display_modes[0].interlaced);
+ EXPECT_EQ("640x480", display_modes[0].size.ToString());
+ EXPECT_TRUE(display_modes[0].interlaced);
EXPECT_EQ(display_modes[0].refresh_rate, 60);
- EXPECT_EQ("1920x1080", display_modes[1].size.ToString());
+ EXPECT_EQ("1024x600", display_modes[1].size.ToString());
EXPECT_FALSE(display_modes[1].interlaced);
- EXPECT_EQ(display_modes[1].refresh_rate, 80);
+ EXPECT_EQ(display_modes[1].refresh_rate, 70);
- EXPECT_EQ("1280x720", display_modes[2].size.ToString());
- EXPECT_FALSE(display_modes[2].interlaced);
- EXPECT_EQ(display_modes[2].refresh_rate, 60);
+ EXPECT_EQ("1024x768", display_modes[2].size.ToString());
+ EXPECT_TRUE(display_modes[2].interlaced);
+ EXPECT_EQ(display_modes[2].refresh_rate, 70);
- EXPECT_EQ("1024x768", display_modes[3].size.ToString());
- EXPECT_TRUE(display_modes[3].interlaced);
- EXPECT_EQ(display_modes[3].refresh_rate, 70);
+ EXPECT_EQ("1280x720", display_modes[3].size.ToString());
+ EXPECT_FALSE(display_modes[3].interlaced);
+ EXPECT_EQ(display_modes[3].refresh_rate, 60);
- EXPECT_EQ("1024x600", display_modes[4].size.ToString());
+ EXPECT_EQ("1920x1080", display_modes[4].size.ToString());
EXPECT_FALSE(display_modes[4].interlaced);
- EXPECT_EQ(display_modes[4].refresh_rate, 70);
+ EXPECT_EQ(display_modes[4].refresh_rate, 80);
- EXPECT_EQ("640x480", display_modes[5].size.ToString());
- EXPECT_TRUE(display_modes[5].interlaced);
+ EXPECT_EQ("1920x1200", display_modes[5].size.ToString());
+ EXPECT_FALSE(display_modes[5].interlaced);
EXPECT_EQ(display_modes[5].refresh_rate, 60);
// Outputs without any modes shouldn't cause a crash.
modes.clear();
display_snapshot.set_modes(modes.get());
- display_modes = DisplayChangeObserver::GetDisplayModeList(output);
+ display_modes = DisplayChangeObserver::GetExternalDisplayModeList(output);
+ EXPECT_EQ(0u, display_modes.size());
+}
+
+TEST_F(DisplayChangeObserverTest, GetInternalDisplayModeList) {
+ ScopedVector<const ui::DisplayMode> modes;
+ // Data picked from peppy.
+ modes.push_back(new ui::DisplayMode(gfx::Size(1366, 768), false, 60));
+ modes.push_back(new ui::DisplayMode(gfx::Size(1024, 768), false, 60));
+ modes.push_back(new ui::DisplayMode(gfx::Size(800, 600), false, 60));
+ modes.push_back(new ui::DisplayMode(gfx::Size(600, 600), false, 56.2));
+ modes.push_back(new ui::DisplayMode(gfx::Size(640, 480), false, 59.9));
+
+ 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, 1366, 768));
+
+ std::vector<DisplayMode> display_modes =
+ DisplayChangeObserver::GetInternalDisplayModeList(info, output);
+ ASSERT_EQ(5u, display_modes.size());
+ EXPECT_EQ("1366x768", 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("1366x768", display_modes[1].size.ToString());
+ EXPECT_FALSE(display_modes[1].native);
+ EXPECT_NEAR(display_modes[1].ui_scale, 0.6, 0.01);
+ EXPECT_EQ(display_modes[1].refresh_rate, 60);
+
+ EXPECT_EQ("1366x768", display_modes[2].size.ToString());
+ EXPECT_FALSE(display_modes[2].native);
+ EXPECT_NEAR(display_modes[2].ui_scale, 0.75, 0.01);
+ EXPECT_EQ(display_modes[2].refresh_rate, 60);
+
+ EXPECT_EQ("1366x768", display_modes[3].size.ToString());
+ EXPECT_TRUE(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("1366x768", 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);
+}
+
+TEST_F(DisplayChangeObserverTest, GetExternalDisplayModeList4K) {
+ 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(1920, 1200), false, 60));
+
+ // All non-interlaced (as would be seen with different refresh rates).
+ modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1080), false, 80));
+ modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1080), false, 70));
+ modes.push_back(new ui::DisplayMode(gfx::Size(1920, 1080), false, 60));
+
+ // Interlaced vs non-interlaced.
+ modes.push_back(new ui::DisplayMode(gfx::Size(1280, 720), true, 60));
+ modes.push_back(new ui::DisplayMode(gfx::Size(1280, 720), false, 60));
+
+ // Interlaced only.
+ modes.push_back(new ui::DisplayMode(gfx::Size(1024, 768), true, 70));
+ modes.push_back(new ui::DisplayMode(gfx::Size(1024, 768), true, 60));
+
+ // Mixed.
+ modes.push_back(new ui::DisplayMode(gfx::Size(1024, 600), true, 60));
+ modes.push_back(new ui::DisplayMode(gfx::Size(1024, 600), false, 70));
+ modes.push_back(new ui::DisplayMode(gfx::Size(1024, 600), false, 60));
+
+ // Just one interlaced mode.
+ modes.push_back(new ui::DisplayMode(gfx::Size(640, 480), true, 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;
+
+ std::vector<DisplayMode> display_modes =
+ DisplayChangeObserver::GetExternalDisplayModeList(output);
+ ASSERT_EQ(9u, display_modes.size());
+ EXPECT_EQ("640x480", display_modes[0].size.ToString());
+ EXPECT_TRUE(display_modes[0].interlaced);
+ EXPECT_EQ(display_modes[0].refresh_rate, 60);
+
+ EXPECT_EQ("1024x600", display_modes[1].size.ToString());
+ EXPECT_FALSE(display_modes[1].interlaced);
+ EXPECT_EQ(display_modes[1].refresh_rate, 70);
+
+ EXPECT_EQ("1024x768", display_modes[2].size.ToString());
+ EXPECT_TRUE(display_modes[2].interlaced);
+ EXPECT_EQ(display_modes[2].refresh_rate, 70);
+
+ EXPECT_EQ("1280x720", display_modes[3].size.ToString());
+ EXPECT_FALSE(display_modes[3].interlaced);
+ EXPECT_EQ(display_modes[3].refresh_rate, 60);
+
+ EXPECT_EQ("1920x1080", display_modes[4].size.ToString());
+ EXPECT_FALSE(display_modes[4].interlaced);
+ EXPECT_EQ(display_modes[4].refresh_rate, 80);
+
+ EXPECT_EQ("3840x2160", display_modes[5].size.ToString());
+ EXPECT_FALSE(display_modes[5].interlaced);
+ EXPECT_FALSE(display_modes[5].native);
+ EXPECT_EQ(display_modes[5].refresh_rate, 30);
+ EXPECT_EQ(display_modes[5].device_scale_factor, 2.0);
+
+ EXPECT_EQ("1920x1200", display_modes[6].size.ToString());
+ EXPECT_FALSE(display_modes[6].interlaced);
+ EXPECT_EQ(display_modes[6].refresh_rate, 60);
+
+ EXPECT_EQ("3840x2160", display_modes[7].size.ToString());
+ EXPECT_FALSE(display_modes[7].interlaced);
+ EXPECT_FALSE(display_modes[7].native);
+ EXPECT_EQ(display_modes[7].refresh_rate, 30);
+ EXPECT_EQ(display_modes[7].device_scale_factor, 1.25);
+
+ EXPECT_EQ("3840x2160", display_modes[8].size.ToString());
+ EXPECT_FALSE(display_modes[8].interlaced);
+ EXPECT_TRUE(display_modes[8].native);
+ EXPECT_EQ(display_modes[8].refresh_rate, 30);
+
+ // Outputs without any modes shouldn't cause a crash.
+ modes.clear();
+ display_snapshot.set_modes(modes.get());
+
+ display_modes = DisplayChangeObserver::GetExternalDisplayModeList(output);
EXPECT_EQ(0u, display_modes.size());
}
« no previous file with comments | « ash/display/display_change_observer_chromeos.cc ('k') | ash/display/display_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698