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 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
14 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
15 #include "ash/display/display_manager.h" | |
16 #include "ash/display/display_util.h" | 15 #include "ash/display/display_util.h" |
17 #include "ash/display/json_converter.h" | 16 #include "ash/display/json_converter.h" |
18 #include "ash/display/resolution_notification_controller.h" | 17 #include "ash/display/resolution_notification_controller.h" |
19 #include "ash/display/screen_orientation_controller_chromeos.h" | 18 #include "ash/display/screen_orientation_controller_chromeos.h" |
20 #include "ash/display/window_tree_host_manager.h" | 19 #include "ash/display/window_tree_host_manager.h" |
21 #include "ash/shell.h" | 20 #include "ash/shell.h" |
22 #include "ash/shell.h" | |
23 #include "ash/test/ash_test_base.h" | 21 #include "ash/test/ash_test_base.h" |
24 #include "ash/test/display_manager_test_api.h" | |
25 #include "base/macros.h" | 22 #include "base/macros.h" |
26 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
27 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
28 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
29 #include "base/values.h" | 26 #include "base/values.h" |
30 #include "chrome/browser/chromeos/display/display_configuration_observer.h" | 27 #include "chrome/browser/chromeos/display/display_configuration_observer.h" |
31 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 28 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
32 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 29 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
33 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
34 #include "chrome/test/base/testing_browser_process.h" | 31 #include "chrome/test/base/testing_browser_process.h" |
35 #include "components/prefs/scoped_user_pref_update.h" | 32 #include "components/prefs/scoped_user_pref_update.h" |
36 #include "components/prefs/testing_pref_service.h" | 33 #include "components/prefs/testing_pref_service.h" |
37 #include "ui/display/chromeos/display_configurator.h" | 34 #include "ui/display/chromeos/display_configurator.h" |
38 #include "ui/display/manager/display_layout_builder.h" | 35 #include "ui/display/manager/display_layout_builder.h" |
39 #include "ui/display/manager/display_layout_store.h" | 36 #include "ui/display/manager/display_layout_store.h" |
| 37 #include "ui/display/manager/display_manager.h" |
40 #include "ui/display/manager/display_manager_utilities.h" | 38 #include "ui/display/manager/display_manager_utilities.h" |
41 #include "ui/display/screen.h" | 39 #include "ui/display/screen.h" |
| 40 #include "ui/display/test/display_manager_test_api.h" |
42 #include "ui/gfx/geometry/vector3d_f.h" | 41 #include "ui/gfx/geometry/vector3d_f.h" |
43 #include "ui/message_center/message_center.h" | 42 #include "ui/message_center/message_center.h" |
44 | 43 |
45 using ash::ResolutionNotificationController; | 44 using ash::ResolutionNotificationController; |
46 | 45 |
47 namespace chromeos { | 46 namespace chromeos { |
48 namespace { | 47 namespace { |
49 const char kPrimaryIdKey[] = "primary-id"; | 48 const char kPrimaryIdKey[] = "primary-id"; |
50 const char kMirroredKey[] = "mirrored"; | 49 const char kMirroredKey[] = "mirrored"; |
51 const char kPositionKey[] = "position"; | 50 const char kPositionKey[] = "position"; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); | 215 DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); |
217 }; | 216 }; |
218 | 217 |
219 } // namespace | 218 } // namespace |
220 | 219 |
221 TEST_F(DisplayPreferencesTest, ListedLayoutOverrides) { | 220 TEST_F(DisplayPreferencesTest, ListedLayoutOverrides) { |
222 UpdateDisplay("100x100,200x200"); | 221 UpdateDisplay("100x100,200x200"); |
223 | 222 |
224 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); | 223 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); |
225 display::DisplayIdList dummy_list = | 224 display::DisplayIdList dummy_list = |
226 ash::test::CreateDisplayIdList2(list[0], list[1] + 1); | 225 display::test::CreateDisplayIdList2(list[0], list[1] + 1); |
227 ASSERT_NE(list[0], dummy_list[1]); | 226 ASSERT_NE(list[0], dummy_list[1]); |
228 | 227 |
229 StoreDisplayLayoutPrefForList(list, display::DisplayPlacement::TOP, 20); | 228 StoreDisplayLayoutPrefForList(list, display::DisplayPlacement::TOP, 20); |
230 StoreDisplayLayoutPrefForList(dummy_list, display::DisplayPlacement::LEFT, | 229 StoreDisplayLayoutPrefForList(dummy_list, display::DisplayPlacement::LEFT, |
231 30); | 230 30); |
232 StoreDisplayPowerStateForTest( | 231 StoreDisplayPowerStateForTest( |
233 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); | 232 chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON); |
234 | 233 |
235 ash::Shell* shell = ash::Shell::GetInstance(); | 234 ash::Shell* shell = ash::Shell::GetInstance(); |
236 | 235 |
(...skipping 17 matching lines...) Expand all Loading... |
254 EXPECT_EQ("id=2200000002, parent=2200000000, left, 30", | 253 EXPECT_EQ("id=2200000002, parent=2200000000, left, 30", |
255 GetRegisteredDisplayPlacementStr(dummy_list)); | 254 GetRegisteredDisplayPlacementStr(dummy_list)); |
256 } | 255 } |
257 | 256 |
258 TEST_F(DisplayPreferencesTest, BasicStores) { | 257 TEST_F(DisplayPreferencesTest, BasicStores) { |
259 ash::WindowTreeHostManager* window_tree_host_manager = | 258 ash::WindowTreeHostManager* window_tree_host_manager = |
260 ash::Shell::GetInstance()->window_tree_host_manager(); | 259 ash::Shell::GetInstance()->window_tree_host_manager(); |
261 | 260 |
262 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); | 261 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); |
263 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 262 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
264 ash::test::ScopedSetInternalDisplayId set_internal(display_manager(), id1); | 263 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), |
| 264 id1); |
265 int64_t id2 = display_manager()->GetSecondaryDisplay().id(); | 265 int64_t id2 = display_manager()->GetSecondaryDisplay().id(); |
266 int64_t dummy_id = id2 + 1; | 266 int64_t dummy_id = id2 + 1; |
267 ASSERT_NE(id1, dummy_id); | 267 ASSERT_NE(id1, dummy_id); |
268 std::vector<ui::ColorCalibrationProfile> profiles; | 268 std::vector<ui::ColorCalibrationProfile> profiles; |
269 profiles.push_back(ui::COLOR_PROFILE_STANDARD); | 269 profiles.push_back(ui::COLOR_PROFILE_STANDARD); |
270 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); | 270 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); |
271 profiles.push_back(ui::COLOR_PROFILE_MOVIE); | 271 profiles.push_back(ui::COLOR_PROFILE_MOVIE); |
272 profiles.push_back(ui::COLOR_PROFILE_READING); | 272 profiles.push_back(ui::COLOR_PROFILE_READING); |
273 // Allows only |id1|. | 273 // Allows only |id1|. |
274 ash::test::DisplayManagerTestApi(display_manager()) | 274 display::test::DisplayManagerTestApi(display_manager()) |
275 .SetAvailableColorProfiles(id1, profiles); | 275 .SetAvailableColorProfiles(id1, profiles); |
276 display_manager()->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); | 276 display_manager()->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); |
277 display_manager()->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); | 277 display_manager()->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); |
278 | 278 |
279 LoggedInAsUser(); | 279 LoggedInAsUser(); |
280 | 280 |
281 display_manager()->SetLayoutForCurrentDisplays(ash::test::CreateDisplayLayout( | 281 display_manager()->SetLayoutForCurrentDisplays( |
282 display_manager(), display::DisplayPlacement::TOP, 10)); | 282 display::test::CreateDisplayLayout(display_manager(), |
| 283 display::DisplayPlacement::TOP, 10)); |
283 const display::DisplayLayout& layout = | 284 const display::DisplayLayout& layout = |
284 display_manager()->GetCurrentDisplayLayout(); | 285 display_manager()->GetCurrentDisplayLayout(); |
285 EXPECT_EQ(display::DisplayPlacement::TOP, layout.placement_list[0].position); | 286 EXPECT_EQ(display::DisplayPlacement::TOP, layout.placement_list[0].position); |
286 EXPECT_EQ(10, layout.placement_list[0].offset); | 287 EXPECT_EQ(10, layout.placement_list[0].offset); |
287 | 288 |
288 display::DisplayLayoutBuilder dummy_layout_builder(id1); | 289 display::DisplayLayoutBuilder dummy_layout_builder(id1); |
289 dummy_layout_builder.SetSecondaryPlacement( | 290 dummy_layout_builder.SetSecondaryPlacement( |
290 dummy_id, display::DisplayPlacement::LEFT, 20); | 291 dummy_id, display::DisplayPlacement::LEFT, 20); |
291 std::unique_ptr<display::DisplayLayout> dummy_layout( | 292 std::unique_ptr<display::DisplayLayout> dummy_layout( |
292 dummy_layout_builder.Build()); | 293 dummy_layout_builder.Build()); |
293 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, dummy_id); | 294 display::DisplayIdList list = |
| 295 display::test::CreateDisplayIdList2(id1, dummy_id); |
294 StoreDisplayLayoutPrefForTest(list, *dummy_layout); | 296 StoreDisplayLayoutPrefForTest(list, *dummy_layout); |
295 | 297 |
296 // Can't switch to a display that does not exist. | 298 // Can't switch to a display that does not exist. |
297 window_tree_host_manager->SetPrimaryDisplayId(dummy_id); | 299 window_tree_host_manager->SetPrimaryDisplayId(dummy_id); |
298 EXPECT_NE(dummy_id, display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 300 EXPECT_NE(dummy_id, display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
299 | 301 |
300 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); | 302 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); |
301 display_manager()->SetDisplayRotation(id1, display::Display::ROTATE_90, | 303 display_manager()->SetDisplayRotation(id1, display::Display::ROTATE_90, |
302 display::Display::ROTATION_SOURCE_USER); | 304 display::Display::ROTATION_SOURCE_USER); |
303 EXPECT_TRUE(ash::test::DisplayManagerTestApi(display_manager()) | 305 EXPECT_TRUE(display::test::DisplayManagerTestApi(display_manager()) |
304 .SetDisplayUIScale(id1, 1.25f)); | 306 .SetDisplayUIScale(id1, 1.25f)); |
305 EXPECT_FALSE(ash::test::DisplayManagerTestApi(display_manager()) | 307 EXPECT_FALSE(display::test::DisplayManagerTestApi(display_manager()) |
306 .SetDisplayUIScale(id2, 1.25f)); | 308 .SetDisplayUIScale(id2, 1.25f)); |
307 | 309 |
308 const base::DictionaryValue* displays = | 310 const base::DictionaryValue* displays = |
309 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 311 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
310 const base::DictionaryValue* layout_value = nullptr; | 312 const base::DictionaryValue* layout_value = nullptr; |
311 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); | 313 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
312 std::string dummy_key = | 314 std::string dummy_key = |
313 base::Int64ToString(id1) + "," + base::Int64ToString(dummy_id); | 315 base::Int64ToString(id1) + "," + base::Int64ToString(dummy_id); |
314 EXPECT_TRUE(displays->GetDictionary(dummy_key, &layout_value)); | 316 EXPECT_TRUE(displays->GetDictionary(dummy_key, &layout_value)); |
315 | 317 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (true) | 425 if (true) |
424 return; | 426 return; |
425 | 427 |
426 mirrored = true; | 428 mirrored = true; |
427 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); | 429 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
428 EXPECT_FALSE(mirrored); | 430 EXPECT_FALSE(mirrored); |
429 std::string primary_id_str; | 431 std::string primary_id_str; |
430 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); | 432 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); |
431 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); | 433 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); |
432 | 434 |
433 display_manager()->SetLayoutForCurrentDisplays(ash::test::CreateDisplayLayout( | 435 display_manager()->SetLayoutForCurrentDisplays( |
434 ash::Shell::GetInstance()->display_manager(), | 436 display::test::CreateDisplayLayout( |
435 display::DisplayPlacement::BOTTOM, 20)); | 437 ash::Shell::GetInstance()->display_manager(), |
| 438 display::DisplayPlacement::BOTTOM, 20)); |
436 | 439 |
437 UpdateDisplay("1+0-200x200*2,1+0-200x200"); | 440 UpdateDisplay("1+0-200x200*2,1+0-200x200"); |
438 // Mirrored. | 441 // Mirrored. |
439 int offset = 0; | 442 int offset = 0; |
440 std::string position; | 443 std::string position; |
441 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 444 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
442 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); | 445 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
443 EXPECT_EQ("bottom", position); | 446 EXPECT_EQ("bottom", position); |
444 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); | 447 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); |
445 EXPECT_EQ(20, offset); | 448 EXPECT_EQ(20, offset); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 EXPECT_EQ(display::DisplayPlacement::LEFT, stored_placement.position); | 600 EXPECT_EQ(display::DisplayPlacement::LEFT, stored_placement.position); |
598 EXPECT_EQ(0, stored_placement.offset); | 601 EXPECT_EQ(0, stored_placement.offset); |
599 EXPECT_EQ(id1, stored_placement.display_id); | 602 EXPECT_EQ(id1, stored_placement.display_id); |
600 EXPECT_EQ(id2, stored_placement.parent_display_id); | 603 EXPECT_EQ(id2, stored_placement.parent_display_id); |
601 EXPECT_EQ(id2, stored_layout.primary_id); | 604 EXPECT_EQ(id2, stored_layout.primary_id); |
602 } | 605 } |
603 | 606 |
604 // Updating layout with primary swapped should save the correct value. | 607 // Updating layout with primary swapped should save the correct value. |
605 { | 608 { |
606 display_manager()->SetLayoutForCurrentDisplays( | 609 display_manager()->SetLayoutForCurrentDisplays( |
607 ash::test::CreateDisplayLayout(display_manager(), | 610 display::test::CreateDisplayLayout(display_manager(), |
608 display::DisplayPlacement::TOP, 10)); | 611 display::DisplayPlacement::TOP, 10)); |
609 const base::DictionaryValue* new_value = nullptr; | 612 const base::DictionaryValue* new_value = nullptr; |
610 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 613 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
611 display::DisplayLayout stored_layout; | 614 display::DisplayLayout stored_layout; |
612 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 615 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
613 ASSERT_EQ(1u, stored_layout.placement_list.size()); | 616 ASSERT_EQ(1u, stored_layout.placement_list.size()); |
614 const display::DisplayPlacement& stored_placement = | 617 const display::DisplayPlacement& stored_placement = |
615 stored_layout.placement_list[0]; | 618 stored_layout.placement_list[0]; |
616 EXPECT_EQ(display::DisplayPlacement::TOP, stored_placement.position); | 619 EXPECT_EQ(display::DisplayPlacement::TOP, stored_placement.position); |
617 EXPECT_EQ(10, stored_placement.offset); | 620 EXPECT_EQ(10, stored_placement.offset); |
618 EXPECT_EQ(id1, stored_placement.display_id); | 621 EXPECT_EQ(id1, stored_placement.display_id); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 // profile suport is temporary in trouble. | 655 // profile suport is temporary in trouble. |
653 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, | 656 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, |
654 display_manager()->GetDisplayInfo(id1).color_profile()); | 657 display_manager()->GetDisplayInfo(id1).color_profile()); |
655 | 658 |
656 // Once the profile is supported, the color profile should be restored. | 659 // Once the profile is supported, the color profile should be restored. |
657 std::vector<ui::ColorCalibrationProfile> profiles; | 660 std::vector<ui::ColorCalibrationProfile> profiles; |
658 profiles.push_back(ui::COLOR_PROFILE_STANDARD); | 661 profiles.push_back(ui::COLOR_PROFILE_STANDARD); |
659 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); | 662 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); |
660 profiles.push_back(ui::COLOR_PROFILE_MOVIE); | 663 profiles.push_back(ui::COLOR_PROFILE_MOVIE); |
661 profiles.push_back(ui::COLOR_PROFILE_READING); | 664 profiles.push_back(ui::COLOR_PROFILE_READING); |
662 ash::test::DisplayManagerTestApi(ash::Shell::GetInstance()->display_manager()) | 665 display::test::DisplayManagerTestApi( |
| 666 ash::Shell::GetInstance()->display_manager()) |
663 .SetAvailableColorProfiles(id1, profiles); | 667 .SetAvailableColorProfiles(id1, profiles); |
664 | 668 |
665 LoadDisplayPreferences(false); | 669 LoadDisplayPreferences(false); |
666 EXPECT_EQ(ui::COLOR_PROFILE_DYNAMIC, | 670 EXPECT_EQ(ui::COLOR_PROFILE_DYNAMIC, |
667 display_manager()->GetDisplayInfo(id1).color_profile()); | 671 display_manager()->GetDisplayInfo(id1).color_profile()); |
668 } | 672 } |
669 | 673 |
670 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { | 674 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { |
671 ash::WindowTreeHostManager* window_tree_host_manager = | 675 ash::WindowTreeHostManager* window_tree_host_manager = |
672 ash::Shell::GetInstance()->window_tree_host_manager(); | 676 ash::Shell::GetInstance()->window_tree_host_manager(); |
673 | 677 |
674 UpdateDisplay("200x200*2,200x200"); | 678 UpdateDisplay("200x200*2,200x200"); |
675 | 679 |
676 LoggedInAsGuest(); | 680 LoggedInAsGuest(); |
677 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 681 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
678 ash::test::ScopedSetInternalDisplayId set_internal( | 682 display::test::ScopedSetInternalDisplayId set_internal( |
679 ash::Shell::GetInstance()->display_manager(), id1); | 683 ash::Shell::GetInstance()->display_manager(), id1); |
680 int64_t id2 = display_manager()->GetSecondaryDisplay().id(); | 684 int64_t id2 = display_manager()->GetSecondaryDisplay().id(); |
681 display_manager()->SetLayoutForCurrentDisplays(ash::test::CreateDisplayLayout( | 685 display_manager()->SetLayoutForCurrentDisplays( |
682 display_manager(), display::DisplayPlacement::TOP, 10)); | 686 display::test::CreateDisplayLayout(display_manager(), |
683 ash::test::DisplayManagerTestApi(display_manager()) | 687 display::DisplayPlacement::TOP, 10)); |
| 688 display::test::DisplayManagerTestApi(display_manager()) |
684 .SetDisplayUIScale(id1, 1.25f); | 689 .SetDisplayUIScale(id1, 1.25f); |
685 window_tree_host_manager->SetPrimaryDisplayId(id2); | 690 window_tree_host_manager->SetPrimaryDisplayId(id2); |
686 int64_t new_primary = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 691 int64_t new_primary = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
687 window_tree_host_manager->SetOverscanInsets(new_primary, | 692 window_tree_host_manager->SetOverscanInsets(new_primary, |
688 gfx::Insets(10, 11, 12, 13)); | 693 gfx::Insets(10, 11, 12, 13)); |
689 display_manager()->SetDisplayRotation(new_primary, | 694 display_manager()->SetDisplayRotation(new_primary, |
690 display::Display::ROTATE_90, | 695 display::Display::ROTATE_90, |
691 display::Display::ROTATION_SOURCE_USER); | 696 display::Display::ROTATION_SOURCE_USER); |
692 | 697 |
693 // Does not store the preferences locally. | 698 // Does not store the preferences locally. |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 993 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
989 EXPECT_TRUE(stored_layout.default_unified); | 994 EXPECT_TRUE(stored_layout.default_unified); |
990 EXPECT_FALSE(stored_layout.mirrored); | 995 EXPECT_FALSE(stored_layout.mirrored); |
991 | 996 |
992 const base::DictionaryValue* displays = | 997 const base::DictionaryValue* displays = |
993 local_state()->GetDictionary(prefs::kDisplayProperties); | 998 local_state()->GetDictionary(prefs::kDisplayProperties); |
994 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 999 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
995 EXPECT_FALSE( | 1000 EXPECT_FALSE( |
996 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 1001 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
997 | 1002 |
998 ash::test::SetDisplayResolution(display_manager(), unified_id, | 1003 display::test::SetDisplayResolution(display_manager(), unified_id, |
999 gfx::Size(200, 100)); | 1004 gfx::Size(200, 100)); |
1000 EXPECT_EQ( | 1005 EXPECT_EQ( |
1001 "200x100", | 1006 "200x100", |
1002 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1007 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
1003 EXPECT_FALSE( | 1008 EXPECT_FALSE( |
1004 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 1009 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
1005 | 1010 |
1006 // Mirror mode should remember if the default mode was unified. | 1011 // Mirror mode should remember if the default mode was unified. |
1007 display_manager()->SetMirrorMode(true); | 1012 display_manager()->SetMirrorMode(true); |
1008 ASSERT_TRUE(secondary_displays->GetDictionary( | 1013 ASSERT_TRUE(secondary_displays->GetDictionary( |
1009 display::DisplayIdListToString(list), &new_value)); | 1014 display::DisplayIdListToString(list), &new_value)); |
1010 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 1015 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
1011 EXPECT_TRUE(stored_layout.default_unified); | 1016 EXPECT_TRUE(stored_layout.default_unified); |
1012 EXPECT_TRUE(stored_layout.mirrored); | 1017 EXPECT_TRUE(stored_layout.mirrored); |
1013 | 1018 |
1014 display_manager()->SetMirrorMode(false); | 1019 display_manager()->SetMirrorMode(false); |
1015 ASSERT_TRUE(secondary_displays->GetDictionary( | 1020 ASSERT_TRUE(secondary_displays->GetDictionary( |
1016 display::DisplayIdListToString(list), &new_value)); | 1021 display::DisplayIdListToString(list), &new_value)); |
1017 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 1022 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
1018 EXPECT_TRUE(stored_layout.default_unified); | 1023 EXPECT_TRUE(stored_layout.default_unified); |
1019 EXPECT_FALSE(stored_layout.mirrored); | 1024 EXPECT_FALSE(stored_layout.mirrored); |
1020 | 1025 |
1021 // Exit unified mode. | 1026 // Exit unified mode. |
1022 display_manager()->SetDefaultMultiDisplayModeForCurrentDisplays( | 1027 display_manager()->SetDefaultMultiDisplayModeForCurrentDisplays( |
1023 ash::DisplayManager::EXTENDED); | 1028 display::DisplayManager::EXTENDED); |
1024 ASSERT_TRUE(secondary_displays->GetDictionary( | 1029 ASSERT_TRUE(secondary_displays->GetDictionary( |
1025 display::DisplayIdListToString(list), &new_value)); | 1030 display::DisplayIdListToString(list), &new_value)); |
1026 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 1031 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
1027 EXPECT_FALSE(stored_layout.default_unified); | 1032 EXPECT_FALSE(stored_layout.default_unified); |
1028 EXPECT_FALSE(stored_layout.mirrored); | 1033 EXPECT_FALSE(stored_layout.mirrored); |
1029 } | 1034 } |
1030 | 1035 |
1031 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { | 1036 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { |
1032 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1037 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1033 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, id1 + 1); | 1038 display::DisplayIdList list = |
| 1039 display::test::CreateDisplayIdList2(id1, id1 + 1); |
1034 StoreDisplayBoolPropertyForList(list, "default_unified", true); | 1040 StoreDisplayBoolPropertyForList(list, "default_unified", true); |
1035 StoreDisplayPropertyForList( | 1041 StoreDisplayPropertyForList( |
1036 list, "primary-id", | 1042 list, "primary-id", |
1037 base::MakeUnique<base::StringValue>(base::Int64ToString(id1))); | 1043 base::MakeUnique<base::StringValue>(base::Int64ToString(id1))); |
1038 LoadDisplayPreferences(false); | 1044 LoadDisplayPreferences(false); |
1039 | 1045 |
1040 // Should not restore to unified unless unified desktop is enabled. | 1046 // Should not restore to unified unless unified desktop is enabled. |
1041 UpdateDisplay("100x100,200x200"); | 1047 UpdateDisplay("100x100,200x200"); |
1042 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); | 1048 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); |
1043 | 1049 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 1091 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
1086 const base::DictionaryValue* new_value = nullptr; | 1092 const base::DictionaryValue* new_value = nullptr; |
1087 EXPECT_TRUE(secondary_displays->GetDictionary( | 1093 EXPECT_TRUE(secondary_displays->GetDictionary( |
1088 display::DisplayIdListToString(list), &new_value)); | 1094 display::DisplayIdListToString(list), &new_value)); |
1089 } | 1095 } |
1090 | 1096 |
1091 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) { | 1097 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) { |
1092 LoggedInAsUser(); | 1098 LoggedInAsUser(); |
1093 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1099 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1094 display::DisplayIdList list = | 1100 display::DisplayIdList list = |
1095 ash::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2); | 1101 display::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2); |
1096 | 1102 |
1097 display::DisplayLayoutBuilder builder(list[0]); | 1103 display::DisplayLayoutBuilder builder(list[0]); |
1098 builder.AddDisplayPlacement(list[1], list[0], display::DisplayPlacement::LEFT, | 1104 builder.AddDisplayPlacement(list[1], list[0], display::DisplayPlacement::LEFT, |
1099 0); | 1105 0); |
1100 builder.AddDisplayPlacement(list[2], list[1], | 1106 builder.AddDisplayPlacement(list[2], list[1], |
1101 display::DisplayPlacement::BOTTOM, 100); | 1107 display::DisplayPlacement::BOTTOM, 100); |
1102 StoreDisplayLayoutPrefForTest(list, *builder.Build()); | 1108 StoreDisplayLayoutPrefForTest(list, *builder.Build()); |
1103 LoadDisplayPreferences(false); | 1109 LoadDisplayPreferences(false); |
1104 | 1110 |
1105 UpdateDisplay("200x200,200x200,300x300"); | 1111 UpdateDisplay("200x200,200x200,300x300"); |
1106 display::DisplayIdList new_list = | 1112 display::DisplayIdList new_list = |
1107 display_manager()->GetCurrentDisplayIdList(); | 1113 display_manager()->GetCurrentDisplayIdList(); |
1108 ASSERT_EQ(3u, list.size()); | 1114 ASSERT_EQ(3u, list.size()); |
1109 ASSERT_EQ(list[0], new_list[0]); | 1115 ASSERT_EQ(list[0], new_list[0]); |
1110 ASSERT_EQ(list[1], new_list[1]); | 1116 ASSERT_EQ(list[1], new_list[1]); |
1111 ASSERT_EQ(list[2], new_list[2]); | 1117 ASSERT_EQ(list[2], new_list[2]); |
1112 | 1118 |
1113 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), | 1119 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), |
1114 display_manager()->GetDisplayForId(list[0]).bounds()); | 1120 display_manager()->GetDisplayForId(list[0]).bounds()); |
1115 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), | 1121 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), |
1116 display_manager()->GetDisplayForId(list[1]).bounds()); | 1122 display_manager()->GetDisplayForId(list[1]).bounds()); |
1117 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), | 1123 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), |
1118 display_manager()->GetDisplayForId(list[2]).bounds()); | 1124 display_manager()->GetDisplayForId(list[2]).bounds()); |
1119 } | 1125 } |
1120 | 1126 |
1121 } // namespace chromeos | 1127 } // namespace chromeos |
OLD | NEW |