| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 // The mean acceleration due to gravity on Earth in m/s^2. | 48 // The mean acceleration due to gravity on Earth in m/s^2. |
| 49 const float kMeanGravity = -9.80665f; | 49 const float kMeanGravity = -9.80665f; |
| 50 | 50 |
| 51 bool IsRotationLocked() { | 51 bool IsRotationLocked() { |
| 52 return ash::Shell::GetInstance() | 52 return ash::Shell::GetInstance() |
| 53 ->screen_orientation_controller() | 53 ->screen_orientation_controller() |
| 54 ->rotation_locked(); | 54 ->rotation_locked(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 std::string ToPairString(const ash::DisplayIdPair& pair) { | |
| 58 return base::Int64ToString(pair.first) + "," + | |
| 59 base::Int64ToString(pair.second); | |
| 60 } | |
| 61 | |
| 62 class DisplayPreferencesTest : public ash::test::AshTestBase { | 57 class DisplayPreferencesTest : public ash::test::AshTestBase { |
| 63 protected: | 58 protected: |
| 64 DisplayPreferencesTest() | 59 DisplayPreferencesTest() |
| 65 : mock_user_manager_(new MockUserManager), | 60 : mock_user_manager_(new MockUserManager), |
| 66 user_manager_enabler_(mock_user_manager_) { | 61 user_manager_enabler_(mock_user_manager_) { |
| 67 } | 62 } |
| 68 | 63 |
| 69 ~DisplayPreferencesTest() override {} | 64 ~DisplayPreferencesTest() override {} |
| 70 | 65 |
| 71 void SetUp() override { | 66 void SetUp() override { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 95 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) | 90 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) |
| 96 .WillRepeatedly(testing::Return(true)); | 91 .WillRepeatedly(testing::Return(true)); |
| 97 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) | 92 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) |
| 98 .WillRepeatedly(testing::Return(false)); | 93 .WillRepeatedly(testing::Return(false)); |
| 99 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsSupervisedUser()) | 94 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsSupervisedUser()) |
| 100 .WillRepeatedly(testing::Return(false)); | 95 .WillRepeatedly(testing::Return(false)); |
| 101 } | 96 } |
| 102 | 97 |
| 103 // Do not use the implementation of display_preferences.cc directly to avoid | 98 // Do not use the implementation of display_preferences.cc directly to avoid |
| 104 // notifying the update to the system. | 99 // notifying the update to the system. |
| 105 void StoreDisplayLayoutPrefForPair(const ash::DisplayIdPair& pair, | 100 void StoreDisplayLayoutPrefForList(const ash::DisplayIdList& list, |
| 106 ash::DisplayLayout::Position layout, | 101 ash::DisplayLayout::Position layout, |
| 107 int offset, | 102 int offset, |
| 108 int64_t primary_id) { | 103 int64_t primary_id) { |
| 109 std::string name = ToPairString(pair); | 104 std::string name = ash::DisplayIdListToString(list); |
| 110 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); | 105 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); |
| 111 ash::DisplayLayout display_layout(layout, offset); | 106 ash::DisplayLayout display_layout(layout, offset); |
| 112 display_layout.primary_id = primary_id; | 107 display_layout.primary_id = primary_id; |
| 113 | 108 |
| 114 DCHECK(!name.empty()); | 109 DCHECK(!name.empty()); |
| 115 | 110 |
| 116 base::DictionaryValue* pref_data = update.Get(); | 111 base::DictionaryValue* pref_data = update.Get(); |
| 117 scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); | 112 scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); |
| 118 if (pref_data->HasKey(name)) { | 113 if (pref_data->HasKey(name)) { |
| 119 base::Value* value = NULL; | 114 base::Value* value = NULL; |
| 120 if (pref_data->Get(name, &value) && value != NULL) | 115 if (pref_data->Get(name, &value) && value != NULL) |
| 121 layout_value.reset(value->DeepCopy()); | 116 layout_value.reset(value->DeepCopy()); |
| 122 } | 117 } |
| 123 if (ash::DisplayLayout::ConvertToValue(display_layout, layout_value.get())) | 118 if (ash::DisplayLayout::ConvertToValue(display_layout, layout_value.get())) |
| 124 pref_data->Set(name, layout_value.release()); | 119 pref_data->Set(name, layout_value.release()); |
| 125 } | 120 } |
| 126 | 121 |
| 127 void StoreDisplayPropertyForPair(const ash::DisplayIdPair& pair, | 122 void StoreDisplayPropertyForList(const ash::DisplayIdList& list, |
| 128 std::string key, | 123 std::string key, |
| 129 scoped_ptr<base::Value> value) { | 124 scoped_ptr<base::Value> value) { |
| 130 std::string name = ToPairString(pair); | 125 std::string name = ash::DisplayIdListToString(list); |
| 131 | 126 |
| 132 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); | 127 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); |
| 133 base::DictionaryValue* pref_data = update.Get(); | 128 base::DictionaryValue* pref_data = update.Get(); |
| 134 | 129 |
| 135 if (pref_data->HasKey(name)) { | 130 if (pref_data->HasKey(name)) { |
| 136 base::Value* layout_value = NULL; | 131 base::Value* layout_value = NULL; |
| 137 pref_data->Get(name, &layout_value); | 132 pref_data->Get(name, &layout_value); |
| 138 if (layout_value) | 133 if (layout_value) |
| 139 static_cast<base::DictionaryValue*>(layout_value) | 134 static_cast<base::DictionaryValue*>(layout_value) |
| 140 ->Set(key, std::move(value)); | 135 ->Set(key, std::move(value)); |
| 141 } else { | 136 } else { |
| 142 scoped_ptr<base::DictionaryValue> layout_value( | 137 scoped_ptr<base::DictionaryValue> layout_value( |
| 143 new base::DictionaryValue()); | 138 new base::DictionaryValue()); |
| 144 layout_value->SetBoolean(key, value); | 139 layout_value->SetBoolean(key, value); |
| 145 pref_data->Set(name, layout_value.release()); | 140 pref_data->Set(name, layout_value.release()); |
| 146 } | 141 } |
| 147 } | 142 } |
| 148 | 143 |
| 149 void StoreDisplayBoolPropertyForPair(const ash::DisplayIdPair& pair, | 144 void StoreDisplayBoolPropertyForList(const ash::DisplayIdList& list, |
| 150 const std::string& key, | 145 const std::string& key, |
| 151 bool value) { | 146 bool value) { |
| 152 StoreDisplayPropertyForPair( | 147 StoreDisplayPropertyForList( |
| 153 pair, key, make_scoped_ptr(new base::FundamentalValue(value))); | 148 list, key, make_scoped_ptr(new base::FundamentalValue(value))); |
| 154 } | 149 } |
| 155 | 150 |
| 156 void StoreDisplayLayoutPrefForPair(const ash::DisplayIdPair& pair, | 151 void StoreDisplayLayoutPrefForList(const ash::DisplayIdList& list, |
| 157 ash::DisplayLayout::Position layout, | 152 ash::DisplayLayout::Position layout, |
| 158 int offset) { | 153 int offset) { |
| 159 StoreDisplayLayoutPrefForPair(pair, layout, offset, pair.first); | 154 StoreDisplayLayoutPrefForList(list, layout, offset, list[0]); |
| 160 } | 155 } |
| 161 | 156 |
| 162 void StoreDisplayOverscan(int64_t id, const gfx::Insets& insets) { | 157 void StoreDisplayOverscan(int64_t id, const gfx::Insets& insets) { |
| 163 DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); | 158 DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); |
| 164 const std::string name = base::Int64ToString(id); | 159 const std::string name = base::Int64ToString(id); |
| 165 | 160 |
| 166 base::DictionaryValue* pref_data = update.Get(); | 161 base::DictionaryValue* pref_data = update.Get(); |
| 167 base::DictionaryValue* insets_value = new base::DictionaryValue(); | 162 base::DictionaryValue* insets_value = new base::DictionaryValue(); |
| 168 insets_value->SetInteger("insets_top", insets.top()); | 163 insets_value->SetInteger("insets_top", insets.top()); |
| 169 insets_value->SetInteger("insets_left", insets.left()); | 164 insets_value->SetInteger("insets_left", insets.left()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 183 } | 178 } |
| 184 | 179 |
| 185 void StoreDisplayRotationPrefsForTest(bool rotation_lock, | 180 void StoreDisplayRotationPrefsForTest(bool rotation_lock, |
| 186 gfx::Display::Rotation rotation) { | 181 gfx::Display::Rotation rotation) { |
| 187 DictionaryPrefUpdate update(local_state(), prefs::kDisplayRotationLock); | 182 DictionaryPrefUpdate update(local_state(), prefs::kDisplayRotationLock); |
| 188 base::DictionaryValue* pref_data = update.Get(); | 183 base::DictionaryValue* pref_data = update.Get(); |
| 189 pref_data->SetBoolean("lock", rotation_lock); | 184 pref_data->SetBoolean("lock", rotation_lock); |
| 190 pref_data->SetInteger("orientation", static_cast<int>(rotation)); | 185 pref_data->SetInteger("orientation", static_cast<int>(rotation)); |
| 191 } | 186 } |
| 192 | 187 |
| 193 std::string GetRegisteredDisplayLayoutStr(const ash::DisplayIdPair& pair) { | 188 std::string GetRegisteredDisplayLayoutStr(const ash::DisplayIdList& list) { |
| 194 return ash::Shell::GetInstance()->display_manager()->layout_store()-> | 189 return ash::Shell::GetInstance() |
| 195 GetRegisteredDisplayLayout(pair).ToString(); | 190 ->display_manager() |
| 191 ->layout_store() |
| 192 ->GetRegisteredDisplayLayout(list) |
| 193 .ToString(); |
| 196 } | 194 } |
| 197 | 195 |
| 198 PrefService* local_state() { return &local_state_; } | 196 PrefService* local_state() { return &local_state_; } |
| 199 | 197 |
| 200 private: | 198 private: |
| 201 MockUserManager* mock_user_manager_; // Not owned. | 199 MockUserManager* mock_user_manager_; // Not owned. |
| 202 ScopedUserManagerEnabler user_manager_enabler_; | 200 ScopedUserManagerEnabler user_manager_enabler_; |
| 203 TestingPrefServiceSimple local_state_; | 201 TestingPrefServiceSimple local_state_; |
| 204 scoped_ptr<DisplayConfigurationObserver> observer_; | 202 scoped_ptr<DisplayConfigurationObserver> observer_; |
| 205 | 203 |
| 206 DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); | 204 DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); |
| 207 }; | 205 }; |
| 208 | 206 |
| 209 } // namespace | 207 } // namespace |
| 210 | 208 |
| 211 TEST_F(DisplayPreferencesTest, PairedLayoutOverrides) { | 209 TEST_F(DisplayPreferencesTest, ListedLayoutOverrides) { |
| 212 UpdateDisplay("100x100,200x200"); | 210 UpdateDisplay("100x100,200x200"); |
| 213 ash::DisplayManager* display_manager = | 211 ash::DisplayManager* display_manager = |
| 214 ash::Shell::GetInstance()->display_manager(); | 212 ash::Shell::GetInstance()->display_manager(); |
| 215 | 213 |
| 216 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); | 214 ash::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 217 ash::DisplayIdPair dummy_pair = std::make_pair(pair.first, pair.second + 1); | 215 ash::DisplayIdList dummy_list = |
| 218 ASSERT_NE(pair.first, dummy_pair.second); | 216 ash::CreateDisplayIdList(list[0], list[1] + 1); |
| 217 ASSERT_NE(list[0], dummy_list[1]); |
| 219 | 218 |
| 220 StoreDisplayLayoutPrefForPair(pair, ash::DisplayLayout::TOP, 20); | 219 StoreDisplayLayoutPrefForList(list, ash::DisplayLayout::TOP, 20); |
| 221 StoreDisplayLayoutPrefForPair(dummy_pair, ash::DisplayLayout::LEFT, 30); | 220 StoreDisplayLayoutPrefForList(dummy_list, ash::DisplayLayout::LEFT, 30); |
| 222 StoreDisplayPowerStateForTest( | 221 StoreDisplayPowerStateForTest( |
| 223 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); | 222 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); |
| 224 | 223 |
| 225 ash::Shell* shell = ash::Shell::GetInstance(); | 224 ash::Shell* shell = ash::Shell::GetInstance(); |
| 226 | 225 |
| 227 LoadDisplayPreferences(true); | 226 LoadDisplayPreferences(true); |
| 228 // DisplayPowerState should be ignored at boot. | 227 // DisplayPowerState should be ignored at boot. |
| 229 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, | 228 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 230 shell->display_configurator()->requested_power_state()); | 229 shell->display_configurator()->requested_power_state()); |
| 231 | 230 |
| 232 shell->display_manager()->UpdateDisplays(); | 231 shell->display_manager()->UpdateDisplays(); |
| 233 // Check if the layout settings are notified to the system properly. | 232 // Check if the layout settings are notified to the system properly. |
| 234 // The paired layout overrides old layout. | 233 // The new layout overrides old layout. |
| 235 // Inverted one of for specified pair (id1, id2). Not used for the pair | 234 // Inverted one of for specified pair (id1, id2). Not used for the list |
| 236 // (id1, dummy_id) since dummy_id is not connected right now. | 235 // (id1, dummy_id) since dummy_id is not connected right now. |
| 237 EXPECT_EQ("top, 20", | 236 EXPECT_EQ("top, 20", |
| 238 shell->display_manager()->GetCurrentDisplayLayout().ToString()); | 237 shell->display_manager()->GetCurrentDisplayLayout().ToString()); |
| 239 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(pair)); | 238 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(list)); |
| 240 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(dummy_pair)); | 239 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(dummy_list)); |
| 241 } | 240 } |
| 242 | 241 |
| 243 TEST_F(DisplayPreferencesTest, BasicStores) { | 242 TEST_F(DisplayPreferencesTest, BasicStores) { |
| 244 ash::WindowTreeHostManager* window_tree_host_manager = | 243 ash::WindowTreeHostManager* window_tree_host_manager = |
| 245 ash::Shell::GetInstance()->window_tree_host_manager(); | 244 ash::Shell::GetInstance()->window_tree_host_manager(); |
| 246 ash::DisplayManager* display_manager = | 245 ash::DisplayManager* display_manager = |
| 247 ash::Shell::GetInstance()->display_manager(); | 246 ash::Shell::GetInstance()->display_manager(); |
| 248 | 247 |
| 249 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); | 248 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); |
| 250 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); | 249 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 } | 879 } |
| 881 | 880 |
| 882 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { | 881 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { |
| 883 | 882 |
| 884 LoggedInAsUser(); | 883 LoggedInAsUser(); |
| 885 ash::DisplayManager* display_manager = | 884 ash::DisplayManager* display_manager = |
| 886 ash::Shell::GetInstance()->display_manager(); | 885 ash::Shell::GetInstance()->display_manager(); |
| 887 display_manager->SetUnifiedDesktopEnabled(true); | 886 display_manager->SetUnifiedDesktopEnabled(true); |
| 888 | 887 |
| 889 UpdateDisplay("200x200,100x100"); | 888 UpdateDisplay("200x200,100x100"); |
| 890 ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); | 889 ash::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 891 EXPECT_EQ("400x200", | 890 EXPECT_EQ("400x200", |
| 892 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 891 gfx::Screen::GetScreen()->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(secondary_displays->GetDictionary( |
| 898 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 897 ash::DisplayIdListToString(list), &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::GetScreen()->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("200x100", | 911 EXPECT_EQ("200x100", |
| 913 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 912 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
| 914 EXPECT_FALSE( | 913 EXPECT_FALSE( |
| 915 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 914 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
| 916 | 915 |
| 917 // Mirror mode should remember if the default mode was unified. | 916 // Mirror mode should remember if the default mode was unified. |
| 918 display_manager->SetMirrorMode(true); | 917 display_manager->SetMirrorMode(true); |
| 919 ASSERT_TRUE( | 918 ASSERT_TRUE(secondary_displays->GetDictionary( |
| 920 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 919 ash::DisplayIdListToString(list), &new_value)); |
| 921 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 920 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 922 EXPECT_TRUE(stored_layout.default_unified); | 921 EXPECT_TRUE(stored_layout.default_unified); |
| 923 EXPECT_TRUE(stored_layout.mirrored); | 922 EXPECT_TRUE(stored_layout.mirrored); |
| 924 | 923 |
| 925 display_manager->SetMirrorMode(false); | 924 display_manager->SetMirrorMode(false); |
| 926 ASSERT_TRUE( | 925 ASSERT_TRUE(secondary_displays->GetDictionary( |
| 927 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 926 ash::DisplayIdListToString(list), &new_value)); |
| 928 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 927 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 929 EXPECT_TRUE(stored_layout.default_unified); | 928 EXPECT_TRUE(stored_layout.default_unified); |
| 930 EXPECT_FALSE(stored_layout.mirrored); | 929 EXPECT_FALSE(stored_layout.mirrored); |
| 931 | 930 |
| 932 // Exit unified mode. | 931 // Exit unified mode. |
| 933 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( | 932 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( |
| 934 ash::DisplayManager::EXTENDED); | 933 ash::DisplayManager::EXTENDED); |
| 935 ASSERT_TRUE( | 934 ASSERT_TRUE(secondary_displays->GetDictionary( |
| 936 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 935 ash::DisplayIdListToString(list), &new_value)); |
| 937 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 936 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 938 EXPECT_FALSE(stored_layout.default_unified); | 937 EXPECT_FALSE(stored_layout.default_unified); |
| 939 EXPECT_FALSE(stored_layout.mirrored); | 938 EXPECT_FALSE(stored_layout.mirrored); |
| 940 } | 939 } |
| 941 | 940 |
| 942 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { | 941 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { |
| 943 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); | 942 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 944 ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1); | 943 ash::DisplayIdList list = ash::CreateDisplayIdList(id1, id1 + 1); |
| 945 StoreDisplayBoolPropertyForPair(pair, "default_unified", true); | 944 StoreDisplayBoolPropertyForList(list, "default_unified", true); |
| 946 StoreDisplayPropertyForPair( | 945 StoreDisplayPropertyForList( |
| 947 pair, "primary-id", | 946 list, "primary-id", |
| 948 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1)))); | 947 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1)))); |
| 949 LoadDisplayPreferences(false); | 948 LoadDisplayPreferences(false); |
| 950 | 949 |
| 951 // Should not restore to unified unless unified desktop is enabled. | 950 // Should not restore to unified unless unified desktop is enabled. |
| 952 UpdateDisplay("100x100,200x200"); | 951 UpdateDisplay("100x100,200x200"); |
| 953 ash::DisplayManager* display_manager = | 952 ash::DisplayManager* display_manager = |
| 954 ash::Shell::GetInstance()->display_manager(); | 953 ash::Shell::GetInstance()->display_manager(); |
| 955 EXPECT_FALSE(display_manager->IsInUnifiedMode()); | 954 EXPECT_FALSE(display_manager->IsInUnifiedMode()); |
| 956 | 955 |
| 957 // Restored to unified. | 956 // Restored to unified. |
| 958 display_manager->SetUnifiedDesktopEnabled(true); | 957 display_manager->SetUnifiedDesktopEnabled(true); |
| 959 StoreDisplayBoolPropertyForPair(pair, "default_unified", true); | 958 StoreDisplayBoolPropertyForList(list, "default_unified", true); |
| 960 LoadDisplayPreferences(false); | 959 LoadDisplayPreferences(false); |
| 961 UpdateDisplay("100x100,200x200"); | 960 UpdateDisplay("100x100,200x200"); |
| 962 EXPECT_TRUE(display_manager->IsInUnifiedMode()); | 961 EXPECT_TRUE(display_manager->IsInUnifiedMode()); |
| 963 | 962 |
| 964 // Restored to mirror, then unified. | 963 // Restored to mirror, then unified. |
| 965 StoreDisplayBoolPropertyForPair(pair, "mirrored", true); | 964 StoreDisplayBoolPropertyForList(list, "mirrored", true); |
| 966 StoreDisplayBoolPropertyForPair(pair, "default_unified", true); | 965 StoreDisplayBoolPropertyForList(list, "default_unified", true); |
| 967 LoadDisplayPreferences(false); | 966 LoadDisplayPreferences(false); |
| 968 UpdateDisplay("100x100,200x200"); | 967 UpdateDisplay("100x100,200x200"); |
| 969 EXPECT_TRUE(display_manager->IsInMirrorMode()); | 968 EXPECT_TRUE(display_manager->IsInMirrorMode()); |
| 970 | 969 |
| 971 display_manager->SetMirrorMode(false); | 970 display_manager->SetMirrorMode(false); |
| 972 EXPECT_TRUE(display_manager->IsInUnifiedMode()); | 971 EXPECT_TRUE(display_manager->IsInUnifiedMode()); |
| 973 | 972 |
| 974 // Sanity check. Restore to extended. | 973 // Sanity check. Restore to extended. |
| 975 StoreDisplayBoolPropertyForPair(pair, "default_unified", false); | 974 StoreDisplayBoolPropertyForList(list, "default_unified", false); |
| 976 StoreDisplayBoolPropertyForPair(pair, "mirrored", false); | 975 StoreDisplayBoolPropertyForList(list, "mirrored", false); |
| 977 LoadDisplayPreferences(false); | 976 LoadDisplayPreferences(false); |
| 978 UpdateDisplay("100x100,200x200"); | 977 UpdateDisplay("100x100,200x200"); |
| 979 EXPECT_FALSE(display_manager->IsInMirrorMode()); | 978 EXPECT_FALSE(display_manager->IsInMirrorMode()); |
| 980 EXPECT_FALSE(display_manager->IsInUnifiedMode()); | 979 EXPECT_FALSE(display_manager->IsInUnifiedMode()); |
| 981 } | 980 } |
| 982 | 981 |
| 983 } // namespace chromeos | 982 } // namespace chromeos |
| OLD | NEW |