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" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 LoggedInAsUser(); | 214 LoggedInAsUser(); |
215 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); | 215 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); |
216 SetCurrentDisplayLayout(layout); | 216 SetCurrentDisplayLayout(layout); |
217 StoreDisplayLayoutPrefForTest( | 217 StoreDisplayLayoutPrefForTest( |
218 id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); | 218 id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); |
219 // Can't switch to a display that does not exist. | 219 // Can't switch to a display that does not exist. |
220 display_controller->SetPrimaryDisplayId(dummy_id); | 220 display_controller->SetPrimaryDisplayId(dummy_id); |
221 EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); | 221 EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); |
222 | 222 |
223 display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); | 223 display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); |
224 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90); | 224 display_manager->SetDisplayRotation(id1, |
| 225 gfx::Display::ROTATE_90, |
| 226 ui::USER); |
225 display_manager->SetDisplayUIScale(id1, 1.25f); | 227 display_manager->SetDisplayUIScale(id1, 1.25f); |
226 display_manager->SetDisplayUIScale(id2, 1.25f); | 228 display_manager->SetDisplayUIScale(id2, 1.25f); |
227 | 229 |
228 const base::DictionaryValue* displays = | 230 const base::DictionaryValue* displays = |
229 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 231 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
230 const base::DictionaryValue* layout_value = NULL; | 232 const base::DictionaryValue* layout_value = NULL; |
231 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); | 233 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
232 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 234 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
233 | 235 |
234 ash::DisplayLayout stored_layout; | 236 ash::DisplayLayout stored_layout; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 gfx::Display::SetInternalDisplayId(id1); | 533 gfx::Display::SetInternalDisplayId(id1); |
532 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 534 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
533 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); | 535 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); |
534 SetCurrentDisplayLayout(layout); | 536 SetCurrentDisplayLayout(layout); |
535 display_manager->SetDisplayUIScale(id1, 1.25f); | 537 display_manager->SetDisplayUIScale(id1, 1.25f); |
536 display_controller->SetPrimaryDisplayId(id2); | 538 display_controller->SetPrimaryDisplayId(id2); |
537 int64 new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); | 539 int64 new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); |
538 display_controller->SetOverscanInsets( | 540 display_controller->SetOverscanInsets( |
539 new_primary, | 541 new_primary, |
540 gfx::Insets(10, 11, 12, 13)); | 542 gfx::Insets(10, 11, 12, 13)); |
541 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90); | 543 display_manager->SetDisplayRotation(new_primary, |
| 544 gfx::Display::ROTATE_90, |
| 545 ui::USER); |
542 | 546 |
543 // Does not store the preferences locally. | 547 // Does not store the preferences locally. |
544 EXPECT_FALSE(local_state()->FindPreference( | 548 EXPECT_FALSE(local_state()->FindPreference( |
545 prefs::kSecondaryDisplays)->HasUserSetting()); | 549 prefs::kSecondaryDisplays)->HasUserSetting()); |
546 EXPECT_FALSE(local_state()->FindPreference( | 550 EXPECT_FALSE(local_state()->FindPreference( |
547 prefs::kDisplayProperties)->HasUserSetting()); | 551 prefs::kDisplayProperties)->HasUserSetting()); |
548 | 552 |
549 // Settings are still notified to the system. | 553 // Settings are still notified to the system. |
550 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 554 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
551 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); | 555 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 EXPECT_EQ("internal_off_external_on", | 617 EXPECT_EQ("internal_off_external_on", |
614 local_state()->GetString(prefs::kDisplayPowerState)); | 618 local_state()->GetString(prefs::kDisplayPowerState)); |
615 | 619 |
616 // Don't try to load | 620 // Don't try to load |
617 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); | 621 local_state()->SetString(prefs::kDisplayPowerState, "all_off"); |
618 LoadDisplayPreferences(false); | 622 LoadDisplayPreferences(false); |
619 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 623 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
620 shell->display_configurator()->power_state()); | 624 shell->display_configurator()->power_state()); |
621 } | 625 } |
622 | 626 |
| 627 // Tests that changes to display rotation caused by an accelerometer are not |
| 628 // saved to user preferences. |
| 629 TEST_F(DisplayPreferencesTest, DontSaveAccelerometerRotation) { |
| 630 ash::DisplayManager* display_manager = |
| 631 ash::Shell::GetInstance()->display_manager(); |
| 632 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 633 gfx::Display::ROTATE_180, |
| 634 ui::USER); |
| 635 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 636 gfx::Display::ROTATE_0, |
| 637 ui::ACCELEROMETER); |
| 638 const base::DictionaryValue* properties = |
| 639 local_state()->GetDictionary(prefs::kDisplayProperties); |
| 640 const base::DictionaryValue* property = NULL; |
| 641 EXPECT_TRUE(properties->GetDictionary( |
| 642 base::Int64ToString(gfx::Display::InternalDisplayId()), |
| 643 &property)); |
| 644 int rotation = -1; |
| 645 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); |
| 646 EXPECT_EQ(gfx::Display::ROTATE_180, rotation); |
| 647 } |
| 648 |
623 } // namespace chromeos | 649 } // namespace chromeos |
OLD | NEW |