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

Unified Diff: chrome/browser/chromeos/display/display_preferences_unittest.cc

Issue 21297003: Add ability to set resolution on external display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adraddressed comment, adjusted test Created 7 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 | « chrome/browser/chromeos/display/display_preferences.cc ('k') | chromeos/display/output_configurator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/display/display_preferences_unittest.cc
diff --git a/chrome/browser/chromeos/display/display_preferences_unittest.cc b/chrome/browser/chromeos/display/display_preferences_unittest.cc
index 023cfdf34bb660c6fea8e27c5bee7391f06d8b5a..a319c5b307d5f3a378b2c985cb966837523c44a1 100644
--- a/chrome/browser/chromeos/display/display_preferences_unittest.cc
+++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc
@@ -183,7 +183,7 @@ TEST_F(DisplayPreferencesTest, BasicStores) {
ash::internal::DisplayManager* display_manager =
ash::Shell::GetInstance()->display_manager();
- UpdateDisplay("200x200*2,200x200");
+ UpdateDisplay("200x200*2,400x300");
int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id();
gfx::Display::SetInternalDisplayId(id1);
int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
@@ -231,6 +231,11 @@ TEST_F(DisplayPreferencesTest, BasicStores) {
EXPECT_EQ(1, rotation);
EXPECT_EQ(1250, ui_scale);
+ // Internal display never registere the resolution.
+ int width = 0, height = 0;
+ EXPECT_FALSE(property->GetInteger("width", &width));
+ EXPECT_FALSE(property->GetInteger("height", &height));
+
int top = 0, left = 0, bottom = 0, right = 0;
EXPECT_TRUE(property->GetInteger("insets_top", &top));
EXPECT_TRUE(property->GetInteger("insets_left", &left));
@@ -252,8 +257,31 @@ TEST_F(DisplayPreferencesTest, BasicStores) {
EXPECT_FALSE(property->GetInteger("insets_bottom", &bottom));
EXPECT_FALSE(property->GetInteger("insets_right", &right));
+ // Resolution is saved only when the resolution is set
+ // by DisplayManager::SetDisplayResolution
+ width = 0;
+ height = 0;
+ EXPECT_FALSE(property->GetInteger("width", &width));
+ EXPECT_FALSE(property->GetInteger("height", &height));
+
+ display_manager->SetDisplayResolution(id2, gfx::Size(400, 300));
+
display_controller->SetPrimaryDisplayId(id2);
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property));
+ width = 0;
+ height = 0;
+ // Internal dispaly shouldn't store its resolution.
+ EXPECT_FALSE(property->GetInteger("width", &width));
+ EXPECT_FALSE(property->GetInteger("height", &height));
+
+ // External dispaly's resolution must be stored this time.
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
+ EXPECT_TRUE(property->GetInteger("width", &width));
+ EXPECT_TRUE(property->GetInteger("height", &height));
+ EXPECT_EQ(400, width);
+ EXPECT_EQ(300, height);
+
// The layout remains the same.
EXPECT_TRUE(displays->GetDictionary(key, &layout_value));
EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*layout_value,
@@ -287,7 +315,21 @@ TEST_F(DisplayPreferencesTest, BasicStores) {
EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str));
EXPECT_EQ(base::Int64ToString(id2), primary_id_str);
- UpdateDisplay("200x200*2,200x200");
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property));
+ EXPECT_FALSE(property->GetInteger("width", &width));
+ EXPECT_FALSE(property->GetInteger("height", &height));
+
+ // External dispaly's selected resolution must not change
+ // by mirroring.
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
+ EXPECT_TRUE(property->GetInteger("width", &width));
+ EXPECT_TRUE(property->GetInteger("height", &height));
+ EXPECT_EQ(400, width);
+ EXPECT_EQ(300, height);
+
+ // Set new display's selected resolution.
+ display_manager->SetDisplayResolution(id2 + 1, gfx::Size(500, 400));
+ UpdateDisplay("200x200*2,500x400");
// Update key as the 2nd display gets new id.
id2 = ash::ScreenAsh::GetSecondaryDisplay().id();
key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
@@ -301,6 +343,13 @@ TEST_F(DisplayPreferencesTest, BasicStores) {
EXPECT_FALSE(mirrored);
EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str));
EXPECT_EQ(base::Int64ToString(id1), primary_id_str);
+
+ // External dispaly's selected resolution must be updated.
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
+ EXPECT_TRUE(property->GetInteger("width", &width));
+ EXPECT_TRUE(property->GetInteger("height", &height));
+ EXPECT_EQ(500, width);
+ EXPECT_EQ(400, height);
}
TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) {
« no previous file with comments | « chrome/browser/chromeos/display/display_preferences.cc ('k') | chromeos/display/output_configurator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698