| 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" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | |
| 13 #include "ash/test/ash_test_helper.h" | |
| 14 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 16 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 18 #include "base/macros.h" | 16 #include "base/macros.h" |
| 19 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 20 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 21 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 23 #include "base/values.h" | 21 #include "base/values.h" |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 base::RunLoop().RunUntilIdle(); | 708 base::RunLoop().RunUntilIdle(); |
| 711 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 709 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 712 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); | 710 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); |
| 713 } | 711 } |
| 714 | 712 |
| 715 // Test that WallpaperManager loads the appropriate wallpaper | 713 // Test that WallpaperManager loads the appropriate wallpaper |
| 716 // images as specified via command-line flags in various situations. | 714 // images as specified via command-line flags in various situations. |
| 717 // Splitting these into separate tests avoids needing to run animations. | 715 // Splitting these into separate tests avoids needing to run animations. |
| 718 // TODO(derat): Combine these into a single test | 716 // TODO(derat): Combine these into a single test |
| 719 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallDefaultWallpaper) { | 717 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallDefaultWallpaper) { |
| 720 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | |
| 721 return; | |
| 722 | |
| 723 CreateCmdlineWallpapers(); | 718 CreateCmdlineWallpapers(); |
| 724 | 719 |
| 725 // At 800x600, the small wallpaper should be loaded. | 720 // At 800x600, the small wallpaper should be loaded. |
| 726 UpdateDisplay("800x600"); | 721 UpdateDisplay("800x600"); |
| 727 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 722 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 728 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 723 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 729 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 724 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 730 controller_->GetWallpaper(), | 725 controller_->GetWallpaper(), |
| 731 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); | 726 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); |
| 732 } | 727 } |
| 733 | 728 |
| 734 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeDefaultWallpaper) { | 729 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeDefaultWallpaper) { |
| 735 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | |
| 736 return; | |
| 737 | |
| 738 CreateCmdlineWallpapers(); | 730 CreateCmdlineWallpapers(); |
| 739 UpdateDisplay("1600x1200"); | 731 UpdateDisplay("1600x1200"); |
| 740 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 732 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 741 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 733 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 742 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 734 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 743 controller_->GetWallpaper(), | 735 controller_->GetWallpaper(), |
| 744 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 736 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
| 745 } | 737 } |
| 746 | 738 |
| 747 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 739 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
| 748 LargeDefaultWallpaperWhenRotated) { | 740 LargeDefaultWallpaperWhenRotated) { |
| 749 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | |
| 750 return; | |
| 751 CreateCmdlineWallpapers(); | 741 CreateCmdlineWallpapers(); |
| 752 | 742 |
| 753 UpdateDisplay("1200x800/r"); | 743 UpdateDisplay("1200x800/r"); |
| 754 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 744 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 755 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 745 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 756 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 746 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 757 controller_->GetWallpaper(), | 747 controller_->GetWallpaper(), |
| 758 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 748 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
| 759 } | 749 } |
| 760 | 750 |
| 761 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { | 751 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { |
| 762 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | |
| 763 return; | |
| 764 CreateCmdlineWallpapers(); | 752 CreateCmdlineWallpapers(); |
| 765 SessionManager::Get()->CreateSession(user_manager::GuestAccountId(), | 753 SessionManager::Get()->CreateSession(user_manager::GuestAccountId(), |
| 766 user_manager::kGuestUserName); | 754 user_manager::kGuestUserName); |
| 767 UpdateDisplay("800x600"); | 755 UpdateDisplay("800x600"); |
| 768 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 756 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 769 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 757 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 770 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 758 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 771 controller_->GetWallpaper(), | 759 controller_->GetWallpaper(), |
| 772 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); | 760 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); |
| 773 } | 761 } |
| 774 | 762 |
| 775 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { | 763 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { |
| 776 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | |
| 777 return; | |
| 778 | |
| 779 CreateCmdlineWallpapers(); | 764 CreateCmdlineWallpapers(); |
| 780 SessionManager::Get()->CreateSession(user_manager::GuestAccountId(), | 765 SessionManager::Get()->CreateSession(user_manager::GuestAccountId(), |
| 781 user_manager::kGuestUserName); | 766 user_manager::kGuestUserName); |
| 782 UpdateDisplay("1600x1200"); | 767 UpdateDisplay("1600x1200"); |
| 783 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 768 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 784 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 769 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 785 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 770 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 786 controller_->GetWallpaper(), | 771 controller_->GetWallpaper(), |
| 787 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); | 772 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); |
| 788 } | 773 } |
| 789 | 774 |
| 790 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallChildWallpaper) { | 775 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallChildWallpaper) { |
| 791 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | |
| 792 return; | |
| 793 CreateCmdlineWallpapers(); | 776 CreateCmdlineWallpapers(); |
| 794 LogInAsChild(test_account_id1_, kTestUser1Hash); | 777 LogInAsChild(test_account_id1_, kTestUser1Hash); |
| 795 UpdateDisplay("800x600"); | 778 UpdateDisplay("800x600"); |
| 796 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 779 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 797 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 780 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 798 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 781 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 799 controller_->GetWallpaper(), | 782 controller_->GetWallpaper(), |
| 800 wallpaper_manager_test_utils::kSmallChildWallpaperColor)); | 783 wallpaper_manager_test_utils::kSmallChildWallpaperColor)); |
| 801 } | 784 } |
| 802 | 785 |
| 803 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeChildWallpaper) { | 786 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeChildWallpaper) { |
| 804 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | |
| 805 return; | |
| 806 | |
| 807 CreateCmdlineWallpapers(); | 787 CreateCmdlineWallpapers(); |
| 808 LogInAsChild(test_account_id1_, kTestUser1Hash); | 788 LogInAsChild(test_account_id1_, kTestUser1Hash); |
| 809 UpdateDisplay("1600x1200"); | 789 UpdateDisplay("1600x1200"); |
| 810 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 790 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 811 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 791 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 812 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 792 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 813 controller_->GetWallpaper(), | 793 controller_->GetWallpaper(), |
| 814 wallpaper_manager_test_utils::kLargeChildWallpaperColor)); | 794 wallpaper_manager_test_utils::kLargeChildWallpaperColor)); |
| 815 } | 795 } |
| 816 | 796 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 840 | 820 |
| 841 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); | 821 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); |
| 842 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 822 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
| 843 | 823 |
| 844 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 824 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
| 845 controller_->GetWallpaper(), | 825 controller_->GetWallpaper(), |
| 846 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); | 826 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); |
| 847 } | 827 } |
| 848 | 828 |
| 849 } // namespace chromeos | 829 } // namespace chromeos |
| OLD | NEW |