| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/login/users/wallpaper/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 6 | 6 |
| 7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
| 8 #include "ash/desktop_background/desktop_background_controller_observer.h" | 8 #include "ash/desktop_background/desktop_background_controller_observer.h" |
| 9 #include "ash/desktop_background/desktop_background_controller_test_api.h" | 9 #include "ash/desktop_background/desktop_background_controller_test_api.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "chrome/browser/chromeos/login/users/user.h" | 27 #include "chrome/browser/chromeos/login/users/user.h" |
| 28 #include "chrome/browser/chromeos/login/users/user_manager.h" | 28 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 29 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u
tils.h" | 29 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u
tils.h" |
| 30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/test/base/in_process_browser_test.h" | 31 #include "chrome/test/base/in_process_browser_test.h" |
| 32 #include "chrome/test/base/testing_browser_process.h" | 32 #include "chrome/test/base/testing_browser_process.h" |
| 33 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
| 34 #include "chromeos/login/user_names.h" |
| 34 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
| 35 #include "ui/aura/env.h" | 36 #include "ui/aura/env.h" |
| 36 #include "ui/gfx/image/image_skia.h" | 37 #include "ui/gfx/image/image_skia.h" |
| 37 #include "ui/gfx/point.h" | 38 #include "ui/gfx/point.h" |
| 38 #include "ui/gfx/rect.h" | 39 #include "ui/gfx/rect.h" |
| 39 | 40 |
| 40 using namespace ash; | 41 using namespace ash; |
| 41 | 42 |
| 42 namespace chromeos { | 43 namespace chromeos { |
| 43 | 44 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // This test should finish normally. If timeout, it is probably because chrome | 338 // This test should finish normally. If timeout, it is probably because chrome |
| 338 // can not handle pre migrated user profile (M21 profile or older). | 339 // can not handle pre migrated user profile (M21 profile or older). |
| 339 } | 340 } |
| 340 | 341 |
| 341 // Test for http://crbug.com/265689. When hooked up a large external monitor, | 342 // Test for http://crbug.com/265689. When hooked up a large external monitor, |
| 342 // the default large resolution wallpaper should load. | 343 // the default large resolution wallpaper should load. |
| 343 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 344 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
| 344 HotPlugInScreenAtGAIALoginScreen) { | 345 HotPlugInScreenAtGAIALoginScreen) { |
| 345 UpdateDisplay("800x600"); | 346 UpdateDisplay("800x600"); |
| 346 // Set initial wallpaper to the default wallpaper. | 347 // Set initial wallpaper to the default wallpaper. |
| 347 WallpaperManager::Get()->SetDefaultWallpaperNow(UserManager::kStubUser); | 348 WallpaperManager::Get()->SetDefaultWallpaperNow(chromeos::login::kStubUser); |
| 348 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 349 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 349 | 350 |
| 350 // Hook up a 2000x2000 display. The large resolution custom wallpaper should | 351 // Hook up a 2000x2000 display. The large resolution custom wallpaper should |
| 351 // be loaded. | 352 // be loaded. |
| 352 UpdateDisplay("800x600,2000x2000"); | 353 UpdateDisplay("800x600,2000x2000"); |
| 353 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 354 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 354 } | 355 } |
| 355 | 356 |
| 356 class WallpaperManagerBrowserTestNoAnimation | 357 class WallpaperManagerBrowserTestNoAnimation |
| 357 : public WallpaperManagerBrowserTest { | 358 : public WallpaperManagerBrowserTest { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 742 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 742 controller_->GetWallpaper(), | 743 controller_->GetWallpaper(), |
| 743 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 744 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
| 744 } | 745 } |
| 745 | 746 |
| 746 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { | 747 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { |
| 747 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 748 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 748 return; | 749 return; |
| 749 CreateCmdlineWallpapers(); | 750 CreateCmdlineWallpapers(); |
| 750 UserManager::Get()->UserLoggedIn( | 751 UserManager::Get()->UserLoggedIn( |
| 751 UserManager::kGuestUserName, UserManager::kGuestUserName, false); | 752 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); |
| 752 UpdateDisplay("800x600"); | 753 UpdateDisplay("800x600"); |
| 753 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 754 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 754 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 755 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 755 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 756 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 756 controller_->GetWallpaper(), | 757 controller_->GetWallpaper(), |
| 757 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); | 758 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); |
| 758 } | 759 } |
| 759 | 760 |
| 760 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { | 761 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { |
| 761 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 762 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 762 return; | 763 return; |
| 763 | 764 |
| 764 CreateCmdlineWallpapers(); | 765 CreateCmdlineWallpapers(); |
| 765 UserManager::Get()->UserLoggedIn( | 766 UserManager::Get()->UserLoggedIn( |
| 766 UserManager::kGuestUserName, UserManager::kGuestUserName, false); | 767 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); |
| 767 UpdateDisplay("1600x1200"); | 768 UpdateDisplay("1600x1200"); |
| 768 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 769 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 769 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 770 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 770 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 771 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 771 controller_->GetWallpaper(), | 772 controller_->GetWallpaper(), |
| 772 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); | 773 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); |
| 773 } | 774 } |
| 774 | 775 |
| 775 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 776 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
| 776 SwitchBetweenDefaultAndCustom) { | 777 SwitchBetweenDefaultAndCustom) { |
| 777 // Start loading the default wallpaper. | 778 // Start loading the default wallpaper. |
| 778 UpdateDisplay("640x480"); | 779 UpdateDisplay("640x480"); |
| 779 CreateCmdlineWallpapers(); | 780 CreateCmdlineWallpapers(); |
| 780 UserManager::Get()->UserLoggedIn(UserManager::kStubUser, "test_hash", false); | 781 UserManager::Get()->UserLoggedIn( |
| 782 chromeos::login::kStubUser, "test_hash", false); |
| 781 | 783 |
| 782 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 784 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 783 | 785 |
| 784 // Custom wallpaper should be applied immediately, canceling the default | 786 // Custom wallpaper should be applied immediately, canceling the default |
| 785 // wallpaper load task. | 787 // wallpaper load task. |
| 786 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( | 788 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( |
| 787 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); | 789 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); |
| 788 WallpaperManager::Get()->SetCustomWallpaper(UserManager::kStubUser, | 790 WallpaperManager::Get()->SetCustomWallpaper(chromeos::login::kStubUser, |
| 789 "test_hash", | 791 "test_hash", |
| 790 "test-nofile.jpeg", | 792 "test-nofile.jpeg", |
| 791 WALLPAPER_LAYOUT_STRETCH, | 793 WALLPAPER_LAYOUT_STRETCH, |
| 792 User::CUSTOMIZED, | 794 User::CUSTOMIZED, |
| 793 image, | 795 image, |
| 794 true); | 796 true); |
| 795 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 797 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 796 | 798 |
| 797 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 799 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 798 controller_->GetWallpaper(), | 800 controller_->GetWallpaper(), |
| 799 wallpaper_manager_test_utils::kCustomWallpaperColor)); | 801 wallpaper_manager_test_utils::kCustomWallpaperColor)); |
| 800 | 802 |
| 801 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 803 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 802 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 804 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 803 | 805 |
| 804 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 806 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 805 controller_->GetWallpaper(), | 807 controller_->GetWallpaper(), |
| 806 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); | 808 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); |
| 807 } | 809 } |
| 808 | 810 |
| 809 } // namespace chromeos | 811 } // namespace chromeos |
| OLD | NEW |