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/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 virtual void CleanUpOnMainThread() OVERRIDE { | 88 virtual void CleanUpOnMainThread() OVERRIDE { |
89 controller_ = NULL; | 89 controller_ = NULL; |
90 } | 90 } |
91 | 91 |
92 // Update the display configuration as given in |display_specs|. See | 92 // Update the display configuration as given in |display_specs|. See |
93 // ash::test::DisplayManagerTestApi::UpdateDisplay for more details. | 93 // ash::test::DisplayManagerTestApi::UpdateDisplay for more details. |
94 void UpdateDisplay(const std::string& display_specs) { | 94 void UpdateDisplay(const std::string& display_specs) { |
95 ash::test::DisplayManagerTestApi display_manager_test_api( | 95 ash::test::DisplayManagerTestApi display_manager_test_api( |
96 ash::Shell::GetInstance()->display_manager()); | 96 ash::Shell::GetInstance()->display_manager()); |
97 display_manager_test_api.UpdateDisplay(display_specs); | 97 display_manager_test_api.UpdateDisplay(display_specs); |
98 LOG(ERROR) << "UpdateDisplay(display_specs='" << display_specs | |
99 << "') done."; | |
100 WallpaperManager::GetAppropriateResolutionForTesting(); | |
101 } | 98 } |
102 | 99 |
103 void WaitAsyncWallpaperLoadStarted() { | 100 void WaitAsyncWallpaperLoadStarted() { |
104 base::RunLoop().RunUntilIdle(); | 101 base::RunLoop().RunUntilIdle(); |
105 } | 102 } |
106 | 103 |
107 protected: | 104 protected: |
108 | 105 |
109 // Return custom wallpaper path. Create directory if not exist. | 106 // Return custom wallpaper path. Create directory if not exist. |
110 base::FilePath GetCustomWallpaperPath(const char* sub_dir, | 107 base::FilePath GetCustomWallpaperPath(const char* sub_dir, |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); | 632 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); |
636 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); | 633 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); |
637 | 634 |
638 // Small wallpaper images should be used for configurations less than or | 635 // Small wallpaper images should be used for configurations less than or |
639 // equal to kSmallWallpaperMaxWidth by kSmallWallpaperMaxHeight, even if | 636 // equal to kSmallWallpaperMaxWidth by kSmallWallpaperMaxHeight, even if |
640 // multiple displays are connected. | 637 // multiple displays are connected. |
641 UpdateDisplay("800x600"); | 638 UpdateDisplay("800x600"); |
642 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 639 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
643 base::RunLoop().RunUntilIdle(); | 640 base::RunLoop().RunUntilIdle(); |
644 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 641 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
645 WallpaperManager::GetAppropriateResolutionForTesting(); | |
646 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 642 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
647 WallpaperManager::Get()->GetAppropriateResolution()); | 643 WallpaperManager::Get()->GetAppropriateResolution()); |
648 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); | 644 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); |
649 | 645 |
650 UpdateDisplay("800x600,800x600"); | 646 UpdateDisplay("800x600,800x600"); |
651 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 647 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
652 base::RunLoop().RunUntilIdle(); | 648 base::RunLoop().RunUntilIdle(); |
653 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 649 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
654 WallpaperManager::GetAppropriateResolutionForTesting(); | |
655 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 650 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
656 WallpaperManager::Get()->GetAppropriateResolution()); | 651 WallpaperManager::Get()->GetAppropriateResolution()); |
657 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); | 652 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); |
658 | 653 |
659 UpdateDisplay("1366x800"); | 654 UpdateDisplay("1366x800"); |
660 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 655 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
661 base::RunLoop().RunUntilIdle(); | 656 base::RunLoop().RunUntilIdle(); |
662 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 657 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
663 WallpaperManager::GetAppropriateResolutionForTesting(); | |
664 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 658 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
665 WallpaperManager::Get()->GetAppropriateResolution()); | 659 WallpaperManager::Get()->GetAppropriateResolution()); |
666 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 660 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
667 | 661 |
668 // At larger sizes, large wallpapers should be used. | 662 // At larger sizes, large wallpapers should be used. |
669 UpdateDisplay("1367x800"); | 663 UpdateDisplay("1367x800"); |
670 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 664 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
671 base::RunLoop().RunUntilIdle(); | 665 base::RunLoop().RunUntilIdle(); |
672 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 666 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
673 WallpaperManager::GetAppropriateResolutionForTesting(); | |
674 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 667 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
675 WallpaperManager::Get()->GetAppropriateResolution()); | 668 WallpaperManager::Get()->GetAppropriateResolution()); |
676 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 669 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
677 | 670 |
678 UpdateDisplay("1367x801"); | 671 UpdateDisplay("1367x801"); |
679 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 672 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
680 base::RunLoop().RunUntilIdle(); | 673 base::RunLoop().RunUntilIdle(); |
681 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 674 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
682 WallpaperManager::GetAppropriateResolutionForTesting(); | |
683 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 675 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
684 WallpaperManager::Get()->GetAppropriateResolution()); | 676 WallpaperManager::Get()->GetAppropriateResolution()); |
685 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 677 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
686 | 678 |
687 UpdateDisplay("2560x1700"); | 679 UpdateDisplay("2560x1700"); |
688 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 680 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
689 base::RunLoop().RunUntilIdle(); | 681 base::RunLoop().RunUntilIdle(); |
690 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 682 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
691 WallpaperManager::GetAppropriateResolutionForTesting(); | |
692 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 683 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
693 WallpaperManager::Get()->GetAppropriateResolution()); | 684 WallpaperManager::Get()->GetAppropriateResolution()); |
694 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 685 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
695 | 686 |
696 // Rotated smaller screen may use larger image. | 687 // Rotated smaller screen may use larger image. |
697 UpdateDisplay("800x600/r"); | 688 UpdateDisplay("800x600/r"); |
698 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 689 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
699 base::RunLoop().RunUntilIdle(); | 690 base::RunLoop().RunUntilIdle(); |
700 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 691 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
701 WallpaperManager::GetAppropriateResolutionForTesting(); | |
702 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 692 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
703 WallpaperManager::Get()->GetAppropriateResolution()); | 693 WallpaperManager::Get()->GetAppropriateResolution()); |
704 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 694 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
705 | 695 |
706 UpdateDisplay("800x600/r,800x600"); | 696 UpdateDisplay("800x600/r,800x600"); |
707 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 697 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
708 base::RunLoop().RunUntilIdle(); | 698 base::RunLoop().RunUntilIdle(); |
709 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 699 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
710 WallpaperManager::GetAppropriateResolutionForTesting(); | |
711 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 700 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
712 WallpaperManager::Get()->GetAppropriateResolution()); | 701 WallpaperManager::Get()->GetAppropriateResolution()); |
713 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 702 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
714 UpdateDisplay("1366x800/r"); | 703 UpdateDisplay("1366x800/r"); |
715 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 704 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
716 base::RunLoop().RunUntilIdle(); | 705 base::RunLoop().RunUntilIdle(); |
717 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 706 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
718 WallpaperManager::GetAppropriateResolutionForTesting(); | |
719 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 707 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
720 WallpaperManager::Get()->GetAppropriateResolution()); | 708 WallpaperManager::Get()->GetAppropriateResolution()); |
721 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 709 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
722 | 710 |
723 // Max display size didn't chagne. | 711 // Max display size didn't chagne. |
724 UpdateDisplay("900x800/r,400x1366"); | 712 UpdateDisplay("900x800/r,400x1366"); |
725 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. | 713 // Wait for asynchronous DisplayBackgroundController::UpdateDisplay() call. |
726 base::RunLoop().RunUntilIdle(); | 714 base::RunLoop().RunUntilIdle(); |
727 WallpaperManager::GetAppropriateResolutionForTesting(); | |
728 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 715 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
729 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); | 716 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); |
730 } | 717 } |
731 | 718 |
732 // Test that WallpaperManager loads the appropriate wallpaper | 719 // Test that WallpaperManager loads the appropriate wallpaper |
733 // images as specified via command-line flags in various situations. | 720 // images as specified via command-line flags in various situations. |
734 // Splitting these into separate tests avoids needing to run animations. | 721 // Splitting these into separate tests avoids needing to run animations. |
735 // TODO(derat): Combine these into a single test | 722 // TODO(derat): Combine these into a single test |
736 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallDefaultWallpaper) { | 723 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallDefaultWallpaper) { |
737 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 724 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 | 819 |
833 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 820 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
834 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 821 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
835 | 822 |
836 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 823 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
837 controller_->GetWallpaper(), | 824 controller_->GetWallpaper(), |
838 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); | 825 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); |
839 } | 826 } |
840 | 827 |
841 } // namespace chromeos | 828 } // namespace chromeos |
OLD | NEW |