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

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

Issue 1261693004: Allow dynamic enabling/disabling of unified desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 869
870 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); 870 EXPECT_TRUE(local_state()->HasPrefPath(prefs::kDisplayRotationLock));
871 871
872 const base::DictionaryValue* properties = 872 const base::DictionaryValue* properties =
873 local_state()->GetDictionary(prefs::kDisplayRotationLock); 873 local_state()->GetDictionary(prefs::kDisplayRotationLock);
874 bool rotation_lock; 874 bool rotation_lock;
875 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock)); 875 EXPECT_TRUE(properties->GetBoolean("lock", &rotation_lock));
876 } 876 }
877 877
878 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { 878 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) {
879 ash::test::DisplayManagerTestApi::EnableUnifiedDesktopForTest();
880 879
881 LoggedInAsUser(); 880 LoggedInAsUser();
882 ash::DisplayManager* display_manager = 881 ash::DisplayManager* display_manager =
883 ash::Shell::GetInstance()->display_manager(); 882 ash::Shell::GetInstance()->display_manager();
883 display_manager->SetUnifiedDesktopEnabled(true);
884 884
885 UpdateDisplay("200x200,100x100"); 885 UpdateDisplay("200x200,100x100");
886 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); 886 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair();
887 EXPECT_EQ( 887 EXPECT_EQ(
888 "400x200", 888 "400x200",
889 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString()); 889 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString());
890 890
891 const base::DictionaryValue* secondary_displays = 891 const base::DictionaryValue* secondary_displays =
892 local_state()->GetDictionary(prefs::kSecondaryDisplays); 892 local_state()->GetDictionary(prefs::kSecondaryDisplays);
893 const base::DictionaryValue* new_value = NULL; 893 const base::DictionaryValue* new_value = NULL;
(...skipping 27 matching lines...) Expand all
921 EXPECT_TRUE(stored_layout.mirrored); 921 EXPECT_TRUE(stored_layout.mirrored);
922 922
923 display_manager->SetMirrorMode(false); 923 display_manager->SetMirrorMode(false);
924 ASSERT_TRUE( 924 ASSERT_TRUE(
925 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); 925 secondary_displays->GetDictionary(ToPairString(pair), &new_value));
926 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); 926 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout));
927 EXPECT_TRUE(stored_layout.default_unified); 927 EXPECT_TRUE(stored_layout.default_unified);
928 EXPECT_FALSE(stored_layout.mirrored); 928 EXPECT_FALSE(stored_layout.mirrored);
929 929
930 // Exit unified mode. 930 // Exit unified mode.
931 display_manager->SetDefaultMultiDisplayMode(ash::DisplayManager::EXTENDED); 931 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays(
932 ash::DisplayManager::EXTENDED);
932 display_manager->ReconfigureDisplays(); 933 display_manager->ReconfigureDisplays();
933 ASSERT_TRUE( 934 ASSERT_TRUE(
934 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); 935 secondary_displays->GetDictionary(ToPairString(pair), &new_value));
935 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); 936 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout));
936 EXPECT_FALSE(stored_layout.default_unified); 937 EXPECT_FALSE(stored_layout.default_unified);
937 EXPECT_FALSE(stored_layout.mirrored); 938 EXPECT_FALSE(stored_layout.mirrored);
938 } 939 }
939 940
940 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { 941 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) {
941 int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); 942 int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id();
942 ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1); 943 ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1);
943 StoreDisplayBoolPropertyForPair(pair, "default_unified", true); 944 StoreDisplayBoolPropertyForPair(pair, "default_unified", true);
944 StoreDisplayPropertyForPair( 945 StoreDisplayPropertyForPair(
945 pair, "primary-id", 946 pair, "primary-id",
946 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1)))); 947 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1))));
947 LoadDisplayPreferences(false); 948 LoadDisplayPreferences(false);
948 949
949 // Should not restore to unified unless unified desktop is enabled. 950 // Should not restore to unified unless unified desktop is enabled.
950 UpdateDisplay("100x100,200x200"); 951 UpdateDisplay("100x100,200x200");
951 ash::DisplayManager* display_manager = 952 ash::DisplayManager* display_manager =
952 ash::Shell::GetInstance()->display_manager(); 953 ash::Shell::GetInstance()->display_manager();
953 EXPECT_FALSE(display_manager->IsInUnifiedMode()); 954 EXPECT_FALSE(display_manager->IsInUnifiedMode());
954 955
955 // Restored to unified. 956 // Restored to unified.
956 ash::test::DisplayManagerTestApi::EnableUnifiedDesktopForTest(); 957 display_manager->SetUnifiedDesktopEnabled(true);
957 StoreDisplayBoolPropertyForPair(pair, "default_unified", true); 958 StoreDisplayBoolPropertyForPair(pair, "default_unified", true);
958 LoadDisplayPreferences(false); 959 LoadDisplayPreferences(false);
959 UpdateDisplay("100x100,200x200"); 960 UpdateDisplay("100x100,200x200");
960 EXPECT_TRUE(display_manager->IsInUnifiedMode()); 961 EXPECT_TRUE(display_manager->IsInUnifiedMode());
961 962
962 // Restored to mirror, then unified. 963 // Restored to mirror, then unified.
963 StoreDisplayBoolPropertyForPair(pair, "mirrored", true); 964 StoreDisplayBoolPropertyForPair(pair, "mirrored", true);
964 StoreDisplayBoolPropertyForPair(pair, "default_unified", true); 965 StoreDisplayBoolPropertyForPair(pair, "default_unified", true);
965 LoadDisplayPreferences(false); 966 LoadDisplayPreferences(false);
966 UpdateDisplay("100x100,200x200"); 967 UpdateDisplay("100x100,200x200");
967 EXPECT_TRUE(display_manager->IsInMirrorMode()); 968 EXPECT_TRUE(display_manager->IsInMirrorMode());
968 969
969 display_manager->SetMirrorMode(false); 970 display_manager->SetMirrorMode(false);
970 EXPECT_TRUE(display_manager->IsInUnifiedMode()); 971 EXPECT_TRUE(display_manager->IsInUnifiedMode());
971 972
972 // Sanity check. Restore to extended. 973 // Sanity check. Restore to extended.
973 StoreDisplayBoolPropertyForPair(pair, "default_unified", false); 974 StoreDisplayBoolPropertyForPair(pair, "default_unified", false);
974 StoreDisplayBoolPropertyForPair(pair, "mirrored", false); 975 StoreDisplayBoolPropertyForPair(pair, "mirrored", false);
975 LoadDisplayPreferences(false); 976 LoadDisplayPreferences(false);
976 UpdateDisplay("100x100,200x200"); 977 UpdateDisplay("100x100,200x200");
977 EXPECT_FALSE(display_manager->IsInMirrorMode()); 978 EXPECT_FALSE(display_manager->IsInMirrorMode());
978 EXPECT_FALSE(display_manager->IsInUnifiedMode()); 979 EXPECT_FALSE(display_manager->IsInUnifiedMode());
979 } 980 }
980 981
981 } // namespace chromeos 982 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/test/display_manager_test_api.cc ('k') | chrome/browser/ui/webui/options/chromeos/display_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698