| 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(display_manager()->SetDisplayUIScale(id1, 1.25f)); | 305 EXPECT_TRUE(display_manager()->SetDisplayUIScale(id1, 1.25f)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 if (true) | 423 if (true) |
| 422 return; | 424 return; |
| 423 | 425 |
| 424 mirrored = true; | 426 mirrored = true; |
| 425 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); | 427 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
| 426 EXPECT_FALSE(mirrored); | 428 EXPECT_FALSE(mirrored); |
| 427 std::string primary_id_str; | 429 std::string primary_id_str; |
| 428 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); | 430 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); |
| 429 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); | 431 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); |
| 430 | 432 |
| 431 display_manager()->SetLayoutForCurrentDisplays(ash::test::CreateDisplayLayout( | 433 display_manager()->SetLayoutForCurrentDisplays( |
| 432 ash::Shell::GetInstance()->display_manager(), | 434 display::test::CreateDisplayLayout( |
| 433 display::DisplayPlacement::BOTTOM, 20)); | 435 ash::Shell::GetInstance()->display_manager(), |
| 436 display::DisplayPlacement::BOTTOM, 20)); |
| 434 | 437 |
| 435 UpdateDisplay("1+0-200x200*2,1+0-200x200"); | 438 UpdateDisplay("1+0-200x200*2,1+0-200x200"); |
| 436 // Mirrored. | 439 // Mirrored. |
| 437 int offset = 0; | 440 int offset = 0; |
| 438 std::string position; | 441 std::string position; |
| 439 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 442 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 440 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); | 443 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
| 441 EXPECT_EQ("bottom", position); | 444 EXPECT_EQ("bottom", position); |
| 442 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); | 445 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); |
| 443 EXPECT_EQ(20, offset); | 446 EXPECT_EQ(20, offset); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 EXPECT_EQ(display::DisplayPlacement::LEFT, stored_placement.position); | 598 EXPECT_EQ(display::DisplayPlacement::LEFT, stored_placement.position); |
| 596 EXPECT_EQ(0, stored_placement.offset); | 599 EXPECT_EQ(0, stored_placement.offset); |
| 597 EXPECT_EQ(id1, stored_placement.display_id); | 600 EXPECT_EQ(id1, stored_placement.display_id); |
| 598 EXPECT_EQ(id2, stored_placement.parent_display_id); | 601 EXPECT_EQ(id2, stored_placement.parent_display_id); |
| 599 EXPECT_EQ(id2, stored_layout.primary_id); | 602 EXPECT_EQ(id2, stored_layout.primary_id); |
| 600 } | 603 } |
| 601 | 604 |
| 602 // Updating layout with primary swapped should save the correct value. | 605 // Updating layout with primary swapped should save the correct value. |
| 603 { | 606 { |
| 604 display_manager()->SetLayoutForCurrentDisplays( | 607 display_manager()->SetLayoutForCurrentDisplays( |
| 605 ash::test::CreateDisplayLayout(display_manager(), | 608 display::test::CreateDisplayLayout(display_manager(), |
| 606 display::DisplayPlacement::TOP, 10)); | 609 display::DisplayPlacement::TOP, 10)); |
| 607 const base::DictionaryValue* new_value = nullptr; | 610 const base::DictionaryValue* new_value = nullptr; |
| 608 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 611 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
| 609 display::DisplayLayout stored_layout; | 612 display::DisplayLayout stored_layout; |
| 610 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 613 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 611 ASSERT_EQ(1u, stored_layout.placement_list.size()); | 614 ASSERT_EQ(1u, stored_layout.placement_list.size()); |
| 612 const display::DisplayPlacement& stored_placement = | 615 const display::DisplayPlacement& stored_placement = |
| 613 stored_layout.placement_list[0]; | 616 stored_layout.placement_list[0]; |
| 614 EXPECT_EQ(display::DisplayPlacement::TOP, stored_placement.position); | 617 EXPECT_EQ(display::DisplayPlacement::TOP, stored_placement.position); |
| 615 EXPECT_EQ(10, stored_placement.offset); | 618 EXPECT_EQ(10, stored_placement.offset); |
| 616 EXPECT_EQ(id1, stored_placement.display_id); | 619 EXPECT_EQ(id1, stored_placement.display_id); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 // profile suport is temporary in trouble. | 653 // profile suport is temporary in trouble. |
| 651 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, | 654 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, |
| 652 display_manager()->GetDisplayInfo(id1).color_profile()); | 655 display_manager()->GetDisplayInfo(id1).color_profile()); |
| 653 | 656 |
| 654 // Once the profile is supported, the color profile should be restored. | 657 // Once the profile is supported, the color profile should be restored. |
| 655 std::vector<ui::ColorCalibrationProfile> profiles; | 658 std::vector<ui::ColorCalibrationProfile> profiles; |
| 656 profiles.push_back(ui::COLOR_PROFILE_STANDARD); | 659 profiles.push_back(ui::COLOR_PROFILE_STANDARD); |
| 657 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); | 660 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); |
| 658 profiles.push_back(ui::COLOR_PROFILE_MOVIE); | 661 profiles.push_back(ui::COLOR_PROFILE_MOVIE); |
| 659 profiles.push_back(ui::COLOR_PROFILE_READING); | 662 profiles.push_back(ui::COLOR_PROFILE_READING); |
| 660 ash::test::DisplayManagerTestApi(ash::Shell::GetInstance()->display_manager()) | 663 display::test::DisplayManagerTestApi( |
| 664 ash::Shell::GetInstance()->display_manager()) |
| 661 .SetAvailableColorProfiles(id1, profiles); | 665 .SetAvailableColorProfiles(id1, profiles); |
| 662 | 666 |
| 663 LoadDisplayPreferences(false); | 667 LoadDisplayPreferences(false); |
| 664 EXPECT_EQ(ui::COLOR_PROFILE_DYNAMIC, | 668 EXPECT_EQ(ui::COLOR_PROFILE_DYNAMIC, |
| 665 display_manager()->GetDisplayInfo(id1).color_profile()); | 669 display_manager()->GetDisplayInfo(id1).color_profile()); |
| 666 } | 670 } |
| 667 | 671 |
| 668 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { | 672 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { |
| 669 ash::WindowTreeHostManager* window_tree_host_manager = | 673 ash::WindowTreeHostManager* window_tree_host_manager = |
| 670 ash::Shell::GetInstance()->window_tree_host_manager(); | 674 ash::Shell::GetInstance()->window_tree_host_manager(); |
| 671 | 675 |
| 672 UpdateDisplay("200x200*2,200x200"); | 676 UpdateDisplay("200x200*2,200x200"); |
| 673 | 677 |
| 674 LoggedInAsGuest(); | 678 LoggedInAsGuest(); |
| 675 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 679 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 676 ash::test::ScopedSetInternalDisplayId set_internal( | 680 display::test::ScopedSetInternalDisplayId set_internal( |
| 677 ash::Shell::GetInstance()->display_manager(), id1); | 681 ash::Shell::GetInstance()->display_manager(), id1); |
| 678 int64_t id2 = display_manager()->GetSecondaryDisplay().id(); | 682 int64_t id2 = display_manager()->GetSecondaryDisplay().id(); |
| 679 display_manager()->SetLayoutForCurrentDisplays(ash::test::CreateDisplayLayout( | 683 display_manager()->SetLayoutForCurrentDisplays( |
| 680 display_manager(), display::DisplayPlacement::TOP, 10)); | 684 display::test::CreateDisplayLayout(display_manager(), |
| 685 display::DisplayPlacement::TOP, 10)); |
| 681 display_manager()->SetDisplayUIScale(id1, 1.25f); | 686 display_manager()->SetDisplayUIScale(id1, 1.25f); |
| 682 window_tree_host_manager->SetPrimaryDisplayId(id2); | 687 window_tree_host_manager->SetPrimaryDisplayId(id2); |
| 683 int64_t new_primary = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 688 int64_t new_primary = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 684 window_tree_host_manager->SetOverscanInsets(new_primary, | 689 window_tree_host_manager->SetOverscanInsets(new_primary, |
| 685 gfx::Insets(10, 11, 12, 13)); | 690 gfx::Insets(10, 11, 12, 13)); |
| 686 display_manager()->SetDisplayRotation(new_primary, | 691 display_manager()->SetDisplayRotation(new_primary, |
| 687 display::Display::ROTATE_90, | 692 display::Display::ROTATE_90, |
| 688 display::Display::ROTATION_SOURCE_USER); | 693 display::Display::ROTATION_SOURCE_USER); |
| 689 | 694 |
| 690 // Does not store the preferences locally. | 695 // Does not store the preferences locally. |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 990 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 986 EXPECT_TRUE(stored_layout.default_unified); | 991 EXPECT_TRUE(stored_layout.default_unified); |
| 987 EXPECT_FALSE(stored_layout.mirrored); | 992 EXPECT_FALSE(stored_layout.mirrored); |
| 988 | 993 |
| 989 const base::DictionaryValue* displays = | 994 const base::DictionaryValue* displays = |
| 990 local_state()->GetDictionary(prefs::kDisplayProperties); | 995 local_state()->GetDictionary(prefs::kDisplayProperties); |
| 991 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 996 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 992 EXPECT_FALSE( | 997 EXPECT_FALSE( |
| 993 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 998 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
| 994 | 999 |
| 995 ash::test::SetDisplayResolution(display_manager(), unified_id, | 1000 display::test::SetDisplayResolution(display_manager(), unified_id, |
| 996 gfx::Size(200, 100)); | 1001 gfx::Size(200, 100)); |
| 997 EXPECT_EQ( | 1002 EXPECT_EQ( |
| 998 "200x100", | 1003 "200x100", |
| 999 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1004 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
| 1000 EXPECT_FALSE( | 1005 EXPECT_FALSE( |
| 1001 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); | 1006 displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); |
| 1002 | 1007 |
| 1003 // Mirror mode should remember if the default mode was unified. | 1008 // Mirror mode should remember if the default mode was unified. |
| 1004 display_manager()->SetMirrorMode(true); | 1009 display_manager()->SetMirrorMode(true); |
| 1005 ASSERT_TRUE(secondary_displays->GetDictionary( | 1010 ASSERT_TRUE(secondary_displays->GetDictionary( |
| 1006 display::DisplayIdListToString(list), &new_value)); | 1011 display::DisplayIdListToString(list), &new_value)); |
| 1007 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 1012 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 1008 EXPECT_TRUE(stored_layout.default_unified); | 1013 EXPECT_TRUE(stored_layout.default_unified); |
| 1009 EXPECT_TRUE(stored_layout.mirrored); | 1014 EXPECT_TRUE(stored_layout.mirrored); |
| 1010 | 1015 |
| 1011 display_manager()->SetMirrorMode(false); | 1016 display_manager()->SetMirrorMode(false); |
| 1012 ASSERT_TRUE(secondary_displays->GetDictionary( | 1017 ASSERT_TRUE(secondary_displays->GetDictionary( |
| 1013 display::DisplayIdListToString(list), &new_value)); | 1018 display::DisplayIdListToString(list), &new_value)); |
| 1014 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 1019 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 1015 EXPECT_TRUE(stored_layout.default_unified); | 1020 EXPECT_TRUE(stored_layout.default_unified); |
| 1016 EXPECT_FALSE(stored_layout.mirrored); | 1021 EXPECT_FALSE(stored_layout.mirrored); |
| 1017 | 1022 |
| 1018 // Exit unified mode. | 1023 // Exit unified mode. |
| 1019 display_manager()->SetDefaultMultiDisplayModeForCurrentDisplays( | 1024 display_manager()->SetDefaultMultiDisplayModeForCurrentDisplays( |
| 1020 ash::DisplayManager::EXTENDED); | 1025 display::DisplayManager::EXTENDED); |
| 1021 ASSERT_TRUE(secondary_displays->GetDictionary( | 1026 ASSERT_TRUE(secondary_displays->GetDictionary( |
| 1022 display::DisplayIdListToString(list), &new_value)); | 1027 display::DisplayIdListToString(list), &new_value)); |
| 1023 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); | 1028 EXPECT_TRUE(ash::JsonToDisplayLayout(*new_value, &stored_layout)); |
| 1024 EXPECT_FALSE(stored_layout.default_unified); | 1029 EXPECT_FALSE(stored_layout.default_unified); |
| 1025 EXPECT_FALSE(stored_layout.mirrored); | 1030 EXPECT_FALSE(stored_layout.mirrored); |
| 1026 } | 1031 } |
| 1027 | 1032 |
| 1028 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { | 1033 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { |
| 1029 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1034 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1030 display::DisplayIdList list = ash::test::CreateDisplayIdList2(id1, id1 + 1); | 1035 display::DisplayIdList list = |
| 1036 display::test::CreateDisplayIdList2(id1, id1 + 1); |
| 1031 StoreDisplayBoolPropertyForList(list, "default_unified", true); | 1037 StoreDisplayBoolPropertyForList(list, "default_unified", true); |
| 1032 StoreDisplayPropertyForList( | 1038 StoreDisplayPropertyForList( |
| 1033 list, "primary-id", | 1039 list, "primary-id", |
| 1034 base::MakeUnique<base::StringValue>(base::Int64ToString(id1))); | 1040 base::MakeUnique<base::StringValue>(base::Int64ToString(id1))); |
| 1035 LoadDisplayPreferences(false); | 1041 LoadDisplayPreferences(false); |
| 1036 | 1042 |
| 1037 // Should not restore to unified unless unified desktop is enabled. | 1043 // Should not restore to unified unless unified desktop is enabled. |
| 1038 UpdateDisplay("100x100,200x200"); | 1044 UpdateDisplay("100x100,200x200"); |
| 1039 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); | 1045 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); |
| 1040 | 1046 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 1088 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
| 1083 const base::DictionaryValue* new_value = nullptr; | 1089 const base::DictionaryValue* new_value = nullptr; |
| 1084 EXPECT_TRUE(secondary_displays->GetDictionary( | 1090 EXPECT_TRUE(secondary_displays->GetDictionary( |
| 1085 display::DisplayIdListToString(list), &new_value)); | 1091 display::DisplayIdListToString(list), &new_value)); |
| 1086 } | 1092 } |
| 1087 | 1093 |
| 1088 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) { | 1094 TEST_F(DisplayPreferencesTest, RestoreThreeDisplays) { |
| 1089 LoggedInAsUser(); | 1095 LoggedInAsUser(); |
| 1090 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1096 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1091 display::DisplayIdList list = | 1097 display::DisplayIdList list = |
| 1092 ash::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2); | 1098 display::test::CreateDisplayIdListN(3, id1, id1 + 1, id1 + 2); |
| 1093 | 1099 |
| 1094 display::DisplayLayoutBuilder builder(list[0]); | 1100 display::DisplayLayoutBuilder builder(list[0]); |
| 1095 builder.AddDisplayPlacement(list[1], list[0], display::DisplayPlacement::LEFT, | 1101 builder.AddDisplayPlacement(list[1], list[0], display::DisplayPlacement::LEFT, |
| 1096 0); | 1102 0); |
| 1097 builder.AddDisplayPlacement(list[2], list[1], | 1103 builder.AddDisplayPlacement(list[2], list[1], |
| 1098 display::DisplayPlacement::BOTTOM, 100); | 1104 display::DisplayPlacement::BOTTOM, 100); |
| 1099 StoreDisplayLayoutPrefForTest(list, *builder.Build()); | 1105 StoreDisplayLayoutPrefForTest(list, *builder.Build()); |
| 1100 LoadDisplayPreferences(false); | 1106 LoadDisplayPreferences(false); |
| 1101 | 1107 |
| 1102 UpdateDisplay("200x200,200x200,300x300"); | 1108 UpdateDisplay("200x200,200x200,300x300"); |
| 1103 display::DisplayIdList new_list = | 1109 display::DisplayIdList new_list = |
| 1104 display_manager()->GetCurrentDisplayIdList(); | 1110 display_manager()->GetCurrentDisplayIdList(); |
| 1105 ASSERT_EQ(3u, list.size()); | 1111 ASSERT_EQ(3u, list.size()); |
| 1106 ASSERT_EQ(list[0], new_list[0]); | 1112 ASSERT_EQ(list[0], new_list[0]); |
| 1107 ASSERT_EQ(list[1], new_list[1]); | 1113 ASSERT_EQ(list[1], new_list[1]); |
| 1108 ASSERT_EQ(list[2], new_list[2]); | 1114 ASSERT_EQ(list[2], new_list[2]); |
| 1109 | 1115 |
| 1110 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), | 1116 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), |
| 1111 display_manager()->GetDisplayForId(list[0]).bounds()); | 1117 display_manager()->GetDisplayForId(list[0]).bounds()); |
| 1112 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), | 1118 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), |
| 1113 display_manager()->GetDisplayForId(list[1]).bounds()); | 1119 display_manager()->GetDisplayForId(list[1]).bounds()); |
| 1114 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), | 1120 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), |
| 1115 display_manager()->GetDisplayForId(list[2]).bounds()); | 1121 display_manager()->GetDisplayForId(list[2]).bounds()); |
| 1116 } | 1122 } |
| 1117 | 1123 |
| 1118 } // namespace chromeos | 1124 } // namespace chromeos |
| OLD | NEW |