| 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> |
| 11 | 11 |
| 12 #include "ash/display/display_layout_builder.h" | |
| 13 #include "ash/display/display_layout_store.h" | 12 #include "ash/display/display_layout_store.h" |
| 14 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/display_util.h" | 14 #include "ash/display/display_util.h" |
| 16 #include "ash/display/json_converter.h" | 15 #include "ash/display/json_converter.h" |
| 17 #include "ash/display/resolution_notification_controller.h" | 16 #include "ash/display/resolution_notification_controller.h" |
| 18 #include "ash/display/screen_orientation_controller_chromeos.h" | 17 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 19 #include "ash/display/window_tree_host_manager.h" | 18 #include "ash/display/window_tree_host_manager.h" |
| 20 #include "ash/screen_util.h" | 19 #include "ash/screen_util.h" |
| 21 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 22 #include "ash/test/ash_test_base.h" | 21 #include "ash/test/ash_test_base.h" |
| 23 #include "ash/test/display_manager_test_api.h" | 22 #include "ash/test/display_manager_test_api.h" |
| 24 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 23 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 25 #include "base/macros.h" | 24 #include "base/macros.h" |
| 26 #include "base/memory/ref_counted.h" | 25 #include "base/memory/ref_counted.h" |
| 27 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
| 28 #include "base/values.h" | 27 #include "base/values.h" |
| 29 #include "chrome/browser/chromeos/display/display_configuration_observer.h" | 28 #include "chrome/browser/chromeos/display/display_configuration_observer.h" |
| 30 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 29 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
| 31 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 30 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/test/base/testing_browser_process.h" | 32 #include "chrome/test/base/testing_browser_process.h" |
| 34 #include "components/prefs/scoped_user_pref_update.h" | 33 #include "components/prefs/scoped_user_pref_update.h" |
| 35 #include "components/prefs/testing_pref_service.h" | 34 #include "components/prefs/testing_pref_service.h" |
| 36 #include "ui/display/chromeos/display_configurator.h" | 35 #include "ui/display/chromeos/display_configurator.h" |
| 36 #include "ui/display/manager/display_layout_builder.h" |
| 37 #include "ui/gfx/geometry/vector3d_f.h" | 37 #include "ui/gfx/geometry/vector3d_f.h" |
| 38 #include "ui/gfx/screen.h" | 38 #include "ui/gfx/screen.h" |
| 39 #include "ui/message_center/message_center.h" | 39 #include "ui/message_center/message_center.h" |
| 40 | 40 |
| 41 using ash::ResolutionNotificationController; | 41 using ash::ResolutionNotificationController; |
| 42 | 42 |
| 43 namespace chromeos { | 43 namespace chromeos { |
| 44 namespace { | 44 namespace { |
| 45 const char kPrimaryIdKey[] = "primary-id"; | 45 const char kPrimaryIdKey[] = "primary-id"; |
| 46 const char kMirroredKey[] = "mirrored"; | 46 const char kMirroredKey[] = "mirrored"; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) | 94 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) |
| 95 .WillRepeatedly(testing::Return(true)); | 95 .WillRepeatedly(testing::Return(true)); |
| 96 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) | 96 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsUserWithGaiaAccount()) |
| 97 .WillRepeatedly(testing::Return(false)); | 97 .WillRepeatedly(testing::Return(false)); |
| 98 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsSupervisedUser()) | 98 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsSupervisedUser()) |
| 99 .WillRepeatedly(testing::Return(false)); | 99 .WillRepeatedly(testing::Return(false)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // Do not use the implementation of display_preferences.cc directly to avoid | 102 // Do not use the implementation of display_preferences.cc directly to avoid |
| 103 // notifying the update to the system. | 103 // notifying the update to the system. |
| 104 void StoreDisplayLayoutPrefForList(const ash::DisplayIdList& list, | 104 void StoreDisplayLayoutPrefForList( |
| 105 ash::DisplayPlacement::Position position, | 105 const display::DisplayIdList& list, |
| 106 int offset, | 106 display::DisplayPlacement::Position position, |
| 107 int64_t primary_id) { | 107 int offset, |
| 108 int64_t primary_id) { |
| 108 std::string name = ash::DisplayIdListToString(list); | 109 std::string name = ash::DisplayIdListToString(list); |
| 109 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); | 110 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); |
| 110 ash::DisplayLayout display_layout; | 111 display::DisplayLayout display_layout; |
| 111 display_layout.placement_list.emplace_back(position, offset); | 112 display_layout.placement_list.emplace_back(position, offset); |
| 112 display_layout.primary_id = primary_id; | 113 display_layout.primary_id = primary_id; |
| 113 | 114 |
| 114 DCHECK(!name.empty()); | 115 DCHECK(!name.empty()); |
| 115 | 116 |
| 116 base::DictionaryValue* pref_data = update.Get(); | 117 base::DictionaryValue* pref_data = update.Get(); |
| 117 scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); | 118 scoped_ptr<base::Value>layout_value(new base::DictionaryValue()); |
| 118 if (pref_data->HasKey(name)) { | 119 if (pref_data->HasKey(name)) { |
| 119 base::Value* value = nullptr; | 120 base::Value* value = nullptr; |
| 120 if (pref_data->Get(name, &value) && value != nullptr) | 121 if (pref_data->Get(name, &value) && value != nullptr) |
| 121 layout_value.reset(value->DeepCopy()); | 122 layout_value.reset(value->DeepCopy()); |
| 122 } | 123 } |
| 123 if (ash::DisplayLayoutToJson(display_layout, layout_value.get())) | 124 if (ash::DisplayLayoutToJson(display_layout, layout_value.get())) |
| 124 pref_data->Set(name, layout_value.release()); | 125 pref_data->Set(name, layout_value.release()); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void StoreDisplayPropertyForList(const ash::DisplayIdList& list, | 128 void StoreDisplayPropertyForList(const display::DisplayIdList& list, |
| 128 std::string key, | 129 std::string key, |
| 129 scoped_ptr<base::Value> value) { | 130 scoped_ptr<base::Value> value) { |
| 130 std::string name = ash::DisplayIdListToString(list); | 131 std::string name = ash::DisplayIdListToString(list); |
| 131 | 132 |
| 132 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); | 133 DictionaryPrefUpdate update(&local_state_, prefs::kSecondaryDisplays); |
| 133 base::DictionaryValue* pref_data = update.Get(); | 134 base::DictionaryValue* pref_data = update.Get(); |
| 134 | 135 |
| 135 if (pref_data->HasKey(name)) { | 136 if (pref_data->HasKey(name)) { |
| 136 base::Value* layout_value = nullptr; | 137 base::Value* layout_value = nullptr; |
| 137 pref_data->Get(name, &layout_value); | 138 pref_data->Get(name, &layout_value); |
| 138 if (layout_value) | 139 if (layout_value) |
| 139 static_cast<base::DictionaryValue*>(layout_value) | 140 static_cast<base::DictionaryValue*>(layout_value) |
| 140 ->Set(key, std::move(value)); | 141 ->Set(key, std::move(value)); |
| 141 } else { | 142 } else { |
| 142 scoped_ptr<base::DictionaryValue> layout_value( | 143 scoped_ptr<base::DictionaryValue> layout_value( |
| 143 new base::DictionaryValue()); | 144 new base::DictionaryValue()); |
| 144 layout_value->SetBoolean(key, value != nullptr); | 145 layout_value->SetBoolean(key, value != nullptr); |
| 145 pref_data->Set(name, layout_value.release()); | 146 pref_data->Set(name, layout_value.release()); |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 | 149 |
| 149 void StoreDisplayBoolPropertyForList(const ash::DisplayIdList& list, | 150 void StoreDisplayBoolPropertyForList(const display::DisplayIdList& list, |
| 150 const std::string& key, | 151 const std::string& key, |
| 151 bool value) { | 152 bool value) { |
| 152 StoreDisplayPropertyForList( | 153 StoreDisplayPropertyForList( |
| 153 list, key, make_scoped_ptr(new base::FundamentalValue(value))); | 154 list, key, make_scoped_ptr(new base::FundamentalValue(value))); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void StoreDisplayLayoutPrefForList(const ash::DisplayIdList& list, | 157 void StoreDisplayLayoutPrefForList(const display::DisplayIdList& list, |
| 157 ash::DisplayPlacement::Position layout, | 158 display::DisplayPlacement::Position layout, |
| 158 int offset) { | 159 int offset) { |
| 159 StoreDisplayLayoutPrefForList(list, layout, offset, list[0]); | 160 StoreDisplayLayoutPrefForList(list, layout, offset, list[0]); |
| 160 } | 161 } |
| 161 | 162 |
| 162 void StoreDisplayOverscan(int64_t id, const gfx::Insets& insets) { | 163 void StoreDisplayOverscan(int64_t id, const gfx::Insets& insets) { |
| 163 DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); | 164 DictionaryPrefUpdate update(&local_state_, prefs::kDisplayProperties); |
| 164 const std::string name = base::Int64ToString(id); | 165 const std::string name = base::Int64ToString(id); |
| 165 | 166 |
| 166 base::DictionaryValue* pref_data = update.Get(); | 167 base::DictionaryValue* pref_data = update.Get(); |
| 167 base::DictionaryValue* insets_value = new base::DictionaryValue(); | 168 base::DictionaryValue* insets_value = new base::DictionaryValue(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 183 } | 184 } |
| 184 | 185 |
| 185 void StoreDisplayRotationPrefsForTest(bool rotation_lock, | 186 void StoreDisplayRotationPrefsForTest(bool rotation_lock, |
| 186 gfx::Display::Rotation rotation) { | 187 gfx::Display::Rotation rotation) { |
| 187 DictionaryPrefUpdate update(local_state(), prefs::kDisplayRotationLock); | 188 DictionaryPrefUpdate update(local_state(), prefs::kDisplayRotationLock); |
| 188 base::DictionaryValue* pref_data = update.Get(); | 189 base::DictionaryValue* pref_data = update.Get(); |
| 189 pref_data->SetBoolean("lock", rotation_lock); | 190 pref_data->SetBoolean("lock", rotation_lock); |
| 190 pref_data->SetInteger("orientation", static_cast<int>(rotation)); | 191 pref_data->SetInteger("orientation", static_cast<int>(rotation)); |
| 191 } | 192 } |
| 192 | 193 |
| 193 std::string GetRegisteredDisplayPlacementStr(const ash::DisplayIdList& list) { | 194 std::string GetRegisteredDisplayPlacementStr( |
| 195 const display::DisplayIdList& list) { |
| 194 return ash::Shell::GetInstance() | 196 return ash::Shell::GetInstance() |
| 195 ->display_manager() | 197 ->display_manager() |
| 196 ->layout_store() | 198 ->layout_store() |
| 197 ->GetRegisteredDisplayLayout(list) | 199 ->GetRegisteredDisplayLayout(list) |
| 198 .placement_list[0] | 200 .placement_list[0] |
| 199 .ToString(); | 201 .ToString(); |
| 200 } | 202 } |
| 201 | 203 |
| 202 PrefService* local_state() { return &local_state_; } | 204 PrefService* local_state() { return &local_state_; } |
| 203 | 205 |
| 204 private: | 206 private: |
| 205 MockUserManager* mock_user_manager_; // Not owned. | 207 MockUserManager* mock_user_manager_; // Not owned. |
| 206 ScopedUserManagerEnabler user_manager_enabler_; | 208 ScopedUserManagerEnabler user_manager_enabler_; |
| 207 TestingPrefServiceSimple local_state_; | 209 TestingPrefServiceSimple local_state_; |
| 208 scoped_ptr<DisplayConfigurationObserver> observer_; | 210 scoped_ptr<DisplayConfigurationObserver> observer_; |
| 209 | 211 |
| 210 DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); | 212 DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); |
| 211 }; | 213 }; |
| 212 | 214 |
| 213 } // namespace | 215 } // namespace |
| 214 | 216 |
| 215 TEST_F(DisplayPreferencesTest, ListedLayoutOverrides) { | 217 TEST_F(DisplayPreferencesTest, ListedLayoutOverrides) { |
| 216 UpdateDisplay("100x100,200x200"); | 218 UpdateDisplay("100x100,200x200"); |
| 217 ash::DisplayManager* display_manager = | 219 ash::DisplayManager* display_manager = |
| 218 ash::Shell::GetInstance()->display_manager(); | 220 ash::Shell::GetInstance()->display_manager(); |
| 219 | 221 |
| 220 ash::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); | 222 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 221 ash::DisplayIdList dummy_list = | 223 display::DisplayIdList dummy_list = |
| 222 ash::test::CreateDisplayIdList2(list[0], list[1] + 1); | 224 ash::test::CreateDisplayIdList2(list[0], list[1] + 1); |
| 223 ASSERT_NE(list[0], dummy_list[1]); | 225 ASSERT_NE(list[0], dummy_list[1]); |
| 224 | 226 |
| 225 StoreDisplayLayoutPrefForList(list, ash::DisplayPlacement::TOP, 20); | 227 StoreDisplayLayoutPrefForList(list, display::DisplayPlacement::TOP, 20); |
| 226 StoreDisplayLayoutPrefForList(dummy_list, ash::DisplayPlacement::LEFT, 30); | 228 StoreDisplayLayoutPrefForList(dummy_list, display::DisplayPlacement::LEFT, |
| 229 30); |
| 227 StoreDisplayPowerStateForTest( | 230 StoreDisplayPowerStateForTest( |
| 228 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); | 231 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); |
| 229 | 232 |
| 230 ash::Shell* shell = ash::Shell::GetInstance(); | 233 ash::Shell* shell = ash::Shell::GetInstance(); |
| 231 | 234 |
| 232 LoadDisplayPreferences(true); | 235 LoadDisplayPreferences(true); |
| 233 // DisplayPowerState should be ignored at boot. | 236 // DisplayPowerState should be ignored at boot. |
| 234 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, | 237 EXPECT_EQ(chromeos::DISPLAY_POWER_ALL_ON, |
| 235 shell->display_configurator()->requested_power_state()); | 238 shell->display_configurator()->requested_power_state()); |
| 236 | 239 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 profiles.push_back(ui::COLOR_PROFILE_MOVIE); | 271 profiles.push_back(ui::COLOR_PROFILE_MOVIE); |
| 269 profiles.push_back(ui::COLOR_PROFILE_READING); | 272 profiles.push_back(ui::COLOR_PROFILE_READING); |
| 270 // Allows only |id1|. | 273 // Allows only |id1|. |
| 271 ash::test::DisplayManagerTestApi().SetAvailableColorProfiles(id1, profiles); | 274 ash::test::DisplayManagerTestApi().SetAvailableColorProfiles(id1, profiles); |
| 272 display_manager->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); | 275 display_manager->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); |
| 273 display_manager->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); | 276 display_manager->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); |
| 274 | 277 |
| 275 LoggedInAsUser(); | 278 LoggedInAsUser(); |
| 276 | 279 |
| 277 display_manager->SetLayoutForCurrentDisplays( | 280 display_manager->SetLayoutForCurrentDisplays( |
| 278 ash::test::CreateDisplayLayout(ash::DisplayPlacement::TOP, 10)); | 281 ash::test::CreateDisplayLayout(display::DisplayPlacement::TOP, 10)); |
| 279 const ash::DisplayLayout& layout = display_manager->GetCurrentDisplayLayout(); | 282 const display::DisplayLayout& layout = |
| 280 EXPECT_EQ(ash::DisplayPlacement::TOP, layout.placement_list[0].position); | 283 display_manager->GetCurrentDisplayLayout(); |
| 284 EXPECT_EQ(display::DisplayPlacement::TOP, layout.placement_list[0].position); |
| 281 EXPECT_EQ(10, layout.placement_list[0].offset); | 285 EXPECT_EQ(10, layout.placement_list[0].offset); |
| 282 | 286 |
| 283 ash::DisplayLayoutBuilder dummy_layout_builder(id1); | 287 display::DisplayLayoutBuilder dummy_layout_builder(id1); |
| 284 dummy_layout_builder.SetSecondaryPlacement(dummy_id, | 288 dummy_layout_builder.SetSecondaryPlacement( |
| 285 ash::DisplayPlacement::LEFT, 20); | 289 dummy_id, display::DisplayPlacement::LEFT, 20); |
| 286 scoped_ptr<ash::DisplayLayout> dummy_layout(dummy_layout_builder.Build()); | 290 scoped_ptr<display::DisplayLayout> dummy_layout(dummy_layout_builder.Build()); |
| 287 ash::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, dummy_id); | 291 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, dummy_id); |
| 288 StoreDisplayLayoutPrefForTest(list, *dummy_layout); | 292 StoreDisplayLayoutPrefForTest(list, *dummy_layout); |
| 289 | 293 |
| 290 // Can't switch to a display that does not exist. | 294 // Can't switch to a display that does not exist. |
| 291 window_tree_host_manager->SetPrimaryDisplayId(dummy_id); | 295 window_tree_host_manager->SetPrimaryDisplayId(dummy_id); |
| 292 EXPECT_NE(dummy_id, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); | 296 EXPECT_NE(dummy_id, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 293 | 297 |
| 294 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); | 298 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); |
| 295 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90, | 299 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90, |
| 296 gfx::Display::ROTATION_SOURCE_USER); | 300 gfx::Display::ROTATION_SOURCE_USER); |
| 297 EXPECT_TRUE(ash::SetDisplayUIScale(id1, 1.25f)); | 301 EXPECT_TRUE(ash::SetDisplayUIScale(id1, 1.25f)); |
| 298 EXPECT_FALSE(ash::SetDisplayUIScale(id2, 1.25f)); | 302 EXPECT_FALSE(ash::SetDisplayUIScale(id2, 1.25f)); |
| 299 | 303 |
| 300 const base::DictionaryValue* displays = | 304 const base::DictionaryValue* displays = |
| 301 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 305 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
| 302 const base::DictionaryValue* layout_value = nullptr; | 306 const base::DictionaryValue* layout_value = nullptr; |
| 303 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); | 307 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
| 304 std::string dummy_key = | 308 std::string dummy_key = |
| 305 base::Int64ToString(id1) + "," + base::Int64ToString(dummy_id); | 309 base::Int64ToString(id1) + "," + base::Int64ToString(dummy_id); |
| 306 EXPECT_TRUE(displays->GetDictionary(dummy_key, &layout_value)); | 310 EXPECT_TRUE(displays->GetDictionary(dummy_key, &layout_value)); |
| 307 | 311 |
| 308 ash::DisplayLayout stored_layout; | 312 display::DisplayLayout stored_layout; |
| 309 EXPECT_TRUE(ash::JsonToDisplayLayout(*layout_value, &stored_layout)); | 313 EXPECT_TRUE(ash::JsonToDisplayLayout(*layout_value, &stored_layout)); |
| 310 ASSERT_EQ(1u, stored_layout.placement_list.size()); | 314 ASSERT_EQ(1u, stored_layout.placement_list.size()); |
| 311 | 315 |
| 312 EXPECT_EQ(dummy_layout->placement_list[0].position, | 316 EXPECT_EQ(dummy_layout->placement_list[0].position, |
| 313 stored_layout.placement_list[0].position); | 317 stored_layout.placement_list[0].position); |
| 314 EXPECT_EQ(dummy_layout->placement_list[0].offset, | 318 EXPECT_EQ(dummy_layout->placement_list[0].offset, |
| 315 stored_layout.placement_list[0].offset); | 319 stored_layout.placement_list[0].offset); |
| 316 | 320 |
| 317 bool mirrored = true; | 321 bool mirrored = true; |
| 318 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); | 322 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 "device-scale-factor", &device_scale_factor)); | 399 "device-scale-factor", &device_scale_factor)); |
| 396 EXPECT_EQ(300, width); | 400 EXPECT_EQ(300, width); |
| 397 EXPECT_EQ(200, height); | 401 EXPECT_EQ(200, height); |
| 398 EXPECT_EQ(1250, device_scale_factor); | 402 EXPECT_EQ(1250, device_scale_factor); |
| 399 | 403 |
| 400 // The layout is swapped. | 404 // The layout is swapped. |
| 401 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 405 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 402 | 406 |
| 403 EXPECT_TRUE(ash::JsonToDisplayLayout(*layout_value, &stored_layout)); | 407 EXPECT_TRUE(ash::JsonToDisplayLayout(*layout_value, &stored_layout)); |
| 404 ASSERT_EQ(1u, stored_layout.placement_list.size()); | 408 ASSERT_EQ(1u, stored_layout.placement_list.size()); |
| 405 const ash::DisplayPlacement& stored_placement = | 409 const display::DisplayPlacement& stored_placement = |
| 406 stored_layout.placement_list[0]; | 410 stored_layout.placement_list[0]; |
| 407 EXPECT_EQ(ash::DisplayPlacement::BOTTOM, stored_placement.position); | 411 EXPECT_EQ(display::DisplayPlacement::BOTTOM, stored_placement.position); |
| 408 EXPECT_EQ(-10, stored_placement.offset); | 412 EXPECT_EQ(-10, stored_placement.offset); |
| 409 EXPECT_EQ(id1, stored_placement.display_id); | 413 EXPECT_EQ(id1, stored_placement.display_id); |
| 410 EXPECT_EQ(id2, stored_placement.parent_display_id); | 414 EXPECT_EQ(id2, stored_placement.parent_display_id); |
| 411 EXPECT_EQ(id2, stored_layout.primary_id); | 415 EXPECT_EQ(id2, stored_layout.primary_id); |
| 412 | 416 |
| 413 if (true) | 417 if (true) |
| 414 return; | 418 return; |
| 415 | 419 |
| 416 mirrored = true; | 420 mirrored = true; |
| 417 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); | 421 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
| 418 EXPECT_FALSE(mirrored); | 422 EXPECT_FALSE(mirrored); |
| 419 std::string primary_id_str; | 423 std::string primary_id_str; |
| 420 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); | 424 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); |
| 421 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); | 425 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); |
| 422 | 426 |
| 423 display_manager->SetLayoutForCurrentDisplays( | 427 display_manager->SetLayoutForCurrentDisplays( |
| 424 ash::test::CreateDisplayLayout(ash::DisplayPlacement::BOTTOM, 20)); | 428 ash::test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 20)); |
| 425 | 429 |
| 426 UpdateDisplay("1+0-200x200*2,1+0-200x200"); | 430 UpdateDisplay("1+0-200x200*2,1+0-200x200"); |
| 427 // Mirrored. | 431 // Mirrored. |
| 428 int offset = 0; | 432 int offset = 0; |
| 429 std::string position; | 433 std::string position; |
| 430 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 434 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 431 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); | 435 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
| 432 EXPECT_EQ("bottom", position); | 436 EXPECT_EQ("bottom", position); |
| 433 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); | 437 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); |
| 434 EXPECT_EQ(20, offset); | 438 EXPECT_EQ(20, offset); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 ash::test::SwapPrimaryDisplay(); | 573 ash::test::SwapPrimaryDisplay(); |
| 570 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); | 574 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); |
| 571 | 575 |
| 572 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); | 576 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
| 573 const base::DictionaryValue* displays = | 577 const base::DictionaryValue* displays = |
| 574 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 578 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
| 575 // Initial saved value is swapped. | 579 // Initial saved value is swapped. |
| 576 { | 580 { |
| 577 const base::DictionaryValue* new_value = nullptr; | 581 const base::DictionaryValue* new_value = nullptr; |
| 578 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 582 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
| 579 ash::DisplayLayout stored_layout; | 583 display::DisplayLayout stored_layout; |
| 580 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 584 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 581 ASSERT_EQ(1u, stored_layout.placement_list.size()); | 585 ASSERT_EQ(1u, stored_layout.placement_list.size()); |
| 582 const ash::DisplayPlacement& stored_placement = | 586 const display::DisplayPlacement& stored_placement = |
| 583 stored_layout.placement_list[0]; | 587 stored_layout.placement_list[0]; |
| 584 EXPECT_EQ(ash::DisplayPlacement::LEFT, stored_placement.position); | 588 EXPECT_EQ(display::DisplayPlacement::LEFT, stored_placement.position); |
| 585 EXPECT_EQ(0, stored_placement.offset); | 589 EXPECT_EQ(0, stored_placement.offset); |
| 586 EXPECT_EQ(id1, stored_placement.display_id); | 590 EXPECT_EQ(id1, stored_placement.display_id); |
| 587 EXPECT_EQ(id2, stored_placement.parent_display_id); | 591 EXPECT_EQ(id2, stored_placement.parent_display_id); |
| 588 EXPECT_EQ(id2, stored_layout.primary_id); | 592 EXPECT_EQ(id2, stored_layout.primary_id); |
| 589 } | 593 } |
| 590 | 594 |
| 591 // Updating layout with primary swapped should save the correct value. | 595 // Updating layout with primary swapped should save the correct value. |
| 592 { | 596 { |
| 593 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 597 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 594 ash::test::CreateDisplayLayout(ash::DisplayPlacement::TOP, 10)); | 598 ash::test::CreateDisplayLayout(display::DisplayPlacement::TOP, 10)); |
| 595 const base::DictionaryValue* new_value = nullptr; | 599 const base::DictionaryValue* new_value = nullptr; |
| 596 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 600 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
| 597 ash::DisplayLayout stored_layout; | 601 display::DisplayLayout stored_layout; |
| 598 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 602 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 599 ASSERT_EQ(1u, stored_layout.placement_list.size()); | 603 ASSERT_EQ(1u, stored_layout.placement_list.size()); |
| 600 const ash::DisplayPlacement& stored_placement = | 604 const display::DisplayPlacement& stored_placement = |
| 601 stored_layout.placement_list[0]; | 605 stored_layout.placement_list[0]; |
| 602 EXPECT_EQ(ash::DisplayPlacement::TOP, stored_placement.position); | 606 EXPECT_EQ(display::DisplayPlacement::TOP, stored_placement.position); |
| 603 EXPECT_EQ(10, stored_placement.offset); | 607 EXPECT_EQ(10, stored_placement.offset); |
| 604 EXPECT_EQ(id1, stored_placement.display_id); | 608 EXPECT_EQ(id1, stored_placement.display_id); |
| 605 EXPECT_EQ(id2, stored_placement.parent_display_id); | 609 EXPECT_EQ(id2, stored_placement.parent_display_id); |
| 606 EXPECT_EQ(id2, stored_layout.primary_id); | 610 EXPECT_EQ(id2, stored_layout.primary_id); |
| 607 } | 611 } |
| 608 | 612 |
| 609 // Swapping primary will save the swapped value. | 613 // Swapping primary will save the swapped value. |
| 610 { | 614 { |
| 611 ash::test::SwapPrimaryDisplay(); | 615 ash::test::SwapPrimaryDisplay(); |
| 612 const base::DictionaryValue* new_value = nullptr; | 616 const base::DictionaryValue* new_value = nullptr; |
| 613 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 617 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
| 614 ash::DisplayLayout stored_layout; | 618 display::DisplayLayout stored_layout; |
| 615 | 619 |
| 616 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 620 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
| 617 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 621 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 618 ASSERT_EQ(1u, stored_layout.placement_list.size()); | 622 ASSERT_EQ(1u, stored_layout.placement_list.size()); |
| 619 const ash::DisplayPlacement& stored_placement = | 623 const display::DisplayPlacement& stored_placement = |
| 620 stored_layout.placement_list[0]; | 624 stored_layout.placement_list[0]; |
| 621 EXPECT_EQ(ash::DisplayPlacement::BOTTOM, stored_placement.position); | 625 EXPECT_EQ(display::DisplayPlacement::BOTTOM, stored_placement.position); |
| 622 EXPECT_EQ(-10, stored_placement.offset); | 626 EXPECT_EQ(-10, stored_placement.offset); |
| 623 EXPECT_EQ(id2, stored_placement.display_id); | 627 EXPECT_EQ(id2, stored_placement.display_id); |
| 624 EXPECT_EQ(id1, stored_placement.parent_display_id); | 628 EXPECT_EQ(id1, stored_placement.parent_display_id); |
| 625 EXPECT_EQ(id1, stored_layout.primary_id); | 629 EXPECT_EQ(id1, stored_layout.primary_id); |
| 626 } | 630 } |
| 627 } | 631 } |
| 628 | 632 |
| 629 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { | 633 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { |
| 630 ash::DisplayManager* display_manager = | 634 ash::DisplayManager* display_manager = |
| 631 ash::Shell::GetInstance()->display_manager(); | 635 ash::Shell::GetInstance()->display_manager(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 661 | 665 |
| 662 UpdateDisplay("200x200*2,200x200"); | 666 UpdateDisplay("200x200*2,200x200"); |
| 663 | 667 |
| 664 LoggedInAsGuest(); | 668 LoggedInAsGuest(); |
| 665 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); | 669 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 666 ash::test::ScopedSetInternalDisplayId set_internal(id1); | 670 ash::test::ScopedSetInternalDisplayId set_internal(id1); |
| 667 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 671 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 668 ash::DisplayManager* display_manager = | 672 ash::DisplayManager* display_manager = |
| 669 ash::Shell::GetInstance()->display_manager(); | 673 ash::Shell::GetInstance()->display_manager(); |
| 670 display_manager->SetLayoutForCurrentDisplays( | 674 display_manager->SetLayoutForCurrentDisplays( |
| 671 ash::test::CreateDisplayLayout(ash::DisplayPlacement::TOP, 10)); | 675 ash::test::CreateDisplayLayout(display::DisplayPlacement::TOP, 10)); |
| 672 ash::SetDisplayUIScale(id1, 1.25f); | 676 ash::SetDisplayUIScale(id1, 1.25f); |
| 673 window_tree_host_manager->SetPrimaryDisplayId(id2); | 677 window_tree_host_manager->SetPrimaryDisplayId(id2); |
| 674 int64_t new_primary = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); | 678 int64_t new_primary = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 675 window_tree_host_manager->SetOverscanInsets(new_primary, | 679 window_tree_host_manager->SetOverscanInsets(new_primary, |
| 676 gfx::Insets(10, 11, 12, 13)); | 680 gfx::Insets(10, 11, 12, 13)); |
| 677 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, | 681 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, |
| 678 gfx::Display::ROTATION_SOURCE_USER); | 682 gfx::Display::ROTATION_SOURCE_USER); |
| 679 | 683 |
| 680 // Does not store the preferences locally. | 684 // Does not store the preferences locally. |
| 681 EXPECT_FALSE(local_state()->FindPreference( | 685 EXPECT_FALSE(local_state()->FindPreference( |
| 682 prefs::kSecondaryDisplays)->HasUserSetting()); | 686 prefs::kSecondaryDisplays)->HasUserSetting()); |
| 683 EXPECT_FALSE(local_state()->FindPreference( | 687 EXPECT_FALSE(local_state()->FindPreference( |
| 684 prefs::kDisplayProperties)->HasUserSetting()); | 688 prefs::kDisplayProperties)->HasUserSetting()); |
| 685 | 689 |
| 686 // Settings are still notified to the system. | 690 // Settings are still notified to the system. |
| 687 gfx::Screen* screen = gfx::Screen::GetScreen(); | 691 gfx::Screen* screen = gfx::Screen::GetScreen(); |
| 688 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); | 692 EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); |
| 689 const ash::DisplayPlacement& placement = | 693 const display::DisplayPlacement& placement = |
| 690 display_manager->GetCurrentDisplayLayout().placement_list[0]; | 694 display_manager->GetCurrentDisplayLayout().placement_list[0]; |
| 691 EXPECT_EQ(ash::DisplayPlacement::BOTTOM, placement.position); | 695 EXPECT_EQ(display::DisplayPlacement::BOTTOM, placement.position); |
| 692 EXPECT_EQ(-10, placement.offset); | 696 EXPECT_EQ(-10, placement.offset); |
| 693 const gfx::Display& primary_display = screen->GetPrimaryDisplay(); | 697 const gfx::Display& primary_display = screen->GetPrimaryDisplay(); |
| 694 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); | 698 EXPECT_EQ("178x176", primary_display.bounds().size().ToString()); |
| 695 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); | 699 EXPECT_EQ(gfx::Display::ROTATE_90, primary_display.rotation()); |
| 696 | 700 |
| 697 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); | 701 const ash::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); |
| 698 EXPECT_EQ(1.25f, info1.configured_ui_scale()); | 702 EXPECT_EQ(1.25f, info1.configured_ui_scale()); |
| 699 | 703 |
| 700 const ash::DisplayInfo& info_primary = | 704 const ash::DisplayInfo& info_primary = |
| 701 display_manager->GetDisplayInfo(new_primary); | 705 display_manager->GetDisplayInfo(new_primary); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 } | 957 } |
| 954 | 958 |
| 955 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { | 959 TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { |
| 956 | 960 |
| 957 LoggedInAsUser(); | 961 LoggedInAsUser(); |
| 958 ash::DisplayManager* display_manager = | 962 ash::DisplayManager* display_manager = |
| 959 ash::Shell::GetInstance()->display_manager(); | 963 ash::Shell::GetInstance()->display_manager(); |
| 960 display_manager->SetUnifiedDesktopEnabled(true); | 964 display_manager->SetUnifiedDesktopEnabled(true); |
| 961 | 965 |
| 962 UpdateDisplay("200x200,100x100"); | 966 UpdateDisplay("200x200,100x100"); |
| 963 ash::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); | 967 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 964 EXPECT_EQ("400x200", | 968 EXPECT_EQ("400x200", |
| 965 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 969 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
| 966 | 970 |
| 967 const base::DictionaryValue* secondary_displays = | 971 const base::DictionaryValue* secondary_displays = |
| 968 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 972 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
| 969 const base::DictionaryValue* new_value = nullptr; | 973 const base::DictionaryValue* new_value = nullptr; |
| 970 EXPECT_TRUE(secondary_displays->GetDictionary( | 974 EXPECT_TRUE(secondary_displays->GetDictionary( |
| 971 ash::DisplayIdListToString(list), &new_value)); | 975 ash::DisplayIdListToString(list), &new_value)); |
| 972 | 976 |
| 973 ash::DisplayLayout stored_layout; | 977 display::DisplayLayout stored_layout; |
| 974 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 978 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 975 EXPECT_TRUE(stored_layout.default_unified); | 979 EXPECT_TRUE(stored_layout.default_unified); |
| 976 EXPECT_FALSE(stored_layout.mirrored); | 980 EXPECT_FALSE(stored_layout.mirrored); |
| 977 | 981 |
| 978 const base::DictionaryValue* displays = | 982 const base::DictionaryValue* displays = |
| 979 local_state()->GetDictionary(prefs::kDisplayProperties); | 983 local_state()->GetDictionary(prefs::kDisplayProperties); |
| 980 int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); | 984 int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 981 EXPECT_FALSE( | 985 EXPECT_FALSE( |
| 982 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 986 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
| 983 | 987 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1007 ash::DisplayManager::EXTENDED); | 1011 ash::DisplayManager::EXTENDED); |
| 1008 ASSERT_TRUE(secondary_displays->GetDictionary( | 1012 ASSERT_TRUE(secondary_displays->GetDictionary( |
| 1009 ash::DisplayIdListToString(list), &new_value)); | 1013 ash::DisplayIdListToString(list), &new_value)); |
| 1010 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 1014 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 1011 EXPECT_FALSE(stored_layout.default_unified); | 1015 EXPECT_FALSE(stored_layout.default_unified); |
| 1012 EXPECT_FALSE(stored_layout.mirrored); | 1016 EXPECT_FALSE(stored_layout.mirrored); |
| 1013 } | 1017 } |
| 1014 | 1018 |
| 1015 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { | 1019 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { |
| 1016 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1020 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1017 ash::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, id1 + 1); | 1021 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, id1 + 1); |
| 1018 StoreDisplayBoolPropertyForList(list, "default_unified", true); | 1022 StoreDisplayBoolPropertyForList(list, "default_unified", true); |
| 1019 StoreDisplayPropertyForList( | 1023 StoreDisplayPropertyForList( |
| 1020 list, "primary-id", | 1024 list, "primary-id", |
| 1021 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1)))); | 1025 make_scoped_ptr(new base::StringValue(base::Int64ToString(id1)))); |
| 1022 LoadDisplayPreferences(false); | 1026 LoadDisplayPreferences(false); |
| 1023 | 1027 |
| 1024 // Should not restore to unified unless unified desktop is enabled. | 1028 // Should not restore to unified unless unified desktop is enabled. |
| 1025 UpdateDisplay("100x100,200x200"); | 1029 UpdateDisplay("100x100,200x200"); |
| 1026 ash::DisplayManager* display_manager = | 1030 ash::DisplayManager* display_manager = |
| 1027 ash::Shell::GetInstance()->display_manager(); | 1031 ash::Shell::GetInstance()->display_manager(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1052 EXPECT_FALSE(display_manager->IsInMirrorMode()); | 1056 EXPECT_FALSE(display_manager->IsInMirrorMode()); |
| 1053 EXPECT_FALSE(display_manager->IsInUnifiedMode()); | 1057 EXPECT_FALSE(display_manager->IsInUnifiedMode()); |
| 1054 } | 1058 } |
| 1055 | 1059 |
| 1056 TEST_F(DisplayPreferencesTest, SaveThreeDisplays) { | 1060 TEST_F(DisplayPreferencesTest, SaveThreeDisplays) { |
| 1057 LoggedInAsUser(); | 1061 LoggedInAsUser(); |
| 1058 ash::DisplayManager* display_manager = | 1062 ash::DisplayManager* display_manager = |
| 1059 ash::Shell::GetInstance()->display_manager(); | 1063 ash::Shell::GetInstance()->display_manager(); |
| 1060 UpdateDisplay("200x200,200x200,300x300"); | 1064 UpdateDisplay("200x200,200x200,300x300"); |
| 1061 | 1065 |
| 1062 ash::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); | 1066 display::DisplayIdList list = display_manager->GetCurrentDisplayIdList(); |
| 1063 ASSERT_EQ(3u, list.size()); | 1067 ASSERT_EQ(3u, list.size()); |
| 1064 | 1068 |
| 1065 ash::DisplayLayoutBuilder builder(list[0]); | 1069 display::DisplayLayoutBuilder builder(list[0]); |
| 1066 builder.AddDisplayPlacement(list[1], list[0], ash::DisplayPlacement::RIGHT, | 1070 builder.AddDisplayPlacement(list[1], list[0], |
| 1067 0); | 1071 display::DisplayPlacement::RIGHT, 0); |
| 1068 builder.AddDisplayPlacement(list[2], list[0], ash::DisplayPlacement::BOTTOM, | 1072 builder.AddDisplayPlacement(list[2], list[0], |
| 1069 100); | 1073 display::DisplayPlacement::BOTTOM, 100); |
| 1070 display_manager->SetLayoutForCurrentDisplays(builder.Build()); | 1074 display_manager->SetLayoutForCurrentDisplays(builder.Build()); |
| 1071 | 1075 |
| 1072 const base::DictionaryValue* secondary_displays = | 1076 const base::DictionaryValue* secondary_displays = |
| 1073 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 1077 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
| 1074 const base::DictionaryValue* new_value = nullptr; | 1078 const base::DictionaryValue* new_value = nullptr; |
| 1075 EXPECT_TRUE(secondary_displays->GetDictionary( | 1079 EXPECT_TRUE(secondary_displays->GetDictionary( |
| 1076 ash::DisplayIdListToString(list), &new_value)); | 1080 ash::DisplayIdListToString(list), &new_value)); |
| 1077 } | 1081 } |
| 1078 | 1082 |
| 1079 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) { | 1083 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) { |
| 1080 LoggedInAsUser(); | 1084 LoggedInAsUser(); |
| 1081 ash::DisplayManager* display_manager = | 1085 ash::DisplayManager* display_manager = |
| 1082 ash::Shell::GetInstance()->display_manager(); | 1086 ash::Shell::GetInstance()->display_manager(); |
| 1083 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1087 int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1084 ash::DisplayIdList list = | 1088 display::DisplayIdList list = |
| 1085 ash::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2); | 1089 ash::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2); |
| 1086 | 1090 |
| 1087 ash::DisplayLayoutBuilder builder(list[0]); | 1091 display::DisplayLayoutBuilder builder(list[0]); |
| 1088 builder.AddDisplayPlacement(list[1], list[0], ash::DisplayPlacement::LEFT, 0); | 1092 builder.AddDisplayPlacement(list[1], list[0], display::DisplayPlacement::LEFT, |
| 1089 builder.AddDisplayPlacement(list[2], list[1], ash::DisplayPlacement::BOTTOM, | 1093 0); |
| 1090 100); | 1094 builder.AddDisplayPlacement(list[2], list[1], |
| 1095 display::DisplayPlacement::BOTTOM, 100); |
| 1091 StoreDisplayLayoutPrefForTest(list, *builder.Build()); | 1096 StoreDisplayLayoutPrefForTest(list, *builder.Build()); |
| 1092 LoadDisplayPreferences(false); | 1097 LoadDisplayPreferences(false); |
| 1093 | 1098 |
| 1094 UpdateDisplay("200x200,200x200,300x300"); | 1099 UpdateDisplay("200x200,200x200,300x300"); |
| 1095 ash::DisplayIdList new_list = display_manager->GetCurrentDisplayIdList(); | 1100 display::DisplayIdList new_list = display_manager->GetCurrentDisplayIdList(); |
| 1096 ASSERT_EQ(3u, list.size()); | 1101 ASSERT_EQ(3u, list.size()); |
| 1097 ASSERT_EQ(list[0], new_list[0]); | 1102 ASSERT_EQ(list[0], new_list[0]); |
| 1098 ASSERT_EQ(list[1], new_list[1]); | 1103 ASSERT_EQ(list[1], new_list[1]); |
| 1099 ASSERT_EQ(list[2], new_list[2]); | 1104 ASSERT_EQ(list[2], new_list[2]); |
| 1100 | 1105 |
| 1101 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), | 1106 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), |
| 1102 display_manager->GetDisplayForId(list[0]).bounds()); | 1107 display_manager->GetDisplayForId(list[0]).bounds()); |
| 1103 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), | 1108 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), |
| 1104 display_manager->GetDisplayForId(list[1]).bounds()); | 1109 display_manager->GetDisplayForId(list[1]).bounds()); |
| 1105 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), | 1110 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), |
| 1106 display_manager->GetDisplayForId(list[2]).bounds()); | 1111 display_manager->GetDisplayForId(list[2]).bounds()); |
| 1107 } | 1112 } |
| 1108 | 1113 |
| 1109 } // namespace chromeos | 1114 } // namespace chromeos |
| OLD | NEW |