| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/display/display_preferences.h" | 5 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); | 257 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); |
| 258 profiles.push_back(ui::COLOR_PROFILE_MOVIE); | 258 profiles.push_back(ui::COLOR_PROFILE_MOVIE); |
| 259 profiles.push_back(ui::COLOR_PROFILE_READING); | 259 profiles.push_back(ui::COLOR_PROFILE_READING); |
| 260 // Allows only |id1|. | 260 // Allows only |id1|. |
| 261 ash::test::DisplayManagerTestApi().SetAvailableColorProfiles(id1, profiles); | 261 ash::test::DisplayManagerTestApi().SetAvailableColorProfiles(id1, profiles); |
| 262 display_manager->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); | 262 display_manager->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); |
| 263 display_manager->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); | 263 display_manager->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); |
| 264 | 264 |
| 265 LoggedInAsUser(); | 265 LoggedInAsUser(); |
| 266 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); | 266 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); |
| 267 SetCurrentDisplayLayout(layout); | 267 display_manager->SetLayoutForCurrentDisplays(layout); |
| 268 StoreDisplayLayoutPrefForTest( | 268 StoreDisplayLayoutPrefForTest( |
| 269 id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); | 269 id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); |
| 270 // Can't switch to a display that does not exist. | 270 // Can't switch to a display that does not exist. |
| 271 window_tree_host_manager->SetPrimaryDisplayId(dummy_id); | 271 window_tree_host_manager->SetPrimaryDisplayId(dummy_id); |
| 272 EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); | 272 EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); |
| 273 | 273 |
| 274 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); | 274 window_tree_host_manager->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); |
| 275 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90, | 275 display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90, |
| 276 gfx::Display::ROTATION_SOURCE_USER); | 276 gfx::Display::ROTATION_SOURCE_USER); |
| 277 EXPECT_TRUE(ash::SetDisplayUIScale(id1, 1.25f)); | 277 EXPECT_TRUE(ash::SetDisplayUIScale(id1, 1.25f)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 EXPECT_EQ(layout.offset, stored_layout.offset); | 378 EXPECT_EQ(layout.offset, stored_layout.offset); |
| 379 EXPECT_EQ(id2, stored_layout.primary_id); | 379 EXPECT_EQ(id2, stored_layout.primary_id); |
| 380 | 380 |
| 381 mirrored = true; | 381 mirrored = true; |
| 382 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); | 382 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
| 383 EXPECT_FALSE(mirrored); | 383 EXPECT_FALSE(mirrored); |
| 384 std::string primary_id_str; | 384 std::string primary_id_str; |
| 385 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); | 385 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); |
| 386 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); | 386 EXPECT_EQ(base::Int64ToString(id2), primary_id_str); |
| 387 | 387 |
| 388 SetCurrentDisplayLayout( | 388 display_manager->SetLayoutForCurrentDisplays( |
| 389 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 20)); | 389 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 20)); |
| 390 | 390 |
| 391 UpdateDisplay("1+0-200x200*2,1+0-200x200"); | 391 UpdateDisplay("1+0-200x200*2,1+0-200x200"); |
| 392 // Mirrored. | 392 // Mirrored. |
| 393 int offset = 0; | 393 int offset = 0; |
| 394 std::string position; | 394 std::string position; |
| 395 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 395 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 396 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); | 396 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
| 397 EXPECT_EQ("top", position); | 397 EXPECT_EQ("top", position); |
| 398 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); | 398 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 EXPECT_EQ(200, height); | 518 EXPECT_EQ(200, height); |
| 519 } | 519 } |
| 520 | 520 |
| 521 TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { | 521 TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { |
| 522 UpdateDisplay("100x100,200x200"); | 522 UpdateDisplay("100x100,200x200"); |
| 523 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); | 523 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); |
| 524 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 524 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 525 | 525 |
| 526 ash::WindowTreeHostManager* window_tree_host_manager = | 526 ash::WindowTreeHostManager* window_tree_host_manager = |
| 527 ash::Shell::GetInstance()->window_tree_host_manager(); | 527 ash::Shell::GetInstance()->window_tree_host_manager(); |
| 528 window_tree_host_manager->SwapPrimaryDisplay(); | 528 window_tree_host_manager->SwapPrimaryDisplayForTest(); |
| 529 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); | 529 ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); |
| 530 | 530 |
| 531 LoggedInAsUser(); | 531 LoggedInAsUser(); |
| 532 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); | 532 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); |
| 533 SetCurrentDisplayLayout(layout); | 533 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 534 layout); |
| 534 layout = layout.Invert(); | 535 layout = layout.Invert(); |
| 535 | 536 |
| 536 const base::DictionaryValue* displays = | 537 const base::DictionaryValue* displays = |
| 537 local_state()->GetDictionary(prefs::kSecondaryDisplays); | 538 local_state()->GetDictionary(prefs::kSecondaryDisplays); |
| 538 const base::DictionaryValue* new_value = NULL; | 539 const base::DictionaryValue* new_value = NULL; |
| 539 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); | 540 std::string key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
| 540 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 541 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
| 541 | 542 |
| 542 ash::DisplayLayout stored_layout; | 543 ash::DisplayLayout stored_layout; |
| 543 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 544 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 544 EXPECT_EQ(layout.position, stored_layout.position); | 545 EXPECT_EQ(layout.position, stored_layout.position); |
| 545 EXPECT_EQ(layout.offset, stored_layout.offset); | 546 EXPECT_EQ(layout.offset, stored_layout.offset); |
| 546 EXPECT_EQ(id2, stored_layout.primary_id); | 547 EXPECT_EQ(id2, stored_layout.primary_id); |
| 547 | 548 |
| 548 window_tree_host_manager->SwapPrimaryDisplay(); | 549 window_tree_host_manager->SwapPrimaryDisplayForTest(); |
| 549 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); | 550 EXPECT_TRUE(displays->GetDictionary(key, &new_value)); |
| 550 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 551 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 551 EXPECT_EQ(layout.position, stored_layout.position); | 552 EXPECT_EQ(layout.position, stored_layout.position); |
| 552 EXPECT_EQ(layout.offset, stored_layout.offset); | 553 EXPECT_EQ(layout.offset, stored_layout.offset); |
| 553 EXPECT_EQ(id1, stored_layout.primary_id); | 554 EXPECT_EQ(id1, stored_layout.primary_id); |
| 554 } | 555 } |
| 555 | 556 |
| 556 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { | 557 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { |
| 557 ash::DisplayManager* display_manager = | 558 ash::DisplayManager* display_manager = |
| 558 ash::Shell::GetInstance()->display_manager(); | 559 ash::Shell::GetInstance()->display_manager(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 585 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { | 586 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { |
| 586 ash::WindowTreeHostManager* window_tree_host_manager = | 587 ash::WindowTreeHostManager* window_tree_host_manager = |
| 587 ash::Shell::GetInstance()->window_tree_host_manager(); | 588 ash::Shell::GetInstance()->window_tree_host_manager(); |
| 588 | 589 |
| 589 UpdateDisplay("200x200*2,200x200"); | 590 UpdateDisplay("200x200*2,200x200"); |
| 590 | 591 |
| 591 LoggedInAsGuest(); | 592 LoggedInAsGuest(); |
| 592 int64_t id1 = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); | 593 int64_t id1 = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); |
| 593 ash::test::ScopedSetInternalDisplayId set_internal(id1); | 594 ash::test::ScopedSetInternalDisplayId set_internal(id1); |
| 594 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 595 int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 595 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); | |
| 596 SetCurrentDisplayLayout(layout); | |
| 597 ash::DisplayManager* display_manager = | 596 ash::DisplayManager* display_manager = |
| 598 ash::Shell::GetInstance()->display_manager(); | 597 ash::Shell::GetInstance()->display_manager(); |
| 598 ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); |
| 599 display_manager->SetLayoutForCurrentDisplays(layout); |
| 599 ash::SetDisplayUIScale(id1, 1.25f); | 600 ash::SetDisplayUIScale(id1, 1.25f); |
| 600 window_tree_host_manager->SetPrimaryDisplayId(id2); | 601 window_tree_host_manager->SetPrimaryDisplayId(id2); |
| 601 int64_t new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); | 602 int64_t new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); |
| 602 window_tree_host_manager->SetOverscanInsets(new_primary, | 603 window_tree_host_manager->SetOverscanInsets(new_primary, |
| 603 gfx::Insets(10, 11, 12, 13)); | 604 gfx::Insets(10, 11, 12, 13)); |
| 604 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, | 605 display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, |
| 605 gfx::Display::ROTATION_SOURCE_USER); | 606 gfx::Display::ROTATION_SOURCE_USER); |
| 606 | 607 |
| 607 // Does not store the preferences locally. | 608 // Does not store the preferences locally. |
| 608 EXPECT_FALSE(local_state()->FindPreference( | 609 EXPECT_FALSE(local_state()->FindPreference( |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 display_manager->SetMirrorMode(false); | 927 display_manager->SetMirrorMode(false); |
| 927 ASSERT_TRUE( | 928 ASSERT_TRUE( |
| 928 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 929 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); |
| 929 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 930 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 930 EXPECT_TRUE(stored_layout.default_unified); | 931 EXPECT_TRUE(stored_layout.default_unified); |
| 931 EXPECT_FALSE(stored_layout.mirrored); | 932 EXPECT_FALSE(stored_layout.mirrored); |
| 932 | 933 |
| 933 // Exit unified mode. | 934 // Exit unified mode. |
| 934 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( | 935 display_manager->SetDefaultMultiDisplayModeForCurrentDisplays( |
| 935 ash::DisplayManager::EXTENDED); | 936 ash::DisplayManager::EXTENDED); |
| 936 display_manager->ReconfigureDisplays(); | |
| 937 ASSERT_TRUE( | 937 ASSERT_TRUE( |
| 938 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); | 938 secondary_displays->GetDictionary(ToPairString(pair), &new_value)); |
| 939 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); | 939 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*new_value, &stored_layout)); |
| 940 EXPECT_FALSE(stored_layout.default_unified); | 940 EXPECT_FALSE(stored_layout.default_unified); |
| 941 EXPECT_FALSE(stored_layout.mirrored); | 941 EXPECT_FALSE(stored_layout.mirrored); |
| 942 } | 942 } |
| 943 | 943 |
| 944 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { | 944 TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { |
| 945 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); | 945 int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); |
| 946 ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1); | 946 ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 976 // Sanity check. Restore to extended. | 976 // Sanity check. Restore to extended. |
| 977 StoreDisplayBoolPropertyForPair(pair, "default_unified", false); | 977 StoreDisplayBoolPropertyForPair(pair, "default_unified", false); |
| 978 StoreDisplayBoolPropertyForPair(pair, "mirrored", false); | 978 StoreDisplayBoolPropertyForPair(pair, "mirrored", false); |
| 979 LoadDisplayPreferences(false); | 979 LoadDisplayPreferences(false); |
| 980 UpdateDisplay("100x100,200x200"); | 980 UpdateDisplay("100x100,200x200"); |
| 981 EXPECT_FALSE(display_manager->IsInMirrorMode()); | 981 EXPECT_FALSE(display_manager->IsInMirrorMode()); |
| 982 EXPECT_FALSE(display_manager->IsInUnifiedMode()); | 982 EXPECT_FALSE(display_manager->IsInUnifiedMode()); |
| 983 } | 983 } |
| 984 | 984 |
| 985 } // namespace chromeos | 985 } // namespace chromeos |
| OLD | NEW |