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

Side by Side Diff: chrome/browser/chromeos/display/display_preferences_unittest.cc

Issue 1108343002: Revert of Merge Prevent DisplayPreferences from saving incorrect rotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
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/content/display/screen_orientation_controller_chromeos.h" 10 #include "ash/content/display/screen_orientation_controller_chromeos.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 LoggedInAsUser(); 238 LoggedInAsUser();
239 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); 239 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10);
240 SetCurrentDisplayLayout(layout); 240 SetCurrentDisplayLayout(layout);
241 StoreDisplayLayoutPrefForTest( 241 StoreDisplayLayoutPrefForTest(
242 id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); 242 id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20));
243 // Can't switch to a display that does not exist. 243 // Can't switch to a display that does not exist.
244 display_controller->SetPrimaryDisplayId(dummy_id); 244 display_controller->SetPrimaryDisplayId(dummy_id);
245 EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); 245 EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id());
246 246
247 display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); 247 display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13));
248 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90, 248 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90);
249 gfx::Display::ROTATION_SOURCE_USER);
250 EXPECT_TRUE(display_manager->SetDisplayUIScale(id1, 1.25f)); 249 EXPECT_TRUE(display_manager->SetDisplayUIScale(id1, 1.25f));
251 EXPECT_FALSE(display_manager->SetDisplayUIScale(id2, 1.25f)); 250 EXPECT_FALSE(display_manager->SetDisplayUIScale(id2, 1.25f));
252 251
253 const base::DictionaryValue* displays = 252 const base::DictionaryValue* displays =
254 local_state()->GetDictionary(prefs::kSecondaryDisplays); 253 local_state()->GetDictionary(prefs::kSecondaryDisplays);
255 const base::DictionaryValue* layout_value = NULL; 254 const base::DictionaryValue* layout_value = NULL;
256 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); 255 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
257 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); 256 EXPECT_TRUE(displays->GetDictionary(key, &layout_value));
258 257
259 ash::DisplayLayout stored_layout; 258 ash::DisplayLayout stored_layout;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 .SetInternalDisplayId(id1); 569 .SetInternalDisplayId(id1);
571 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 570 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
572 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); 571 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10);
573 SetCurrentDisplayLayout(layout); 572 SetCurrentDisplayLayout(layout);
574 display_manager->SetDisplayUIScale(id1, 1.25f); 573 display_manager->SetDisplayUIScale(id1, 1.25f);
575 display_controller->SetPrimaryDisplayId(id2); 574 display_controller->SetPrimaryDisplayId(id2);
576 int64 new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); 575 int64 new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id();
577 display_controller->SetOverscanInsets( 576 display_controller->SetOverscanInsets(
578 new_primary, 577 new_primary,
579 gfx::Insets(10, 11, 12, 13)); 578 gfx::Insets(10, 11, 12, 13));
580 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, 579 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90);
581 gfx::Display::ROTATION_SOURCE_USER);
582 580
583 // Does not store the preferences locally. 581 // Does not store the preferences locally.
584 EXPECT_FALSE(local_state()->FindPreference( 582 EXPECT_FALSE(local_state()->FindPreference(
585 prefs::kSecondaryDisplays)->HasUserSetting()); 583 prefs::kSecondaryDisplays)->HasUserSetting());
586 EXPECT_FALSE(local_state()->FindPreference( 584 EXPECT_FALSE(local_state()->FindPreference(
587 prefs::kDisplayProperties)->HasUserSetting()); 585 prefs::kDisplayProperties)->HasUserSetting());
588 586
589 // Settings are still notified to the system. 587 // Settings are still notified to the system.
590 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 588 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
591 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); 589 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id());
592 EXPECT_EQ(ash::DisplayLayout::BOTTOM, 590 EXPECT_EQ(ash::DisplayLayout::BOTTOM,
593 display_manager->GetCurrentDisplayLayout().position); 591 display_manager->GetCurrentDisplayLayout().position);
594 EXPECT_EQ(-10, display_manager->GetCurrentDisplayLayout().offset); 592 EXPECT_EQ(-10, display_manager->GetCurrentDisplayLayout().offset);
595 const gfx::Display& primary_display = screen->GetPrimaryDisplay(); 593 const gfx::Display& primary_display = screen->GetPrimaryDisplay();
596 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); 594 EXPECT_EQ("178x176", primary_display.bounds().size().ToString());
597 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); 595 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation());
598 596
599 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); 597 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1);
600 EXPECT_EQ(1.25f, info1.configured_ui_scale()); 598 EXPECT_EQ(1.25f, info1.configured_ui_scale());
601 599
602 const ash::DisplayInfo& info_primary = 600 const ash::DisplayInfo& info_primary =
603 display_manager->GetDisplayInfo(new_primary); 601 display_manager->GetDisplayInfo(new_primary);
604 EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.GetActiveRotation()); 602 EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.rotation());
605 EXPECT_EQ(1.0f, info_primary.configured_ui_scale()); 603 EXPECT_EQ(1.0f, info_primary.configured_ui_scale());
606 } 604 }
607 605
608 TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) { 606 TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) {
609 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); 607 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayPowerState));
610 608
611 // Stores display prefs without login, which still stores the power state. 609 // Stores display prefs without login, which still stores the power state.
612 StoreDisplayPrefs(); 610 StoreDisplayPrefs();
613 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState)); 611 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayPowerState));
614 } 612 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 // Tests that display configuration changes caused by MaximizeModeController 662 // Tests that display configuration changes caused by MaximizeModeController
665 // are not saved. 663 // are not saved.
666 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { 664 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
667 ash::Shell* shell = ash::Shell::GetInstance(); 665 ash::Shell* shell = ash::Shell::GetInstance();
668 gfx::Display::SetInternalDisplayId( 666 gfx::Display::SetInternalDisplayId(
669 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 667 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
670 ash::DisplayManager* display_manager = shell->display_manager(); 668 ash::DisplayManager* display_manager = shell->display_manager();
671 LoggedInAsUser(); 669 LoggedInAsUser();
672 // Populate the properties. 670 // Populate the properties.
673 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 671 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
674 gfx::Display::ROTATE_180, 672 gfx::Display::ROTATE_180);
675 gfx::Display::ROTATION_SOURCE_USER);
676 // Reset property to avoid rotation lock 673 // Reset property to avoid rotation lock
677 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 674 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
678 gfx::Display::ROTATE_0, 675 gfx::Display::ROTATE_0);
679 gfx::Display::ROTATION_SOURCE_USER);
680 676
681 // Open up 270 degrees to trigger maximize mode 677 // Open up 270 degrees to trigger maximize mode
682 scoped_refptr<chromeos::AccelerometerUpdate> update( 678 scoped_refptr<chromeos::AccelerometerUpdate> update(
683 new chromeos::AccelerometerUpdate()); 679 new chromeos::AccelerometerUpdate());
684 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f, 680 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f,
685 kMeanGravity); 681 kMeanGravity);
686 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f); 682 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f);
687 ash::MaximizeModeController* controller = shell->maximize_mode_controller(); 683 ash::MaximizeModeController* controller = shell->maximize_mode_controller();
688 controller->OnAccelerometerUpdated(update); 684 controller->OnAccelerometerUpdated(update);
689 EXPECT_TRUE(controller->IsMaximizeModeWindowManagerEnabled()); 685 EXPECT_TRUE(controller->IsMaximizeModeWindowManagerEnabled());
690 686
691 // Trigger 90 degree rotation 687 // Trigger 90 degree rotation
692 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, -kMeanGravity, 688 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, -kMeanGravity,
693 0.0f, 0.0f); 689 0.0f, 0.0f);
694 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, -kMeanGravity, 0.0f, 0.0f); 690 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, -kMeanGravity, 0.0f, 0.0f);
695 controller->OnAccelerometerUpdated(update); 691 controller->OnAccelerometerUpdated(update);
696 shell->screen_orientation_controller()->OnAccelerometerUpdated(update); 692 shell->screen_orientation_controller()->OnAccelerometerUpdated(update);
697 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 693 EXPECT_EQ(gfx::Display::ROTATE_90, display_manager->
694 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation());
698 695
699 const base::DictionaryValue* properties = 696 const base::DictionaryValue* properties =
700 local_state()->GetDictionary(prefs::kDisplayProperties); 697 local_state()->GetDictionary(prefs::kDisplayProperties);
701 const base::DictionaryValue* property = NULL; 698 const base::DictionaryValue* property = NULL;
702 EXPECT_TRUE(properties->GetDictionary( 699 EXPECT_TRUE(properties->GetDictionary(
703 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); 700 base::Int64ToString(gfx::Display::InternalDisplayId()), &property));
704 int rotation = -1; 701 int rotation = -1;
705 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); 702 EXPECT_TRUE(property->GetInteger("rotation", &rotation));
706 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); 703 EXPECT_EQ(gfx::Display::ROTATE_0, rotation);
707
708 // Trigger a save, the acceleration rotation should not be saved as the user
709 // rotation.
710 StoreDisplayPrefs();
711 properties = local_state()->GetDictionary(prefs::kDisplayProperties);
712 property = NULL;
713 EXPECT_TRUE(properties->GetDictionary(
714 base::Int64ToString(gfx::Display::InternalDisplayId()), &property));
715 rotation = -1;
716 EXPECT_TRUE(property->GetInteger("rotation", &rotation));
717 EXPECT_EQ(gfx::Display::ROTATE_0, rotation);
718 } 704 }
719 705
720 // Tests that the rotation state is saved without a user being logged in. 706 // Tests that the rotation state is saved without a user being logged in.
721 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { 707 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) {
722 gfx::Display::SetInternalDisplayId( 708 gfx::Display::SetInternalDisplayId(
723 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 709 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
724 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 710 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
725 711
726 bool current_rotation_lock = IsRotationLocked(); 712 bool current_rotation_lock = IsRotationLocked();
727 StoreDisplayRotationPrefs(current_rotation_lock); 713 StoreDisplayRotationPrefs(current_rotation_lock);
728 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 714 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
729 715
730 const base::DictionaryValue* properties = 716 const base::DictionaryValue* properties =
731 local_state()->GetDictionary(prefs::kDisplayRotationLock); 717 local_state()->GetDictionary(prefs::kDisplayRotationLock);
732 bool rotation_lock; 718 bool rotation_lock;
733 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 719 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
734 EXPECT_EQ(current_rotation_lock, rotation_lock); 720 EXPECT_EQ(current_rotation_lock, rotation_lock);
735 721
736 int orientation; 722 int orientation;
737 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 723 gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()->
724 display_manager()->
725 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
738 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 726 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
739 EXPECT_EQ(current_rotation, orientation); 727 EXPECT_EQ(current_rotation, orientation);
740 } 728 }
741 729
742 // Tests that the rotation state is saved when a guest is logged in. 730 // Tests that the rotation state is saved when a guest is logged in.
743 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { 731 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) {
744 gfx::Display::SetInternalDisplayId( 732 gfx::Display::SetInternalDisplayId(
745 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 733 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
746 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 734 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
747 LoggedInAsGuest(); 735 LoggedInAsGuest();
748 736
749 bool current_rotation_lock = IsRotationLocked(); 737 bool current_rotation_lock = IsRotationLocked();
750 StoreDisplayRotationPrefs(current_rotation_lock); 738 StoreDisplayRotationPrefs(current_rotation_lock);
751 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 739 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
752 740
753 const base::DictionaryValue* properties = 741 const base::DictionaryValue* properties =
754 local_state()->GetDictionary(prefs::kDisplayRotationLock); 742 local_state()->GetDictionary(prefs::kDisplayRotationLock);
755 bool rotation_lock; 743 bool rotation_lock;
756 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 744 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
757 EXPECT_EQ(current_rotation_lock, rotation_lock); 745 EXPECT_EQ(current_rotation_lock, rotation_lock);
758 746
759 int orientation; 747 int orientation;
760 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 748 gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()->
749 display_manager()->
750 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
761 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 751 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
762 EXPECT_EQ(current_rotation, orientation); 752 EXPECT_EQ(current_rotation, orientation);
763 } 753 }
764 754
765 // Tests that the rotation state is saved when a normal user is logged in. 755 // Tests that the rotation state is saved when a normal user is logged in.
766 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { 756 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) {
767 gfx::Display::SetInternalDisplayId( 757 gfx::Display::SetInternalDisplayId(
768 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 758 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
769 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 759 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
770 LoggedInAsGuest(); 760 LoggedInAsGuest();
771 761
772 bool current_rotation_lock = IsRotationLocked(); 762 bool current_rotation_lock = IsRotationLocked();
773 StoreDisplayRotationPrefs(current_rotation_lock); 763 StoreDisplayRotationPrefs(current_rotation_lock);
774 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 764 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
775 765
776 const base::DictionaryValue* properties = 766 const base::DictionaryValue* properties =
777 local_state()->GetDictionary(prefs::kDisplayRotationLock); 767 local_state()->GetDictionary(prefs::kDisplayRotationLock);
778 bool rotation_lock; 768 bool rotation_lock;
779 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 769 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
780 EXPECT_EQ(current_rotation_lock, rotation_lock); 770 EXPECT_EQ(current_rotation_lock, rotation_lock);
781 771
782 int orientation; 772 int orientation;
783 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 773 gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()->
774 display_manager()->
775 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
784 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 776 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
785 EXPECT_EQ(current_rotation, orientation); 777 EXPECT_EQ(current_rotation, orientation);
786 } 778 }
787 779
788 // Tests that rotation state is loaded without a user being logged in, and that 780 // Tests that rotation state is loaded without a user being logged in, and that
789 // entering maximize mode applies the state. 781 // entering maximize mode applies the state.
790 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { 782 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
791 gfx::Display::SetInternalDisplayId( 783 gfx::Display::SetInternalDisplayId(
792 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 784 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
793 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 785 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
794 786
795 ash::Shell* shell = ash::Shell::GetInstance(); 787 ash::Shell* shell = ash::Shell::GetInstance();
796 bool initial_rotation_lock = IsRotationLocked(); 788 bool initial_rotation_lock = IsRotationLocked();
797 ASSERT_FALSE(initial_rotation_lock); 789 ASSERT_FALSE(initial_rotation_lock);
798 ash::DisplayManager* display_manager = shell->display_manager(); 790 ash::DisplayManager* display_manager = shell->display_manager();
799 gfx::Display::Rotation initial_rotation = GetCurrentInternalDisplayRotation(); 791 gfx::Display::Rotation initial_rotation = display_manager->
792 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
800 ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation); 793 ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation);
801 794
802 StoreDisplayRotationPrefs(initial_rotation_lock); 795 StoreDisplayRotationPrefs(initial_rotation_lock);
803 ASSERT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 796 ASSERT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
804 797
805 StoreDisplayRotationPrefsForTest(true, gfx::Display::ROTATE_90); 798 StoreDisplayRotationPrefsForTest(true, gfx::Display::ROTATE_90);
806 LoadDisplayPreferences(false); 799 LoadDisplayPreferences(false);
807 800
808 bool display_rotation_lock = 801 bool display_rotation_lock =
809 display_manager->registered_internal_display_rotation_lock(); 802 display_manager->registered_internal_display_rotation_lock();
810 bool display_rotation = 803 bool display_rotation =
811 display_manager->registered_internal_display_rotation(); 804 display_manager->registered_internal_display_rotation();
812 EXPECT_TRUE(display_rotation_lock); 805 EXPECT_TRUE(display_rotation_lock);
813 EXPECT_EQ(gfx::Display::ROTATE_90, display_rotation); 806 EXPECT_EQ(gfx::Display::ROTATE_90, display_rotation);
814 807
815 bool rotation_lock = IsRotationLocked(); 808 bool rotation_lock = IsRotationLocked();
816 gfx::Display::Rotation before_maximize_mode_rotation = 809 gfx::Display::Rotation before_maximize_mode_rotation = display_manager->
817 GetCurrentInternalDisplayRotation(); 810 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
818 811
819 // Settings should not be applied until maximize mode activates 812 // Settings should not be applied until maximize mode activates
820 EXPECT_FALSE(rotation_lock); 813 EXPECT_FALSE(rotation_lock);
821 EXPECT_EQ(gfx::Display::ROTATE_0, before_maximize_mode_rotation); 814 EXPECT_EQ(gfx::Display::ROTATE_0, before_maximize_mode_rotation);
822 815
823 // Open up 270 degrees to trigger maximize mode 816 // Open up 270 degrees to trigger maximize mode
824 scoped_refptr<chromeos::AccelerometerUpdate> update( 817 scoped_refptr<chromeos::AccelerometerUpdate> update(
825 new chromeos::AccelerometerUpdate()); 818 new chromeos::AccelerometerUpdate());
826 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f, 819 update->Set(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, 0.0f, 0.0f,
827 kMeanGravity); 820 kMeanGravity);
828 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f); 821 update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, 0.0f, -kMeanGravity, 0.0f);
829 ash::MaximizeModeController* maximize_mode_controller = 822 ash::MaximizeModeController* maximize_mode_controller =
830 shell->maximize_mode_controller(); 823 shell->maximize_mode_controller();
831 maximize_mode_controller->OnAccelerometerUpdated(update); 824 maximize_mode_controller->OnAccelerometerUpdated(update);
832 EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled()); 825 EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled());
833 bool screen_orientation_rotation_lock = IsRotationLocked(); 826 bool screen_orientation_rotation_lock = IsRotationLocked();
834 gfx::Display::Rotation maximize_mode_rotation = 827 gfx::Display::Rotation maximize_mode_rotation = display_manager->
835 GetCurrentInternalDisplayRotation(); 828 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
836 EXPECT_TRUE(screen_orientation_rotation_lock); 829 EXPECT_TRUE(screen_orientation_rotation_lock);
837 EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation); 830 EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation);
838 } 831 }
839 832
840 // Tests that rotation lock being set causes the rotation state to be saved. 833 // Tests that rotation lock being set causes the rotation state to be saved.
841 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) { 834 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) {
842 gfx::Display::SetInternalDisplayId( 835 gfx::Display::SetInternalDisplayId(
843 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 836 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id());
844 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 837 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
845 838
846 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( 839 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
847 true); 840 true);
848 841
849 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 842 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
850 843
851 const base::DictionaryValue* properties = 844 const base::DictionaryValue* properties =
852 local_state()->GetDictionary(prefs::kDisplayRotationLock); 845 local_state()->GetDictionary(prefs::kDisplayRotationLock);
853 bool rotation_lock; 846 bool rotation_lock;
854 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 847 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
855 } 848 }
856 849
857 } // namespace chromeos 850 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/display/display_preferences.cc ('k') | chrome/browser/extensions/display_info_provider_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698