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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 StoreDisplayLayoutPrefForPair(id1, id2, ash::DisplayLayout::TOP, 20); | 184 StoreDisplayLayoutPrefForPair(id1, id2, ash::DisplayLayout::TOP, 20); |
185 StoreDisplayLayoutPrefForPair(id1, dummy_id, ash::DisplayLayout::LEFT, 30); | 185 StoreDisplayLayoutPrefForPair(id1, dummy_id, ash::DisplayLayout::LEFT, 30); |
186 StoreDisplayPowerStateForTest( | 186 StoreDisplayPowerStateForTest( |
187 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); | 187 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); |
188 | 188 |
189 ash::Shell* shell = ash::Shell::GetInstance(); | 189 ash::Shell* shell = ash::Shell::GetInstance(); |
190 | 190 |
191 LoadDisplayPreferences(true); | 191 LoadDisplayPreferences(true); |
192 // DisplayPowerState should be ignored at boot. | 192 // DisplayPowerState should be ignored at boot. |
193 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, | 193 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
194 shell->display_configurator()->power_state()); | 194 shell->display_configurator()->requested_power_state()); |
195 | 195 |
196 shell->display_manager()->UpdateDisplays(); | 196 shell->display_manager()->UpdateDisplays(); |
197 // Check if the layout settings are notified to the system properly. | 197 // Check if the layout settings are notified to the system properly. |
198 // The paired layout overrides old layout. | 198 // The paired layout overrides old layout. |
199 // Inverted one of for specified pair (id1, id2). Not used for the pair | 199 // Inverted one of for specified pair (id1, id2). Not used for the pair |
200 // (id1, dummy_id) since dummy_id is not connected right now. | 200 // (id1, dummy_id) since dummy_id is not connected right now. |
201 EXPECT_EQ("top, 20", | 201 EXPECT_EQ("top, 20", |
202 shell->display_manager()->GetCurrentDisplayLayout().ToString()); | 202 shell->display_manager()->GetCurrentDisplayLayout().ToString()); |
203 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(id1, id2)); | 203 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(id1, id2)); |
204 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(id1, dummy_id)); | 204 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(id1, dummy_id)); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 LoggedInAsUser(); | 616 LoggedInAsUser(); |
617 StoreDisplayPrefs(); | 617 StoreDisplayPrefs(); |
618 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); | 618 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); |
619 } | 619 } |
620 | 620 |
621 TEST_F(DisplayPreferencesTest, DisplayPowerStateAfterRestart) { | 621 TEST_F(DisplayPreferencesTest, DisplayPowerStateAfterRestart) { |
622 StoreDisplayPowerStateForTest( | 622 StoreDisplayPowerStateForTest( |
623 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); | 623 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); |
624 LoadDisplayPreferences(false); | 624 LoadDisplayPreferences(false); |
625 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 625 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
626 ash::Shell::GetInstance()->display_configurator()->power_state()); | 626 ash::Shell::GetInstance()->display_configurator()-> |
| 627 requested_power_state()); |
627 } | 628 } |
628 | 629 |
629 TEST_F(DisplayPreferencesTest, DontSaveAndRestoreAllOff) { | 630 TEST_F(DisplayPreferencesTest, DontSaveAndRestoreAllOff) { |
630 ash::Shell* shell = ash::Shell::GetInstance(); | 631 ash::Shell* shell = ash::Shell::GetInstance(); |
631 StoreDisplayPowerStateForTest( | 632 StoreDisplayPowerStateForTest( |
632 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); | 633 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); |
633 LoadDisplayPreferences(false); | 634 LoadDisplayPreferences(false); |
634 // DisplayPowerState should be ignored at boot. | 635 // DisplayPowerState should be ignored at boot. |
635 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 636 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
636 shell->display_configurator()->power_state()); | 637 shell->display_configurator()->requested_power_state()); |
637 | 638 |
638 StoreDisplayPowerStateForTest( | 639 StoreDisplayPowerStateForTest( |
639 chromeos::DISPLAY_POWER_ALL_OFF); | 640 chromeos::DISPLAY_POWER_ALL_OFF); |
640 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 641 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
641 shell->display_configurator()->power_state()); | 642 shell->display_configurator()->requested_power_state()); |
642 EXPECT_EQ("internal_off_external_on", | 643 EXPECT_EQ("internal_off_external_on", |
643 local_state()->GetString(prefs::kDisplayPowerState)); | 644 local_state()->GetString(prefs::kDisplayPowerState)); |
644 | 645 |
645 // Don't try to load | 646 // Don't try to load |
646 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); | 647 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); |
647 LoadDisplayPreferences(false); | 648 LoadDisplayPreferences(false); |
648 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 649 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
649 shell->display_configurator()->power_state()); | 650 shell->display_configurator()->requested_power_state()); |
650 } | 651 } |
651 | 652 |
652 // Tests that display configuration changes caused by MaximizeModeController | 653 // Tests that display configuration changes caused by MaximizeModeController |
653 // are not saved. | 654 // are not saved. |
654 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { | 655 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { |
655 ash::Shell* shell = ash::Shell::GetInstance(); | 656 ash::Shell* shell = ash::Shell::GetInstance(); |
656 ash::MaximizeModeController* controller = shell->maximize_mode_controller(); | 657 ash::MaximizeModeController* controller = shell->maximize_mode_controller(); |
657 gfx::Display::SetInternalDisplayId( | 658 gfx::Display::SetInternalDisplayId( |
658 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); | 659 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); |
659 ash::DisplayManager* display_manager = shell->display_manager(); | 660 ash::DisplayManager* display_manager = shell->display_manager(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 871 |
871 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 872 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
872 | 873 |
873 const base::DictionaryValue* properties = | 874 const base::DictionaryValue* properties = |
874 local_state()->GetDictionary(prefs::kDisplayRotationLock); | 875 local_state()->GetDictionary(prefs::kDisplayRotationLock); |
875 bool rotation_lock; | 876 bool rotation_lock; |
876 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); | 877 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); |
877 } | 878 } |
878 | 879 |
879 } // namespace chromeos | 880 } // namespace chromeos |
OLD | NEW |