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 43c0b8be7735a33504da09b39df0b92d3b472d31..03f0959d1893555707fa8d694970363ef1958230 100644 |
--- a/chrome/browser/chromeos/display/display_preferences_unittest.cc |
+++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc |
@@ -5,6 +5,7 @@ |
#include "chrome/browser/chromeos/display/display_preferences.h" |
#include "ash/display/display_controller.h" |
+#include "ash/display/display_manager.h" |
#include "ash/screen_ash.h" |
#include "ash/shell.h" |
#include "ash/test/ash_test_base.h" |
@@ -21,10 +22,6 @@ |
namespace chromeos { |
namespace { |
-ash::DisplayController* GetDisplayController() { |
- return ash::Shell::GetInstance()->display_controller(); |
-} |
- |
class DisplayPreferencesTest : public ash::test::AshTestBase { |
protected: |
DisplayPreferencesTest() : ash::test::AshTestBase() {} |
@@ -113,15 +110,15 @@ class DisplayPreferencesTest : public ash::test::AshTestBase { |
} |
void StoreDisplayOverscan(int64 id, const gfx::Insets& insets) { |
- DictionaryPrefUpdate update(&local_state_, prefs::kDisplayOverscans); |
+ DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); |
const std::string name = base::Int64ToString(id); |
base::DictionaryValue* pref_data = update.Get(); |
base::DictionaryValue* insets_value = new base::DictionaryValue(); |
- insets_value->SetInteger("top", insets.top()); |
- insets_value->SetInteger("left", insets.left()); |
- insets_value->SetInteger("bottom", insets.bottom()); |
- insets_value->SetInteger("right", insets.right()); |
+ insets_value->SetInteger("insets_top", insets.top()); |
+ insets_value->SetInteger("insets_left", insets.left()); |
+ insets_value->SetInteger("insets_bottom", insets.bottom()); |
+ insets_value->SetInteger("insets_right", insets.right()); |
pref_data->Set(name, insets_value); |
} |
@@ -157,7 +154,7 @@ TEST_F(DisplayPreferencesTest, OldInitialization) { |
StoreDisplayOverscan(id1, gfx::Insets(10, 10, 10, 10)); |
StoreDisplayOverscan(id2, gfx::Insets(20, 20, 20, 20)); |
- NotifyDisplayLocalStatePrefChanged(); |
+ LoadDisplayPreferences(); |
// Check if the layout settings are notified to the system properly. |
ash::DisplayController* display_controller = |
ash::Shell::GetInstance()->display_controller(); |
@@ -187,7 +184,7 @@ TEST_F(DisplayPreferencesTest, PairedLayoutOverrides) { |
StoreDisplayLayoutPrefForPair(id1, dummy_id, ash::DisplayLayout::LEFT, 30); |
StoreDefaultLayoutPref(ash::DisplayLayout::LEFT, 50); |
- NotifyDisplayLocalStatePrefChanged(); |
+ LoadDisplayPreferences(); |
// Check if the layout settings are notified to the system properly. |
// The paired layout overrides old layout. |
ash::DisplayController* display_controller = |
@@ -201,7 +198,12 @@ TEST_F(DisplayPreferencesTest, PairedLayoutOverrides) { |
} |
TEST_F(DisplayPreferencesTest, BasicStores) { |
- UpdateDisplay("100x100,200x200"); |
+ ash::DisplayController* display_controller = |
+ ash::Shell::GetInstance()->display_controller(); |
+ ash::internal::DisplayManager* display_manager = |
+ ash::Shell::GetInstance()->display_manager(); |
+ |
+ UpdateDisplay("200x200*2,200x200"); |
int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); |
int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); |
int64 dummy_id = id2 + 1; |
@@ -213,12 +215,13 @@ TEST_F(DisplayPreferencesTest, BasicStores) { |
StoreDisplayLayoutPrefForTest( |
id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); |
// Can't switch to a display that does not exist. |
- GetDisplayController()->SetPrimaryDisplayId(dummy_id); |
+ display_controller->SetPrimaryDisplayId(dummy_id); |
EXPECT_NE(dummy_id, local_state()->GetInt64(prefs::kPrimaryDisplayID)); |
- SetAndStoreDisplayOverscan( |
- ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay(), |
- gfx::Insets(10, 11, 12, 13)); |
+ display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); |
+ display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90); |
+ display_manager->SetDisplayUIScale(id1, 1.25f); |
+ display_manager->SetDisplayUIScale(id2, 1.25f); |
scoped_ptr<base::DictionaryValue> serialized_value( |
new base::DictionaryValue()); |
@@ -238,21 +241,39 @@ TEST_F(DisplayPreferencesTest, BasicStores) { |
local_state()->GetInteger(prefs::kSecondaryDisplayLayout)); |
EXPECT_EQ(10, local_state()->GetInteger(prefs::kSecondaryDisplayOffset)); |
- const base::DictionaryValue* overscans = |
- local_state()->GetDictionary(prefs::kDisplayOverscans); |
- const base::DictionaryValue* overscan = NULL; |
- EXPECT_TRUE(overscans->GetDictionary(base::Int64ToString(id1), &overscan)); |
+ const base::DictionaryValue* properties = |
+ local_state()->GetDictionary(prefs::kDisplayProperties); |
+ const base::DictionaryValue* property = NULL; |
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); |
+ int ui_scale = 0; |
+ int rotation = 0; |
+ EXPECT_TRUE(property->GetInteger("rotation", &rotation)); |
+ EXPECT_TRUE(property->GetInteger("ui-scale", &ui_scale)); |
+ EXPECT_EQ(1, rotation); |
+ EXPECT_EQ(1250, ui_scale); |
+ |
int top = 0, left = 0, bottom = 0, right = 0; |
- EXPECT_TRUE(overscan->GetInteger("top", &top)); |
- EXPECT_TRUE(overscan->GetInteger("left", &left)); |
- EXPECT_TRUE(overscan->GetInteger("bottom", &bottom)); |
- EXPECT_TRUE(overscan->GetInteger("right", &right)); |
+ EXPECT_TRUE(property->GetInteger("insets_top", &top)); |
+ EXPECT_TRUE(property->GetInteger("insets_left", &left)); |
+ EXPECT_TRUE(property->GetInteger("insets_bottom", &bottom)); |
+ EXPECT_TRUE(property->GetInteger("insets_right", &right)); |
EXPECT_EQ(10, top); |
EXPECT_EQ(11, left); |
EXPECT_EQ(12, bottom); |
EXPECT_EQ(13, right); |
- GetDisplayController()->SetPrimaryDisplayId(id2); |
+ EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); |
+ EXPECT_TRUE(property->GetInteger("rotation", &rotation)); |
+ EXPECT_TRUE(property->GetInteger("ui-scale", &ui_scale)); |
+ EXPECT_EQ(0, rotation); |
+ // ui_scale works only on 2x scale factor/1st display. |
+ EXPECT_EQ(1000, ui_scale); |
+ EXPECT_FALSE(property->GetInteger("insets_top", &top)); |
+ EXPECT_FALSE(property->GetInteger("insets_left", &left)); |
+ EXPECT_FALSE(property->GetInteger("insets_bottom", &bottom)); |
+ EXPECT_FALSE(property->GetInteger("insets_right", &right)); |
+ |
+ display_controller->SetPrimaryDisplayId(id2); |
EXPECT_EQ(id2, local_state()->GetInt64(prefs::kPrimaryDisplayID)); |
// The layout remains the same. |
EXPECT_TRUE(displays->GetDictionary(key, &display_layout)); |
@@ -302,16 +323,26 @@ TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { |
} |
TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { |
- UpdateDisplay("100x100,200x200"); |
+ ash::DisplayController* display_controller = |
+ ash::Shell::GetInstance()->display_controller(); |
+ ash::internal::DisplayManager* display_manager = |
+ ash::Shell::GetInstance()->display_manager(); |
+ |
+ UpdateDisplay("200x200*2,200x200"); |
LoggedInAsGuest(); |
+ int64 id1 = ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay().id(); |
int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); |
ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); |
SetCurrentAndDefaultDisplayLayout(layout); |
- GetDisplayController()->SetPrimaryDisplayId(id2); |
- SetAndStoreDisplayOverscan( |
- ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay(), |
+ display_manager->SetDisplayUIScale(id1, 1.25f); |
+ display_controller->SetPrimaryDisplayId(id2); |
+ int64 new_primary = |
+ ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay().id(); |
+ display_controller->SetOverscanInsets( |
+ new_primary, |
gfx::Insets(10, 11, 12, 13)); |
+ display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90); |
// Does not store the preferences locally. |
EXPECT_FALSE(local_state()->FindPreference( |
@@ -323,17 +354,26 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { |
EXPECT_FALSE(local_state()->FindPreference( |
prefs::kPrimaryDisplayID)->HasUserSetting()); |
EXPECT_FALSE(local_state()->FindPreference( |
- prefs::kDisplayOverscans)->HasUserSetting()); |
+ prefs::kDisplayProperties)->HasUserSetting()); |
// Settings are still notified to the system. |
- ash::DisplayController* display_controller = |
- ash::Shell::GetInstance()->display_controller(); |
gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); |
EXPECT_EQ(ash::DisplayLayout::BOTTOM, |
display_controller->GetCurrentDisplayLayout().position); |
EXPECT_EQ(-10, display_controller->GetCurrentDisplayLayout().offset); |
- EXPECT_EQ("176x178", screen->GetPrimaryDisplay().bounds().size().ToString()); |
+ const gfx::Display& primary_display = screen->GetPrimaryDisplay(); |
+ EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); |
+ |
+ const ash::internal::DisplayInfo& info1 = |
+ display_manager->GetDisplayInfo(id1); |
+ EXPECT_EQ(1.25f, info1.ui_scale()); |
+ |
+ const ash::internal::DisplayInfo& info_primary = |
+ display_manager->GetDisplayInfo(new_primary); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.rotation()); |
+ EXPECT_EQ(1.0f, info_primary.ui_scale()); |
} |
} // namespace |