| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/common/wallpaper/wallpaper_controller.h" | 9 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "base/values.h" | 25 #include "base/values.h" |
| 26 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u
tils.h" | 26 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_u
tils.h" |
| 27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/test/base/in_process_browser_test.h" | 28 #include "chrome/test/base/in_process_browser_test.h" |
| 29 #include "chrome/test/base/testing_browser_process.h" | 29 #include "chrome/test/base/testing_browser_process.h" |
| 30 #include "chromeos/chromeos_switches.h" | 30 #include "chromeos/chromeos_switches.h" |
| 31 #include "chromeos/login/user_names.h" | |
| 32 #include "components/prefs/scoped_user_pref_update.h" | 31 #include "components/prefs/scoped_user_pref_update.h" |
| 33 #include "components/signin/core/account_id/account_id.h" | 32 #include "components/signin/core/account_id/account_id.h" |
| 34 #include "components/user_manager/user.h" | 33 #include "components/user_manager/user.h" |
| 35 #include "components/user_manager/user_manager.h" | 34 #include "components/user_manager/user_manager.h" |
| 35 #include "components/user_manager/user_names.h" |
| 36 #include "components/wallpaper/wallpaper_files_id.h" | 36 #include "components/wallpaper/wallpaper_files_id.h" |
| 37 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
| 38 #include "ui/aura/env.h" | 38 #include "ui/aura/env.h" |
| 39 #include "ui/gfx/geometry/point.h" | 39 #include "ui/gfx/geometry/point.h" |
| 40 #include "ui/gfx/geometry/rect.h" | 40 #include "ui/gfx/geometry/rect.h" |
| 41 #include "ui/gfx/image/image_skia.h" | 41 #include "ui/gfx/image/image_skia.h" |
| 42 | 42 |
| 43 using wallpaper::WallpaperInfo; | 43 using wallpaper::WallpaperInfo; |
| 44 using wallpaper::WALLPAPER_LAYOUT_CENTER; | 44 using wallpaper::WALLPAPER_LAYOUT_CENTER; |
| 45 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; | 45 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // This test should finish normally. If timeout, it is probably because chrome | 360 // This test should finish normally. If timeout, it is probably because chrome |
| 361 // can not handle pre migrated user profile (M21 profile or older). | 361 // can not handle pre migrated user profile (M21 profile or older). |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Test for http://crbug.com/265689. When hooked up a large external monitor, | 364 // Test for http://crbug.com/265689. When hooked up a large external monitor, |
| 365 // the default large resolution wallpaper should load. | 365 // the default large resolution wallpaper should load. |
| 366 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 366 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
| 367 HotPlugInScreenAtGAIALoginScreen) { | 367 HotPlugInScreenAtGAIALoginScreen) { |
| 368 UpdateDisplay("800x600"); | 368 UpdateDisplay("800x600"); |
| 369 // Set initial wallpaper to the default wallpaper. | 369 // Set initial wallpaper to the default wallpaper. |
| 370 WallpaperManager::Get()->SetDefaultWallpaperNow(login::StubAccountId()); | 370 WallpaperManager::Get()->SetDefaultWallpaperNow( |
| 371 user_manager::chromeos::StubAccountId()); |
| 371 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 372 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 372 | 373 |
| 373 // Hook up a 2000x2000 display. The large resolution custom wallpaper should | 374 // Hook up a 2000x2000 display. The large resolution custom wallpaper should |
| 374 // be loaded. | 375 // be loaded. |
| 375 UpdateDisplay("800x600,2000x2000"); | 376 UpdateDisplay("800x600,2000x2000"); |
| 376 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 377 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 377 } | 378 } |
| 378 | 379 |
| 379 class WallpaperManagerBrowserTestNoAnimation | 380 class WallpaperManagerBrowserTestNoAnimation |
| 380 : public WallpaperManagerBrowserTest { | 381 : public WallpaperManagerBrowserTest { |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 760 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 760 controller_->GetWallpaper(), | 761 controller_->GetWallpaper(), |
| 761 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 762 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
| 762 } | 763 } |
| 763 | 764 |
| 764 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { | 765 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { |
| 765 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 766 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 766 return; | 767 return; |
| 767 CreateCmdlineWallpapers(); | 768 CreateCmdlineWallpapers(); |
| 768 user_manager::UserManager::Get()->UserLoggedIn( | 769 user_manager::UserManager::Get()->UserLoggedIn( |
| 769 chromeos::login::GuestAccountId(), chromeos::login::kGuestUserName, | 770 user_manager::chromeos::GuestAccountId(), |
| 770 false); | 771 user_manager::chromeos::kGuestUserName, false); |
| 771 UpdateDisplay("800x600"); | 772 UpdateDisplay("800x600"); |
| 772 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 773 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 773 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 774 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 774 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 775 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 775 controller_->GetWallpaper(), | 776 controller_->GetWallpaper(), |
| 776 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); | 777 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); |
| 777 } | 778 } |
| 778 | 779 |
| 779 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { | 780 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { |
| 780 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 781 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 781 return; | 782 return; |
| 782 | 783 |
| 783 CreateCmdlineWallpapers(); | 784 CreateCmdlineWallpapers(); |
| 784 user_manager::UserManager::Get()->UserLoggedIn( | 785 user_manager::UserManager::Get()->UserLoggedIn( |
| 785 chromeos::login::GuestAccountId(), chromeos::login::kGuestUserName, | 786 user_manager::chromeos::GuestAccountId(), |
| 786 false); | 787 user_manager::chromeos::kGuestUserName, false); |
| 787 UpdateDisplay("1600x1200"); | 788 UpdateDisplay("1600x1200"); |
| 788 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 789 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 789 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 790 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 790 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 791 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 791 controller_->GetWallpaper(), | 792 controller_->GetWallpaper(), |
| 792 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); | 793 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); |
| 793 } | 794 } |
| 794 | 795 |
| 795 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallChildWallpaper) { | 796 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallChildWallpaper) { |
| 796 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 797 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 818 controller_->GetWallpaper(), | 819 controller_->GetWallpaper(), |
| 819 wallpaper_manager_test_utils::kLargeChildWallpaperColor)); | 820 wallpaper_manager_test_utils::kLargeChildWallpaperColor)); |
| 820 } | 821 } |
| 821 | 822 |
| 822 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 823 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
| 823 SwitchBetweenDefaultAndCustom) { | 824 SwitchBetweenDefaultAndCustom) { |
| 824 // Start loading the default wallpaper. | 825 // Start loading the default wallpaper. |
| 825 UpdateDisplay("640x480"); | 826 UpdateDisplay("640x480"); |
| 826 CreateCmdlineWallpapers(); | 827 CreateCmdlineWallpapers(); |
| 827 user_manager::UserManager::Get()->UserLoggedIn( | 828 user_manager::UserManager::Get()->UserLoggedIn( |
| 828 chromeos::login::StubAccountId(), "test_hash", false); | 829 user_manager::chromeos::StubAccountId(), "test_hash", false); |
| 829 | 830 |
| 830 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 831 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 831 | 832 |
| 832 // Custom wallpaper should be applied immediately, canceling the default | 833 // Custom wallpaper should be applied immediately, canceling the default |
| 833 // wallpaper load task. | 834 // wallpaper load task. |
| 834 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( | 835 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( |
| 835 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); | 836 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); |
| 836 WallpaperManager::Get()->SetCustomWallpaper( | 837 WallpaperManager::Get()->SetCustomWallpaper( |
| 837 chromeos::login::StubAccountId(), | 838 user_manager::chromeos::StubAccountId(), |
| 838 wallpaper::WallpaperFilesId::FromString("test_hash"), "test-nofile.jpeg", | 839 wallpaper::WallpaperFilesId::FromString("test_hash"), "test-nofile.jpeg", |
| 839 WALLPAPER_LAYOUT_STRETCH, user_manager::User::CUSTOMIZED, image, true); | 840 WALLPAPER_LAYOUT_STRETCH, user_manager::User::CUSTOMIZED, image, true); |
| 840 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 841 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 841 | 842 |
| 842 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 843 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 843 controller_->GetWallpaper(), | 844 controller_->GetWallpaper(), |
| 844 wallpaper_manager_test_utils::kCustomWallpaperColor)); | 845 wallpaper_manager_test_utils::kCustomWallpaperColor)); |
| 845 | 846 |
| 846 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 847 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 847 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 848 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 848 | 849 |
| 849 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 850 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 850 controller_->GetWallpaper(), | 851 controller_->GetWallpaper(), |
| 851 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); | 852 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); |
| 852 } | 853 } |
| 853 | 854 |
| 854 } // namespace chromeos | 855 } // namespace chromeos |
| OLD | NEW |