| 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 0829dcbbac37e5e33c630358a062af1eb819f662..b9b9fed00e159272cc7b310a4f0f22074de20897 100644
|
| --- a/chrome/browser/chromeos/display/display_preferences_unittest.cc
|
| +++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc
|
| @@ -7,6 +7,7 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "ash/content/display/screen_orientation_delegate_chromeos.h"
|
| #include "ash/display/display_controller.h"
|
| #include "ash/display/display_layout_store.h"
|
| #include "ash/display/display_manager.h"
|
| @@ -41,6 +42,12 @@ const char kOffsetKey[] = "offset";
|
| // The mean acceleration due to gravity on Earth in m/s^2.
|
| const float kMeanGravity = 9.80665f;
|
|
|
| +bool rotation_locked() {
|
| + return ash::Shell::GetInstance()
|
| + ->screen_orientation_delegate()
|
| + ->rotation_locked();
|
| +}
|
| +
|
| class DisplayPreferencesTest : public ash::test::AshTestBase {
|
| protected:
|
| DisplayPreferencesTest()
|
| @@ -654,7 +661,6 @@ TEST_F(DisplayPreferencesTest, DontSaveAndRestoreAllOff) {
|
| // are not saved.
|
| TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
|
| ash::Shell* shell = ash::Shell::GetInstance();
|
| - ash::MaximizeModeController* controller = shell->maximize_mode_controller();
|
| gfx::Display::SetInternalDisplayId(
|
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
|
| ash::DisplayManager* display_manager = shell->display_manager();
|
| @@ -672,6 +678,7 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
|
| 0.0f, 0.0f, kMeanGravity);
|
| update.Set(ui::ACCELEROMETER_SOURCE_SCREEN,
|
| 0.0f, -kMeanGravity, 0.0f);
|
| + ash::MaximizeModeController* controller = shell->maximize_mode_controller();
|
| controller->OnAccelerometerUpdated(update);
|
| EXPECT_TRUE(controller->IsMaximizeModeWindowManagerEnabled());
|
|
|
| @@ -700,8 +707,7 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) {
|
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
|
| EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
|
|
| - bool current_rotation_lock =
|
| - ash::Shell::GetInstance()->maximize_mode_controller()->rotation_locked();
|
| + bool current_rotation_lock = rotation_locked();
|
| StoreDisplayRotationPrefs(current_rotation_lock);
|
| EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
|
|
| @@ -726,8 +732,7 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) {
|
| EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
| LoggedInAsGuest();
|
|
|
| - bool current_rotation_lock =
|
| - ash::Shell::GetInstance()->maximize_mode_controller()->rotation_locked();
|
| + bool current_rotation_lock = rotation_locked();
|
| StoreDisplayRotationPrefs(current_rotation_lock);
|
| EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
|
|
| @@ -752,8 +757,7 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) {
|
| EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
| LoggedInAsGuest();
|
|
|
| - bool current_rotation_lock =
|
| - ash::Shell::GetInstance()->maximize_mode_controller()->rotation_locked();
|
| + bool current_rotation_lock = rotation_locked();
|
| StoreDisplayRotationPrefs(current_rotation_lock);
|
| EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
|
|
| @@ -779,9 +783,7 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
|
| ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
|
|
| ash::Shell* shell = ash::Shell::GetInstance();
|
| - ash::MaximizeModeController* maximize_mode_controller =
|
| - shell->maximize_mode_controller();
|
| - bool initial_rotation_lock = maximize_mode_controller->rotation_locked();
|
| + bool initial_rotation_lock = rotation_locked();
|
| ASSERT_FALSE(initial_rotation_lock);
|
| ash::DisplayManager* display_manager = shell->display_manager();
|
| gfx::Display::Rotation initial_rotation = display_manager->
|
| @@ -801,7 +803,7 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
|
| EXPECT_TRUE(display_rotation_lock);
|
| EXPECT_EQ(gfx::Display::ROTATE_90, display_rotation);
|
|
|
| - bool rotation_lock = maximize_mode_controller->rotation_locked();
|
| + bool rotation_lock = rotation_locked();
|
| gfx::Display::Rotation before_maximize_mode_rotation = display_manager->
|
| GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
|
|
|
| @@ -815,13 +817,14 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
|
| 0.0f, 0.0f, kMeanGravity);
|
| update.Set(ui::ACCELEROMETER_SOURCE_SCREEN,
|
| 0.0f, -kMeanGravity, 0.0f);
|
| + ash::MaximizeModeController* maximize_mode_controller =
|
| + shell->maximize_mode_controller();
|
| maximize_mode_controller->OnAccelerometerUpdated(update);
|
| EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled());
|
| - bool maximize_mode_rotation_lock =
|
| - maximize_mode_controller->rotation_locked();
|
| + bool screen_orientation_rotation_lock = rotation_locked();
|
| gfx::Display::Rotation maximize_mode_rotation = display_manager->
|
| GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
|
| - EXPECT_TRUE(maximize_mode_rotation_lock);
|
| + EXPECT_TRUE(screen_orientation_rotation_lock);
|
| EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation);
|
| }
|
|
|
| @@ -847,7 +850,7 @@ TEST_F(DisplayPreferencesTest, LoadRotationIgnoredInNormalMode) {
|
| -kMeanGravity, 0.0f, 0.0f);
|
| maximize_mode_controller->OnAccelerometerUpdated(update);
|
| EXPECT_FALSE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled());
|
| - EXPECT_FALSE(maximize_mode_controller->rotation_locked());
|
| + EXPECT_FALSE(rotation_locked());
|
|
|
| // Open up 270 degrees to trigger maximize mode
|
| update.Set(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD,
|
| @@ -856,7 +859,7 @@ TEST_F(DisplayPreferencesTest, LoadRotationIgnoredInNormalMode) {
|
| 0.0f, -kMeanGravity, 0.0f);
|
| maximize_mode_controller->OnAccelerometerUpdated(update);
|
| EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled());
|
| - EXPECT_FALSE(maximize_mode_controller->rotation_locked());
|
| + EXPECT_FALSE(rotation_locked());
|
| }
|
|
|
| // Tests that rotation lock being set causes the rotation state to be saved.
|
| @@ -865,9 +868,8 @@ TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) {
|
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
|
| ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
|
|
| - ash::MaximizeModeController* maximize_mode_controller =
|
| - ash::Shell::GetInstance()->maximize_mode_controller();
|
| - maximize_mode_controller->SetRotationLocked(true);
|
| + ash::Shell::GetInstance()->screen_orientation_delegate()->SetRotationLocked(
|
| + true);
|
|
|
| EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
|
|
|
|
|