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

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

Issue 1608733002: Remove ui/gfx/screen_type_delegate.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-4
Patch Set: fixes Created 4 years, 11 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 <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(dummy_pair)); 240 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(dummy_pair));
241 } 241 }
242 242
243 TEST_F(DisplayPreferencesTest, BasicStores) { 243 TEST_F(DisplayPreferencesTest, BasicStores) {
244 ash::WindowTreeHostManager* window_tree_host_manager = 244 ash::WindowTreeHostManager* window_tree_host_manager =
245 ash::Shell::GetInstance()->window_tree_host_manager(); 245 ash::Shell::GetInstance()->window_tree_host_manager();
246 ash::DisplayManager* display_manager = 246 ash::DisplayManager* display_manager =
247 ash::Shell::GetInstance()->display_manager(); 247 ash::Shell::GetInstance()->display_manager();
248 248
249 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); 249 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25");
250 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); 250 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
251 ash::test::ScopedSetInternalDisplayId set_internal(id1); 251 ash::test::ScopedSetInternalDisplayId set_internal(id1);
252 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 252 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
253 int64_t dummy_id = id2 + 1; 253 int64_t dummy_id = id2 + 1;
254 ASSERT_NE(id1, dummy_id); 254 ASSERT_NE(id1, dummy_id);
255 std::vector<ui::ColorCalibrationProfile> profiles; 255 std::vector<ui::ColorCalibrationProfile> profiles;
256 profiles.push_back(ui::COLOR_PROFILE_STANDARD); 256 profiles.push_back(ui::COLOR_PROFILE_STANDARD);
257 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); 257 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC);
258 profiles.push_back(ui::COLOR_PROFILE_MOVIE); 258 profiles.push_back(ui::COLOR_PROFILE_MOVIE);
259 profiles.push_back(ui::COLOR_PROFILE_READING); 259 profiles.push_back(ui::COLOR_PROFILE_READING);
260 // Allows only |id1|. 260 // Allows only |id1|.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 property = NULL; 513 property = NULL;
514 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); 514 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property));
515 EXPECT_TRUE(property->GetInteger("width", &width)); 515 EXPECT_TRUE(property->GetInteger("width", &width));
516 EXPECT_TRUE(property->GetInteger("height", &height)); 516 EXPECT_TRUE(property->GetInteger("height", &height));
517 EXPECT_EQ(300, width); 517 EXPECT_EQ(300, width);
518 EXPECT_EQ(200, height); 518 EXPECT_EQ(200, height);
519 } 519 }
520 520
521 TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { 521 TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) {
522 UpdateDisplay("100x100,200x200"); 522 UpdateDisplay("100x100,200x200");
523 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); 523 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
524 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); 524 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id();
525 525
526 ash::WindowTreeHostManager* window_tree_host_manager = 526 ash::WindowTreeHostManager* window_tree_host_manager =
527 ash::Shell::GetInstance()->window_tree_host_manager(); 527 ash::Shell::GetInstance()->window_tree_host_manager();
528 window_tree_host_manager->SwapPrimaryDisplay(); 528 window_tree_host_manager->SwapPrimaryDisplay();
529 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); 529 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id());
530 530
531 LoggedInAsUser(); 531 LoggedInAsUser();
532 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); 532 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10);
533 SetCurrentDisplayLayout(layout); 533 SetCurrentDisplayLayout(layout);
(...skipping 16 matching lines...) Expand all
550 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); 550 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout));
551 EXPECT_EQ(layout.position, stored_layout.position); 551 EXPECT_EQ(layout.position, stored_layout.position);
552 EXPECT_EQ(layout.offset, stored_layout.offset); 552 EXPECT_EQ(layout.offset, stored_layout.offset);
553 EXPECT_EQ(id1, stored_layout.primary_id); 553 EXPECT_EQ(id1, stored_layout.primary_id);
554 } 554 }
555 555
556 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { 556 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) {
557 ash::DisplayManager* display_manager = 557 ash::DisplayManager* display_manager =
558 ash::Shell::GetInstance()->display_manager(); 558 ash::Shell::GetInstance()->display_manager();
559 559
560 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); 560 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
561 561
562 StoreColorProfile(id1, "dynamic"); 562 StoreColorProfile(id1, "dynamic");
563 563
564 LoggedInAsUser(); 564 LoggedInAsUser();
565 LoadDisplayPreferences(false); 565 LoadDisplayPreferences(false);
566 566
567 // id1's available color profiles list is empty, means somehow the color 567 // id1's available color profiles list is empty, means somehow the color
568 // profile suport is temporary in trouble. 568 // profile suport is temporary in trouble.
569 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, 569 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC,
570 display_manager->GetDisplayInfo(id1).color_profile()); 570 display_manager->GetDisplayInfo(id1).color_profile());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, 604 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90,
605 gfx::Display::ROTATION_SOURCE_USER); 605 gfx::Display::ROTATION_SOURCE_USER);
606 606
607 // Does not store the preferences locally. 607 // Does not store the preferences locally.
608 EXPECT_FALSE(local_state()->FindPreference( 608 EXPECT_FALSE(local_state()->FindPreference(
609 prefs::kSecondaryDisplays)->HasUserSetting()); 609 prefs::kSecondaryDisplays)->HasUserSetting());
610 EXPECT_FALSE(local_state()->FindPreference( 610 EXPECT_FALSE(local_state()->FindPreference(
611 prefs::kDisplayProperties)->HasUserSetting()); 611 prefs::kDisplayProperties)->HasUserSetting());
612 612
613 // Settings are still notified to the system. 613 // Settings are still notified to the system.
614 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 614 gfx::Screen* screen = gfx::Screen::GetScreen();
615 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); 615 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id());
616 EXPECT_EQ(ash::DisplayLayout::BOTTOM, 616 EXPECT_EQ(ash::DisplayLayout::BOTTOM,
617 display_manager->GetCurrentDisplayLayout().position); 617 display_manager->GetCurrentDisplayLayout().position);
618 EXPECT_EQ(-10, display_manager->GetCurrentDisplayLayout().offset); 618 EXPECT_EQ(-10, display_manager->GetCurrentDisplayLayout().offset);
619 const gfx::Display& primary_display = screen->GetPrimaryDisplay(); 619 const gfx::Display& primary_display = screen->GetPrimaryDisplay();
620 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); 620 EXPECT_EQ("178x176", primary_display.bounds().size().ToString());
621 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); 621 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation());
622 622
623 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); 623 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1);
624 EXPECT_EQ(1.25f, info1.configured_ui_scale()); 624 EXPECT_EQ(1.25f, info1.configured_ui_scale());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 LoadDisplayPreferences(false); 683 LoadDisplayPreferences(false);
684 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, 684 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
685 shell->display_configurator()->requested_power_state()); 685 shell->display_configurator()->requested_power_state());
686 } 686 }
687 687
688 // Tests that display configuration changes caused by MaximizeModeController 688 // Tests that display configuration changes caused by MaximizeModeController
689 // are not saved. 689 // are not saved.
690 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { 690 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) {
691 ash::Shell* shell = ash::Shell::GetInstance(); 691 ash::Shell* shell = ash::Shell::GetInstance();
692 gfx::Display::SetInternalDisplayId( 692 gfx::Display::SetInternalDisplayId(
693 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 693 gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
694 ash::DisplayManager* display_manager = shell->display_manager(); 694 ash::DisplayManager* display_manager = shell->display_manager();
695 LoggedInAsUser(); 695 LoggedInAsUser();
696 // Populate the properties. 696 // Populate the properties.
697 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 697 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
698 gfx::Display::ROTATE_180, 698 gfx::Display::ROTATE_180,
699 gfx::Display::ROTATION_SOURCE_USER); 699 gfx::Display::ROTATION_SOURCE_USER);
700 // Reset property to avoid rotation lock 700 // Reset property to avoid rotation lock
701 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 701 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
702 gfx::Display::ROTATE_0, 702 gfx::Display::ROTATE_0,
703 gfx::Display::ROTATION_SOURCE_USER); 703 gfx::Display::ROTATION_SOURCE_USER);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 EXPECT_TRUE(properties->GetDictionary( 737 EXPECT_TRUE(properties->GetDictionary(
738 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); 738 base::Int64ToString(gfx::Display::InternalDisplayId()), &property));
739 rotation = -1; 739 rotation = -1;
740 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); 740 EXPECT_TRUE(property->GetInteger("rotation", &rotation));
741 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); 741 EXPECT_EQ(gfx::Display::ROTATE_0, rotation);
742 } 742 }
743 743
744 // Tests that the rotation state is saved without a user being logged in. 744 // Tests that the rotation state is saved without a user being logged in.
745 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { 745 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) {
746 gfx::Display::SetInternalDisplayId( 746 gfx::Display::SetInternalDisplayId(
747 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 747 gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
748 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 748 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
749 749
750 bool current_rotation_lock = IsRotationLocked(); 750 bool current_rotation_lock = IsRotationLocked();
751 StoreDisplayRotationPrefs(current_rotation_lock); 751 StoreDisplayRotationPrefs(current_rotation_lock);
752 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 752 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
753 753
754 const base::DictionaryValue* properties = 754 const base::DictionaryValue* properties =
755 local_state()->GetDictionary(prefs::kDisplayRotationLock); 755 local_state()->GetDictionary(prefs::kDisplayRotationLock);
756 bool rotation_lock; 756 bool rotation_lock;
757 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 757 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
758 EXPECT_EQ(current_rotation_lock, rotation_lock); 758 EXPECT_EQ(current_rotation_lock, rotation_lock);
759 759
760 int orientation; 760 int orientation;
761 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 761 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation();
762 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 762 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
763 EXPECT_EQ(current_rotation, orientation); 763 EXPECT_EQ(current_rotation, orientation);
764 } 764 }
765 765
766 // Tests that the rotation state is saved when a guest is logged in. 766 // Tests that the rotation state is saved when a guest is logged in.
767 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { 767 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) {
768 gfx::Display::SetInternalDisplayId( 768 gfx::Display::SetInternalDisplayId(
769 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 769 gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
770 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 770 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
771 LoggedInAsGuest(); 771 LoggedInAsGuest();
772 772
773 bool current_rotation_lock = IsRotationLocked(); 773 bool current_rotation_lock = IsRotationLocked();
774 StoreDisplayRotationPrefs(current_rotation_lock); 774 StoreDisplayRotationPrefs(current_rotation_lock);
775 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 775 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
776 776
777 const base::DictionaryValue* properties = 777 const base::DictionaryValue* properties =
778 local_state()->GetDictionary(prefs::kDisplayRotationLock); 778 local_state()->GetDictionary(prefs::kDisplayRotationLock);
779 bool rotation_lock; 779 bool rotation_lock;
780 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 780 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
781 EXPECT_EQ(current_rotation_lock, rotation_lock); 781 EXPECT_EQ(current_rotation_lock, rotation_lock);
782 782
783 int orientation; 783 int orientation;
784 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 784 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation();
785 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 785 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
786 EXPECT_EQ(current_rotation, orientation); 786 EXPECT_EQ(current_rotation, orientation);
787 } 787 }
788 788
789 // Tests that the rotation state is saved when a normal user is logged in. 789 // Tests that the rotation state is saved when a normal user is logged in.
790 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { 790 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) {
791 gfx::Display::SetInternalDisplayId( 791 gfx::Display::SetInternalDisplayId(
792 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 792 gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
793 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 793 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
794 LoggedInAsGuest(); 794 LoggedInAsGuest();
795 795
796 bool current_rotation_lock = IsRotationLocked(); 796 bool current_rotation_lock = IsRotationLocked();
797 StoreDisplayRotationPrefs(current_rotation_lock); 797 StoreDisplayRotationPrefs(current_rotation_lock);
798 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 798 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
799 799
800 const base::DictionaryValue* properties = 800 const base::DictionaryValue* properties =
801 local_state()->GetDictionary(prefs::kDisplayRotationLock); 801 local_state()->GetDictionary(prefs::kDisplayRotationLock);
802 bool rotation_lock; 802 bool rotation_lock;
803 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 803 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
804 EXPECT_EQ(current_rotation_lock, rotation_lock); 804 EXPECT_EQ(current_rotation_lock, rotation_lock);
805 805
806 int orientation; 806 int orientation;
807 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); 807 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation();
808 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); 808 EXPECT_TRUE(properties->GetInteger("orientation", &orientation));
809 EXPECT_EQ(current_rotation, orientation); 809 EXPECT_EQ(current_rotation, orientation);
810 } 810 }
811 811
812 // Tests that rotation state is loaded without a user being logged in, and that 812 // Tests that rotation state is loaded without a user being logged in, and that
813 // entering maximize mode applies the state. 813 // entering maximize mode applies the state.
814 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { 814 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) {
815 gfx::Display::SetInternalDisplayId( 815 gfx::Display::SetInternalDisplayId(
816 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 816 gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
817 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 817 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
818 818
819 ash::Shell* shell = ash::Shell::GetInstance(); 819 ash::Shell* shell = ash::Shell::GetInstance();
820 bool initial_rotation_lock = IsRotationLocked(); 820 bool initial_rotation_lock = IsRotationLocked();
821 ASSERT_FALSE(initial_rotation_lock); 821 ASSERT_FALSE(initial_rotation_lock);
822 ash::DisplayManager* display_manager = shell->display_manager(); 822 ash::DisplayManager* display_manager = shell->display_manager();
823 gfx::Display::Rotation initial_rotation = GetCurrentInternalDisplayRotation(); 823 gfx::Display::Rotation initial_rotation = GetCurrentInternalDisplayRotation();
824 ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation); 824 ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation);
825 825
826 StoreDisplayRotationPrefs(initial_rotation_lock); 826 StoreDisplayRotationPrefs(initial_rotation_lock);
(...skipping 30 matching lines...) Expand all
857 bool screen_orientation_rotation_lock = IsRotationLocked(); 857 bool screen_orientation_rotation_lock = IsRotationLocked();
858 gfx::Display::Rotation maximize_mode_rotation = 858 gfx::Display::Rotation maximize_mode_rotation =
859 GetCurrentInternalDisplayRotation(); 859 GetCurrentInternalDisplayRotation();
860 EXPECT_TRUE(screen_orientation_rotation_lock); 860 EXPECT_TRUE(screen_orientation_rotation_lock);
861 EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation); 861 EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation);
862 } 862 }
863 863
864 // Tests that rotation lock being set causes the rotation state to be saved. 864 // Tests that rotation lock being set causes the rotation state to be saved.
865 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) { 865 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) {
866 gfx::Display::SetInternalDisplayId( 866 gfx::Display::SetInternalDisplayId(
867 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); 867 gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
868 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 868 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
869 869
870 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( 870 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
871 true); 871 true);
872 872
873 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 873 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
874 874
875 const base::DictionaryValue* properties = 875 const base::DictionaryValue* properties =
876 local_state()->GetDictionary(prefs::kDisplayRotationLock); 876 local_state()->GetDictionary(prefs::kDisplayRotationLock);
877 bool rotation_lock; 877 bool rotation_lock;
878 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 878 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
879 } 879 }
880 880
881 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { 881 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) {
882 882
883 LoggedInAsUser(); 883 LoggedInAsUser();
884 ash::DisplayManager* display_manager = 884 ash::DisplayManager* display_manager =
885 ash::Shell::GetInstance()->display_manager(); 885 ash::Shell::GetInstance()->display_manager();
886 display_manager->SetUnifiedDesktopEnabled(true); 886 display_manager->SetUnifiedDesktopEnabled(true);
887 887
888 UpdateDisplay("200x200,100x100"); 888 UpdateDisplay("200x200,100x100");
889 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); 889 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair();
890 EXPECT_EQ( 890 EXPECT_EQ("400x200",
891 "400x200", 891 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
892 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString());
893 892
894 const base::DictionaryValue* secondary_displays = 893 const base::DictionaryValue* secondary_displays =
895 local_state()->GetDictionary(prefs::kSecondaryDisplays); 894 local_state()->GetDictionary(prefs::kSecondaryDisplays);
896 const base::DictionaryValue* new_value = NULL; 895 const base::DictionaryValue* new_value = NULL;
897 EXPECT_TRUE( 896 EXPECT_TRUE(
898 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); 897 secondary_displays->GetDictionary(ToPairString(pair), &new_value));
899 898
900 ash::DisplayLayout stored_layout; 899 ash::DisplayLayout stored_layout;
901 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); 900 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout));
902 EXPECT_TRUE(stored_layout.default_unified); 901 EXPECT_TRUE(stored_layout.default_unified);
903 EXPECT_FALSE(stored_layout.mirrored); 902 EXPECT_FALSE(stored_layout.mirrored);
904 903
905 const base::DictionaryValue* displays = 904 const base::DictionaryValue* displays =
906 local_state()->GetDictionary(prefs::kDisplayProperties); 905 local_state()->GetDictionary(prefs::kDisplayProperties);
907 int64_t unified_id = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); 906 int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
908 EXPECT_FALSE( 907 EXPECT_FALSE(
909 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); 908 displays->GetDictionary(base::Int64ToString(unified_id), &new_value));
910 909
911 ash::test::SetDisplayResolution(unified_id, gfx::Size(200, 100)); 910 ash::test::SetDisplayResolution(unified_id, gfx::Size(200, 100));
912 EXPECT_EQ( 911 EXPECT_EQ("200x100",
913 "200x100", 912 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
914 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString());
915 EXPECT_FALSE( 913 EXPECT_FALSE(
916 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); 914 displays->GetDictionary(base::Int64ToString(unified_id), &new_value));
917 915
918 // Mirror mode should remember if the default mode was unified. 916 // Mirror mode should remember if the default mode was unified.
919 display_manager->SetMirrorMode(true); 917 display_manager->SetMirrorMode(true);
920 ASSERT_TRUE( 918 ASSERT_TRUE(
921 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); 919 secondary_displays->GetDictionary(ToPairString(pair), &new_value));
922 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); 920 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout));
923 EXPECT_TRUE(stored_layout.default_unified); 921 EXPECT_TRUE(stored_layout.default_unified);
924 EXPECT_TRUE(stored_layout.mirrored); 922 EXPECT_TRUE(stored_layout.mirrored);
(...skipping 10 matching lines...) Expand all
935 ash::DisplayManager::EXTENDED); 933 ash::DisplayManager::EXTENDED);
936 display_manager->ReconfigureDisplays(); 934 display_manager->ReconfigureDisplays();
937 ASSERT_TRUE( 935 ASSERT_TRUE(
938 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); 936 secondary_displays->GetDictionary(ToPairString(pair), &new_value));
939 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); 937 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout));
940 EXPECT_FALSE(stored_layout.default_unified); 938 EXPECT_FALSE(stored_layout.default_unified);
941 EXPECT_FALSE(stored_layout.mirrored); 939 EXPECT_FALSE(stored_layout.mirrored);
942 } 940 }
943 941
944 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { 942 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) {
945 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); 943 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
946 ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1); 944 ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1);
947 StoreDisplayBoolPropertyForPair(pair, "default_unified", true); 945 StoreDisplayBoolPropertyForPair(pair, "default_unified", true);
948 StoreDisplayPropertyForPair( 946 StoreDisplayPropertyForPair(
949 pair, "primary-id", 947 pair, "primary-id",
950 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1)))); 948 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1))));
951 LoadDisplayPreferences(false); 949 LoadDisplayPreferences(false);
952 950
953 // Should not restore to unified unless unified desktop is enabled. 951 // Should not restore to unified unless unified desktop is enabled.
954 UpdateDisplay("100x100,200x200"); 952 UpdateDisplay("100x100,200x200");
955 ash::DisplayManager* display_manager = 953 ash::DisplayManager* display_manager =
(...skipping 20 matching lines...) Expand all
976 // Sanity check. Restore to extended. 974 // Sanity check. Restore to extended.
977 StoreDisplayBoolPropertyForPair(pair, "default_unified", false); 975 StoreDisplayBoolPropertyForPair(pair, "default_unified", false);
978 StoreDisplayBoolPropertyForPair(pair, "mirrored", false); 976 StoreDisplayBoolPropertyForPair(pair, "mirrored", false);
979 LoadDisplayPreferences(false); 977 LoadDisplayPreferences(false);
980 UpdateDisplay("100x100,200x200"); 978 UpdateDisplay("100x100,200x200");
981 EXPECT_FALSE(display_manager->IsInMirrorMode()); 979 EXPECT_FALSE(display_manager->IsInMirrorMode());
982 EXPECT_FALSE(display_manager->IsInUnifiedMode()); 980 EXPECT_FALSE(display_manager->IsInUnifiedMode());
983 } 981 }
984 982
985 } // namespace chromeos 983 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698