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

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

Issue 1071353003: Prevent DisplayPreferences from saving incorrect rotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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 d38e5723c070cac4bee2579337c74c09e1ed7b69..5aad7eae938f5a49ef688630adf6cb8fb33ec558 100644
--- a/chrome/browser/chromeos/display/display_preferences_unittest.cc
+++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc
@@ -245,7 +245,8 @@ TEST_F(DisplayPreferencesTest, BasicStores) {
EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id());
display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13));
- display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90);
+ display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90,
+ gfx::Display::ROTATION_SOURCE_USER);
EXPECT_TRUE(display_manager->SetDisplayUIScale(id1, 1.25f));
EXPECT_FALSE(display_manager->SetDisplayUIScale(id2, 1.25f));
@@ -576,7 +577,8 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) {
display_controller->SetOverscanInsets(
new_primary,
gfx::Insets(10, 11, 12, 13));
- display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90);
+ display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90,
+ gfx::Display::ROTATION_SOURCE_USER);
// Does not store the preferences locally.
EXPECT_FALSE(local_state()->FindPreference(
@@ -599,7 +601,8 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) {
const ash::DisplayInfo& info_primary =
display_manager->GetDisplayInfo(new_primary);
- EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.rotation());
+ EXPECT_EQ(gfx::Display::ROTATE_90,
+ info_primary.Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE));
EXPECT_EQ(1.0f, info_primary.configured_ui_scale());
}
@@ -669,10 +672,12 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
LoggedInAsUser();
// Populate the properties.
display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
- gfx::Display::ROTATE_180);
+ gfx::Display::ROTATE_180,
+ gfx::Display::ROTATION_SOURCE_USER);
// Reset property to avoid rotation lock
display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
- gfx::Display::ROTATE_0);
+ gfx::Display::ROTATE_0,
+ gfx::Display::ROTATION_SOURCE_USER);
// Open up 270 degrees to trigger maximize mode
scoped_refptr<chromeos::AccelerometerUpdate> update(
@@ -690,8 +695,9 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, -kMeanGravity, 0.0f, 0.0f);
controller->OnAccelerometerUpdated(update);
shell->screen_orientation_controller()->OnAccelerometerUpdated(update);
- EXPECT_EQ(gfx::Display::ROTATE_90, display_manager->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation());
+ EXPECT_EQ(gfx::Display::ROTATE_90,
+ display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE));
const base::DictionaryValue* properties =
local_state()->GetDictionary(prefs::kDisplayProperties);
@@ -701,6 +707,17 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
int rotation = -1;
EXPECT_TRUE(property->GetInteger("rotation", &rotation));
EXPECT_EQ(gfx::Display::ROTATE_0, rotation);
+
+ // Trigger a save, the acceleration rotation should not be saved as the user
+ // rotation.
jonross 2015/04/10 17:54:43 Test for incorrect orientation being saved.
+ StoreDisplayPrefs();
+ properties = local_state()->GetDictionary(prefs::kDisplayProperties);
+ property = NULL;
+ EXPECT_TRUE(properties->GetDictionary(
+ base::Int64ToString(gfx::Display::InternalDisplayId()), &property));
+ rotation = -1;
+ EXPECT_TRUE(property->GetInteger("rotation", &rotation));
+ EXPECT_EQ(gfx::Display::ROTATE_0, rotation);
}
// Tests that the rotation state is saved without a user being logged in.
@@ -720,9 +737,11 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) {
EXPECT_EQ(current_rotation_lock, rotation_lock);
int orientation;
- gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()->
- display_manager()->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ gfx::Display::Rotation current_rotation =
+ ash::Shell::GetInstance()
+ ->display_manager()
+ ->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
EXPECT_EQ(current_rotation, orientation);
}
@@ -745,9 +764,11 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) {
EXPECT_EQ(current_rotation_lock, rotation_lock);
int orientation;
- gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()->
- display_manager()->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ gfx::Display::Rotation current_rotation =
+ ash::Shell::GetInstance()
+ ->display_manager()
+ ->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
EXPECT_EQ(current_rotation, orientation);
}
@@ -770,9 +791,11 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) {
EXPECT_EQ(current_rotation_lock, rotation_lock);
int orientation;
- gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()->
- display_manager()->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ gfx::Display::Rotation current_rotation =
+ ash::Shell::GetInstance()
+ ->display_manager()
+ ->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
EXPECT_EQ(current_rotation, orientation);
}
@@ -788,8 +811,9 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
bool initial_rotation_lock = IsRotationLocked();
ASSERT_FALSE(initial_rotation_lock);
ash::DisplayManager* display_manager = shell->display_manager();
- gfx::Display::Rotation initial_rotation = display_manager->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ gfx::Display::Rotation initial_rotation =
+ display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation);
StoreDisplayRotationPrefs(initial_rotation_lock);
@@ -806,8 +830,9 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
EXPECT_EQ(gfx::Display::ROTATE_90, display_rotation);
bool rotation_lock = IsRotationLocked();
- gfx::Display::Rotation before_maximize_mode_rotation = display_manager->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ gfx::Display::Rotation before_maximize_mode_rotation =
+ display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
// Settings should not be applied until maximize mode activates
EXPECT_FALSE(rotation_lock);
@@ -824,8 +849,9 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
maximize_mode_controller->OnAccelerometerUpdated(update);
EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled());
bool screen_orientation_rotation_lock = IsRotationLocked();
- gfx::Display::Rotation maximize_mode_rotation = display_manager->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ gfx::Display::Rotation maximize_mode_rotation =
+ display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_TRUE(screen_orientation_rotation_lock);
EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation);
}

Powered by Google App Engine
This is Rietveld 408576698