| 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" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/test/ash_test_helper.h" | 13 #include "ash/test/ash_test_helper.h" |
| 14 #include "ash/test/display_manager_test_api.h" | 14 #include "ash/test/display_manager_test_api.h" |
| 15 #include "ash/test/test_user_wallpaper_delegate.h" | 15 #include "ash/test/test_user_wallpaper_delegate.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 23 #include "base/prefs/scoped_user_pref_update.h" | 23 #include "base/prefs/scoped_user_pref_update.h" |
| 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_manager.h" | |
| 28 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u
tils.h" | 27 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u
tils.h" |
| 29 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/test/base/in_process_browser_test.h" | 29 #include "chrome/test/base/in_process_browser_test.h" |
| 31 #include "chrome/test/base/testing_browser_process.h" | 30 #include "chrome/test/base/testing_browser_process.h" |
| 32 #include "chromeos/chromeos_switches.h" | 31 #include "chromeos/chromeos_switches.h" |
| 33 #include "chromeos/login/user_names.h" | 32 #include "chromeos/login/user_names.h" |
| 34 #include "components/user_manager/user.h" | 33 #include "components/user_manager/user.h" |
| 34 #include "components/user_manager/user_manager.h" |
| 35 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
| 36 #include "ui/aura/env.h" | 36 #include "ui/aura/env.h" |
| 37 #include "ui/gfx/image/image_skia.h" | 37 #include "ui/gfx/image/image_skia.h" |
| 38 #include "ui/gfx/point.h" | 38 #include "ui/gfx/point.h" |
| 39 #include "ui/gfx/rect.h" | 39 #include "ui/gfx/rect.h" |
| 40 | 40 |
| 41 using namespace ash; | 41 using namespace ash; |
| 42 | 42 |
| 43 namespace chromeos { | 43 namespace chromeos { |
| 44 | 44 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 username_hash, | 104 username_hash, |
| 105 id); | 105 id); |
| 106 if (!base::DirectoryExists(wallpaper_path.DirName())) | 106 if (!base::DirectoryExists(wallpaper_path.DirName())) |
| 107 base::CreateDirectory(wallpaper_path.DirName()); | 107 base::CreateDirectory(wallpaper_path.DirName()); |
| 108 | 108 |
| 109 return wallpaper_path; | 109 return wallpaper_path; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Logs in |username|. | 112 // Logs in |username|. |
| 113 void LogIn(const std::string& username, const std::string& username_hash) { | 113 void LogIn(const std::string& username, const std::string& username_hash) { |
| 114 UserManager::Get()->UserLoggedIn(username, username_hash, false); | 114 user_manager::UserManager::Get()->UserLoggedIn( |
| 115 username, username_hash, false); |
| 115 WaitAsyncWallpaperLoadStarted(); | 116 WaitAsyncWallpaperLoadStarted(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 int LoadedWallpapers() { | 119 int LoadedWallpapers() { |
| 119 return WallpaperManager::Get()->loaded_wallpapers(); | 120 return WallpaperManager::Get()->loaded_wallpapers(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void ClearDisposableWallpaperCache() { | 123 void ClearDisposableWallpaperCache() { |
| 123 WallpaperManager::Get()->ClearDisposableWallpaperCache(); | 124 WallpaperManager::Get()->ClearDisposableWallpaperCache(); |
| 124 } | 125 } |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 727 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 727 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 728 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 728 controller_->GetWallpaper(), | 729 controller_->GetWallpaper(), |
| 729 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 730 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
| 730 } | 731 } |
| 731 | 732 |
| 732 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { | 733 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { |
| 733 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 734 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 734 return; | 735 return; |
| 735 CreateCmdlineWallpapers(); | 736 CreateCmdlineWallpapers(); |
| 736 UserManager::Get()->UserLoggedIn( | 737 user_manager::UserManager::Get()->UserLoggedIn( |
| 737 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); | 738 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); |
| 738 UpdateDisplay("800x600"); | 739 UpdateDisplay("800x600"); |
| 739 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 740 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 740 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 741 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 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::kSmallGuestWallpaperColor)); | 744 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); |
| 744 } | 745 } |
| 745 | 746 |
| 746 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { | 747 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { |
| 747 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 748 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 748 return; | 749 return; |
| 749 | 750 |
| 750 CreateCmdlineWallpapers(); | 751 CreateCmdlineWallpapers(); |
| 751 UserManager::Get()->UserLoggedIn( | 752 user_manager::UserManager::Get()->UserLoggedIn( |
| 752 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); | 753 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); |
| 753 UpdateDisplay("1600x1200"); | 754 UpdateDisplay("1600x1200"); |
| 754 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 755 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 755 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 756 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 756 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 757 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 757 controller_->GetWallpaper(), | 758 controller_->GetWallpaper(), |
| 758 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); | 759 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); |
| 759 } | 760 } |
| 760 | 761 |
| 761 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 762 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
| 762 SwitchBetweenDefaultAndCustom) { | 763 SwitchBetweenDefaultAndCustom) { |
| 763 // Start loading the default wallpaper. | 764 // Start loading the default wallpaper. |
| 764 UpdateDisplay("640x480"); | 765 UpdateDisplay("640x480"); |
| 765 CreateCmdlineWallpapers(); | 766 CreateCmdlineWallpapers(); |
| 766 UserManager::Get()->UserLoggedIn( | 767 user_manager::UserManager::Get()->UserLoggedIn( |
| 767 chromeos::login::kStubUser, "test_hash", false); | 768 chromeos::login::kStubUser, "test_hash", false); |
| 768 | 769 |
| 769 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 770 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 770 | 771 |
| 771 // Custom wallpaper should be applied immediately, canceling the default | 772 // Custom wallpaper should be applied immediately, canceling the default |
| 772 // wallpaper load task. | 773 // wallpaper load task. |
| 773 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( | 774 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( |
| 774 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); | 775 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); |
| 775 WallpaperManager::Get()->SetCustomWallpaper(chromeos::login::kStubUser, | 776 WallpaperManager::Get()->SetCustomWallpaper(chromeos::login::kStubUser, |
| 776 "test_hash", | 777 "test_hash", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 787 | 788 |
| 788 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 789 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 789 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 790 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 790 | 791 |
| 791 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 792 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 792 controller_->GetWallpaper(), | 793 controller_->GetWallpaper(), |
| 793 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); | 794 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); |
| 794 } | 795 } |
| 795 | 796 |
| 796 } // namespace chromeos | 797 } // namespace chromeos |
| OLD | NEW |