OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/display/display_preferences.h" | 5 #include "chrome/browser/chromeos/display/display_preferences.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/display/resolution_notification_controller.h" | 10 #include "ash/display/resolution_notification_controller.h" |
11 #include "ash/screen_util.h" | 11 #include "ash/screen_util.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
14 #include "ash/test/display_manager_test_api.h" | 14 #include "ash/test/display_manager_test_api.h" |
| 15 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
15 #include "base/prefs/scoped_user_pref_update.h" | 16 #include "base/prefs/scoped_user_pref_update.h" |
16 #include "base/prefs/testing_pref_service.h" | 17 #include "base/prefs/testing_pref_service.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "chrome/browser/chromeos/display/display_configuration_observer.h" | 20 #include "chrome/browser/chromeos/display/display_configuration_observer.h" |
20 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 21 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
21 #include "chrome/browser/chromeos/login/users/user_manager.h" | 22 #include "chrome/browser/chromeos/login/users/user_manager.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
24 #include "ui/display/chromeos/display_configurator.h" | 25 #include "ui/display/chromeos/display_configurator.h" |
| 26 #include "ui/gfx/vector3d_f.h" |
25 #include "ui/message_center/message_center.h" | 27 #include "ui/message_center/message_center.h" |
26 | 28 |
27 using ash::ResolutionNotificationController; | 29 using ash::ResolutionNotificationController; |
28 | 30 |
29 namespace chromeos { | 31 namespace chromeos { |
30 namespace { | 32 namespace { |
31 const char kPrimaryIdKey[] = "primary-id"; | 33 const char kPrimaryIdKey[] = "primary-id"; |
32 const char kMirroredKey[] = "mirrored"; | 34 const char kMirroredKey[] = "mirrored"; |
33 const char kPositionKey[] = "position"; | 35 const char kPositionKey[] = "position"; |
34 const char kOffsetKey[] = "offset"; | 36 const char kOffsetKey[] = "offset"; |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 EXPECT_EQ("internal_off_external_on", | 615 EXPECT_EQ("internal_off_external_on", |
614 local_state()->GetString(prefs::kDisplayPowerState)); | 616 local_state()->GetString(prefs::kDisplayPowerState)); |
615 | 617 |
616 // Don't try to load | 618 // Don't try to load |
617 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); | 619 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); |
618 LoadDisplayPreferences(false); | 620 LoadDisplayPreferences(false); |
619 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 621 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
620 shell->display_configurator()->power_state()); | 622 shell->display_configurator()->power_state()); |
621 } | 623 } |
622 | 624 |
| 625 // Tests that display configuration changes caused by MaximizeModeController |
| 626 // are not saved. |
| 627 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { |
| 628 ash::Shell* shell = ash::Shell::GetInstance(); |
| 629 ash::MaximizeModeController* controller = shell->maximize_mode_controller(); |
| 630 gfx::Display::SetInternalDisplayId( |
| 631 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); |
| 632 ash::DisplayManager* display_manager = shell->display_manager(); |
| 633 LoggedInAsUser(); |
| 634 // Populate the properties. |
| 635 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 636 gfx::Display::ROTATE_180); |
| 637 // Reset property to avoid rotation lock |
| 638 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 639 gfx::Display::ROTATE_0); |
| 640 |
| 641 // Open up 270 degrees to trigger maximize mode |
| 642 controller->OnAccelerometerUpdated(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
| 643 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
| 644 EXPECT_TRUE(shell->IsMaximizeModeWindowManagerEnabled()); |
| 645 |
| 646 // Trigger 90 degree rotation |
| 647 controller->OnAccelerometerUpdated(gfx::Vector3dF(0.0f, 1.0f, 0.0f), |
| 648 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); |
| 649 EXPECT_EQ(gfx::Display::ROTATE_90, display_manager-> |
| 650 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation()); |
| 651 |
| 652 const base::DictionaryValue* properties = |
| 653 local_state()->GetDictionary(prefs::kDisplayProperties); |
| 654 const base::DictionaryValue* property = NULL; |
| 655 EXPECT_TRUE(properties->GetDictionary( |
| 656 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); |
| 657 int rotation = -1; |
| 658 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); |
| 659 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); |
| 660 } |
| 661 |
623 } // namespace chromeos | 662 } // namespace chromeos |
OLD | NEW |