| 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 <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 Loading... |
| 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 Loading... |
| 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->SwapPrimaryDisplayForTest(); | 528 window_tree_host_manager->SwapPrimaryDisplayForTest(); |
| 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 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 533 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 551 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 551 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 552 EXPECT_EQ(layout.position, stored_layout.position); | 552 EXPECT_EQ(layout.position, stored_layout.position); |
| 553 EXPECT_EQ(layout.offset, stored_layout.offset); | 553 EXPECT_EQ(layout.offset, stored_layout.offset); |
| 554 EXPECT_EQ(id1, stored_layout.primary_id); | 554 EXPECT_EQ(id1, stored_layout.primary_id); |
| 555 } | 555 } |
| 556 | 556 |
| 557 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { | 557 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { |
| 558 ash::DisplayManager* display_manager = | 558 ash::DisplayManager* display_manager = |
| 559 ash::Shell::GetInstance()->display_manager(); | 559 ash::Shell::GetInstance()->display_manager(); |
| 560 | 560 |
| 561 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); | 561 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 562 | 562 |
| 563 StoreColorProfile(id1, "dynamic"); | 563 StoreColorProfile(id1, "dynamic"); |
| 564 | 564 |
| 565 LoggedInAsUser(); | 565 LoggedInAsUser(); |
| 566 LoadDisplayPreferences(false); | 566 LoadDisplayPreferences(false); |
| 567 | 567 |
| 568 // id1's available color profiles list is empty, means somehow the color | 568 // id1's available color profiles list is empty, means somehow the color |
| 569 // profile suport is temporary in trouble. | 569 // profile suport is temporary in trouble. |
| 570 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, | 570 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, |
| 571 display_manager->GetDisplayInfo(id1).color_profile()); | 571 display_manager->GetDisplayInfo(id1).color_profile()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, | 605 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, |
| 606 gfx::Display::ROTATION_SOURCE_USER); | 606 gfx::Display::ROTATION_SOURCE_USER); |
| 607 | 607 |
| 608 // Does not store the preferences locally. | 608 // Does not store the preferences locally. |
| 609 EXPECT_FALSE(local_state()->FindPreference( | 609 EXPECT_FALSE(local_state()->FindPreference( |
| 610 prefs::kSecondaryDisplays)->HasUserSetting()); | 610 prefs::kSecondaryDisplays)->HasUserSetting()); |
| 611 EXPECT_FALSE(local_state()->FindPreference( | 611 EXPECT_FALSE(local_state()->FindPreference( |
| 612 prefs::kDisplayProperties)->HasUserSetting()); | 612 prefs::kDisplayProperties)->HasUserSetting()); |
| 613 | 613 |
| 614 // Settings are still notified to the system. | 614 // Settings are still notified to the system. |
| 615 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 615 gfx::Screen* screen = gfx::Screen::GetScreen(); |
| 616 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); | 616 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); |
| 617 EXPECT_EQ(ash::DisplayLayout::BOTTOM, | 617 EXPECT_EQ(ash::DisplayLayout::BOTTOM, |
| 618 display_manager->GetCurrentDisplayLayout().position); | 618 display_manager->GetCurrentDisplayLayout().position); |
| 619 EXPECT_EQ(-10, display_manager->GetCurrentDisplayLayout().offset); | 619 EXPECT_EQ(-10, display_manager->GetCurrentDisplayLayout().offset); |
| 620 const gfx::Display& primary_display = screen->GetPrimaryDisplay(); | 620 const gfx::Display& primary_display = screen->GetPrimaryDisplay(); |
| 621 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); | 621 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); |
| 622 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); | 622 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); |
| 623 | 623 |
| 624 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); | 624 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); |
| 625 EXPECT_EQ(1.25f, info1.configured_ui_scale()); | 625 EXPECT_EQ(1.25f, info1.configured_ui_scale()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 LoadDisplayPreferences(false); | 684 LoadDisplayPreferences(false); |
| 685 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, | 685 EXPECT_EQ(chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, |
| 686 shell->display_configurator()->requested_power_state()); | 686 shell->display_configurator()->requested_power_state()); |
| 687 } | 687 } |
| 688 | 688 |
| 689 // Tests that display configuration changes caused by MaximizeModeController | 689 // Tests that display configuration changes caused by MaximizeModeController |
| 690 // are not saved. | 690 // are not saved. |
| 691 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { | 691 TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { |
| 692 ash::Shell* shell = ash::Shell::GetInstance(); | 692 ash::Shell* shell = ash::Shell::GetInstance(); |
| 693 gfx::Display::SetInternalDisplayId( | 693 gfx::Display::SetInternalDisplayId( |
| 694 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); | 694 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 695 ash::DisplayManager* display_manager = shell->display_manager(); | 695 ash::DisplayManager* display_manager = shell->display_manager(); |
| 696 LoggedInAsUser(); | 696 LoggedInAsUser(); |
| 697 // Populate the properties. | 697 // Populate the properties. |
| 698 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), | 698 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 699 gfx::Display::ROTATE_180, | 699 gfx::Display::ROTATE_180, |
| 700 gfx::Display::ROTATION_SOURCE_USER); | 700 gfx::Display::ROTATION_SOURCE_USER); |
| 701 // Reset property to avoid rotation lock | 701 // Reset property to avoid rotation lock |
| 702 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), | 702 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 703 gfx::Display::ROTATE_0, | 703 gfx::Display::ROTATE_0, |
| 704 gfx::Display::ROTATION_SOURCE_USER); | 704 gfx::Display::ROTATION_SOURCE_USER); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 EXPECT_TRUE(properties->GetDictionary( | 738 EXPECT_TRUE(properties->GetDictionary( |
| 739 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); | 739 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); |
| 740 rotation = -1; | 740 rotation = -1; |
| 741 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); | 741 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); |
| 742 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); | 742 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); |
| 743 } | 743 } |
| 744 | 744 |
| 745 // Tests that the rotation state is saved without a user being logged in. | 745 // Tests that the rotation state is saved without a user being logged in. |
| 746 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { | 746 TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { |
| 747 gfx::Display::SetInternalDisplayId( | 747 gfx::Display::SetInternalDisplayId( |
| 748 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); | 748 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 749 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 749 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 750 | 750 |
| 751 bool current_rotation_lock = IsRotationLocked(); | 751 bool current_rotation_lock = IsRotationLocked(); |
| 752 StoreDisplayRotationPrefs(current_rotation_lock); | 752 StoreDisplayRotationPrefs(current_rotation_lock); |
| 753 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 753 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 754 | 754 |
| 755 const base::DictionaryValue* properties = | 755 const base::DictionaryValue* properties = |
| 756 local_state()->GetDictionary(prefs::kDisplayRotationLock); | 756 local_state()->GetDictionary(prefs::kDisplayRotationLock); |
| 757 bool rotation_lock; | 757 bool rotation_lock; |
| 758 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); | 758 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); |
| 759 EXPECT_EQ(current_rotation_lock, rotation_lock); | 759 EXPECT_EQ(current_rotation_lock, rotation_lock); |
| 760 | 760 |
| 761 int orientation; | 761 int orientation; |
| 762 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); | 762 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); |
| 763 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); | 763 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); |
| 764 EXPECT_EQ(current_rotation, orientation); | 764 EXPECT_EQ(current_rotation, orientation); |
| 765 } | 765 } |
| 766 | 766 |
| 767 // Tests that the rotation state is saved when a guest is logged in. | 767 // Tests that the rotation state is saved when a guest is logged in. |
| 768 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { | 768 TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { |
| 769 gfx::Display::SetInternalDisplayId( | 769 gfx::Display::SetInternalDisplayId( |
| 770 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); | 770 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 771 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 771 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 772 LoggedInAsGuest(); | 772 LoggedInAsGuest(); |
| 773 | 773 |
| 774 bool current_rotation_lock = IsRotationLocked(); | 774 bool current_rotation_lock = IsRotationLocked(); |
| 775 StoreDisplayRotationPrefs(current_rotation_lock); | 775 StoreDisplayRotationPrefs(current_rotation_lock); |
| 776 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 776 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 777 | 777 |
| 778 const base::DictionaryValue* properties = | 778 const base::DictionaryValue* properties = |
| 779 local_state()->GetDictionary(prefs::kDisplayRotationLock); | 779 local_state()->GetDictionary(prefs::kDisplayRotationLock); |
| 780 bool rotation_lock; | 780 bool rotation_lock; |
| 781 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); | 781 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); |
| 782 EXPECT_EQ(current_rotation_lock, rotation_lock); | 782 EXPECT_EQ(current_rotation_lock, rotation_lock); |
| 783 | 783 |
| 784 int orientation; | 784 int orientation; |
| 785 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); | 785 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); |
| 786 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); | 786 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); |
| 787 EXPECT_EQ(current_rotation, orientation); | 787 EXPECT_EQ(current_rotation, orientation); |
| 788 } | 788 } |
| 789 | 789 |
| 790 // Tests that the rotation state is saved when a normal user is logged in. | 790 // Tests that the rotation state is saved when a normal user is logged in. |
| 791 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { | 791 TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { |
| 792 gfx::Display::SetInternalDisplayId( | 792 gfx::Display::SetInternalDisplayId( |
| 793 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); | 793 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 794 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 794 EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 795 LoggedInAsGuest(); | 795 LoggedInAsGuest(); |
| 796 | 796 |
| 797 bool current_rotation_lock = IsRotationLocked(); | 797 bool current_rotation_lock = IsRotationLocked(); |
| 798 StoreDisplayRotationPrefs(current_rotation_lock); | 798 StoreDisplayRotationPrefs(current_rotation_lock); |
| 799 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 799 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 800 | 800 |
| 801 const base::DictionaryValue* properties = | 801 const base::DictionaryValue* properties = |
| 802 local_state()->GetDictionary(prefs::kDisplayRotationLock); | 802 local_state()->GetDictionary(prefs::kDisplayRotationLock); |
| 803 bool rotation_lock; | 803 bool rotation_lock; |
| 804 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); | 804 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); |
| 805 EXPECT_EQ(current_rotation_lock, rotation_lock); | 805 EXPECT_EQ(current_rotation_lock, rotation_lock); |
| 806 | 806 |
| 807 int orientation; | 807 int orientation; |
| 808 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); | 808 gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); |
| 809 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); | 809 EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); |
| 810 EXPECT_EQ(current_rotation, orientation); | 810 EXPECT_EQ(current_rotation, orientation); |
| 811 } | 811 } |
| 812 | 812 |
| 813 // Tests that rotation state is loaded without a user being logged in, and that | 813 // Tests that rotation state is loaded without a user being logged in, and that |
| 814 // entering maximize mode applies the state. | 814 // entering maximize mode applies the state. |
| 815 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { | 815 TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { |
| 816 gfx::Display::SetInternalDisplayId( | 816 gfx::Display::SetInternalDisplayId( |
| 817 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); | 817 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 818 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 818 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 819 | 819 |
| 820 ash::Shell* shell = ash::Shell::GetInstance(); | 820 ash::Shell* shell = ash::Shell::GetInstance(); |
| 821 bool initial_rotation_lock = IsRotationLocked(); | 821 bool initial_rotation_lock = IsRotationLocked(); |
| 822 ASSERT_FALSE(initial_rotation_lock); | 822 ASSERT_FALSE(initial_rotation_lock); |
| 823 ash::DisplayManager* display_manager = shell->display_manager(); | 823 ash::DisplayManager* display_manager = shell->display_manager(); |
| 824 gfx::Display::Rotation initial_rotation = GetCurrentInternalDisplayRotation(); | 824 gfx::Display::Rotation initial_rotation = GetCurrentInternalDisplayRotation(); |
| 825 ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation); | 825 ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation); |
| 826 | 826 |
| 827 StoreDisplayRotationPrefs(initial_rotation_lock); | 827 StoreDisplayRotationPrefs(initial_rotation_lock); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 858 bool screen_orientation_rotation_lock = IsRotationLocked(); | 858 bool screen_orientation_rotation_lock = IsRotationLocked(); |
| 859 gfx::Display::Rotation maximize_mode_rotation = | 859 gfx::Display::Rotation maximize_mode_rotation = |
| 860 GetCurrentInternalDisplayRotation(); | 860 GetCurrentInternalDisplayRotation(); |
| 861 EXPECT_TRUE(screen_orientation_rotation_lock); | 861 EXPECT_TRUE(screen_orientation_rotation_lock); |
| 862 EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation); | 862 EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation); |
| 863 } | 863 } |
| 864 | 864 |
| 865 // Tests that rotation lock being set causes the rotation state to be saved. | 865 // Tests that rotation lock being set causes the rotation state to be saved. |
| 866 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) { | 866 TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) { |
| 867 gfx::Display::SetInternalDisplayId( | 867 gfx::Display::SetInternalDisplayId( |
| 868 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); | 868 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 869 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 869 ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 870 | 870 |
| 871 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( | 871 ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( |
| 872 true); | 872 true); |
| 873 | 873 |
| 874 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); | 874 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); |
| 875 | 875 |
| 876 const base::DictionaryValue* properties = | 876 const base::DictionaryValue* properties = |
| 877 local_state()->GetDictionary(prefs::kDisplayRotationLock); | 877 local_state()->GetDictionary(prefs::kDisplayRotationLock); |
| 878 bool rotation_lock; | 878 bool rotation_lock; |
| 879 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); | 879 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); |
| 880 } | 880 } |
| 881 | 881 |
| 882 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { | 882 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { |
| 883 | 883 |
| 884 LoggedInAsUser(); | 884 LoggedInAsUser(); |
| 885 ash::DisplayManager* display_manager = | 885 ash::DisplayManager* display_manager = |
| 886 ash::Shell::GetInstance()->display_manager(); | 886 ash::Shell::GetInstance()->display_manager(); |
| 887 display_manager->SetUnifiedDesktopEnabled(true); | 887 display_manager->SetUnifiedDesktopEnabled(true); |
| 888 | 888 |
| 889 UpdateDisplay("200x200,100x100"); | 889 UpdateDisplay("200x200,100x100"); |
| 890 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); | 890 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); |
| 891 EXPECT_EQ( | 891 EXPECT_EQ("400x200", |
| 892 "400x200", | 892 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
| 893 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString()); | |
| 894 | 893 |
| 895 const base::DictionaryValue* secondary_displays = | 894 const base::DictionaryValue* secondary_displays = |
| 896 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 895 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
| 897 const base::DictionaryValue* new_value = NULL; | 896 const base::DictionaryValue* new_value = NULL; |
| 898 EXPECT_TRUE( | 897 EXPECT_TRUE( |
| 899 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 898 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); |
| 900 | 899 |
| 901 ash::DisplayLayout stored_layout; | 900 ash::DisplayLayout stored_layout; |
| 902 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 901 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 903 EXPECT_TRUE(stored_layout.default_unified); | 902 EXPECT_TRUE(stored_layout.default_unified); |
| 904 EXPECT_FALSE(stored_layout.mirrored); | 903 EXPECT_FALSE(stored_layout.mirrored); |
| 905 | 904 |
| 906 const base::DictionaryValue* displays = | 905 const base::DictionaryValue* displays = |
| 907 local_state()->GetDictionary(prefs::kDisplayProperties); | 906 local_state()->GetDictionary(prefs::kDisplayProperties); |
| 908 int64_t unified_id = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); | 907 int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 909 EXPECT_FALSE( | 908 EXPECT_FALSE( |
| 910 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 909 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
| 911 | 910 |
| 912 ash::test::SetDisplayResolution(unified_id, gfx::Size(200, 100)); | 911 ash::test::SetDisplayResolution(unified_id, gfx::Size(200, 100)); |
| 913 EXPECT_EQ( | 912 EXPECT_EQ("200x100", |
| 914 "200x100", | 913 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
| 915 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString()); | |
| 916 EXPECT_FALSE( | 914 EXPECT_FALSE( |
| 917 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 915 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
| 918 | 916 |
| 919 // Mirror mode should remember if the default mode was unified. | 917 // Mirror mode should remember if the default mode was unified. |
| 920 display_manager->SetMirrorMode(true); | 918 display_manager->SetMirrorMode(true); |
| 921 ASSERT_TRUE( | 919 ASSERT_TRUE( |
| 922 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 920 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); |
| 923 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 921 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 924 EXPECT_TRUE(stored_layout.default_unified); | 922 EXPECT_TRUE(stored_layout.default_unified); |
| 925 EXPECT_TRUE(stored_layout.mirrored); | 923 EXPECT_TRUE(stored_layout.mirrored); |
| 926 | 924 |
| 927 display_manager->SetMirrorMode(false); | 925 display_manager->SetMirrorMode(false); |
| 928 ASSERT_TRUE( | 926 ASSERT_TRUE( |
| 929 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 927 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); |
| 930 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 928 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 931 EXPECT_TRUE(stored_layout.default_unified); | 929 EXPECT_TRUE(stored_layout.default_unified); |
| 932 EXPECT_FALSE(stored_layout.mirrored); | 930 EXPECT_FALSE(stored_layout.mirrored); |
| 933 | 931 |
| 934 // Exit unified mode. | 932 // Exit unified mode. |
| 935 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( | 933 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( |
| 936 ash::DisplayManager::EXTENDED); | 934 ash::DisplayManager::EXTENDED); |
| 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 Loading... |
| 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 |
| OLD | NEW |