Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc

Issue 239703014: Add debug to WallpaperManagerBrowserTest.DisplayChange test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/login/wallpaper_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ash_resources/grit/ash_resources.h" 7 #include "ash/ash_resources/grit/ash_resources.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/desktop_background/desktop_background_controller.h" 9 #include "ash/desktop_background/desktop_background_controller.h"
10 #include "ash/desktop_background/desktop_background_controller_observer.h" 10 #include "ash/desktop_background/desktop_background_controller_observer.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
98 } 101 }
99 102
100 void WaitAsyncWallpaperLoadStarted() { 103 void WaitAsyncWallpaperLoadStarted() {
101 base::RunLoop().RunUntilIdle(); 104 base::RunLoop().RunUntilIdle();
102 } 105 }
103 106
104 void WaitAsyncWallpaperLoadFinished() { 107 void WaitAsyncWallpaperLoadFinished() {
105 base::RunLoop().RunUntilIdle(); 108 base::RunLoop().RunUntilIdle();
106 while (WallpaperManager::Get()->loading_.size()) { 109 while (WallpaperManager::Get()->loading_.size()) {
107 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); 110 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 return old; 762 return old;
760 } 763 }
761 764
762 private: 765 private:
763 int update_wallpaper_count_; 766 int update_wallpaper_count_;
764 WallpaperManager* wallpaper_manager_; 767 WallpaperManager* wallpaper_manager_;
765 768
766 DISALLOW_COPY_AND_ASSIGN(TestObserver); 769 DISALLOW_COPY_AND_ASSIGN(TestObserver);
767 }; 770 };
768 771
769 // Disabled due to flaky failures. crbug.com/362847 772 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, DisplayChange) {
770 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, DISABLED_DisplayChange) {
771 // TODO(derat|oshima|bshe): Host windows can't be resized on Win8. 773 // TODO(derat|oshima|bshe): Host windows can't be resized on Win8.
772 if (!ash::test::AshTestHelper::SupportsHostWindowResize()) 774 if (!ash::test::AshTestHelper::SupportsHostWindowResize())
773 return; 775 return;
774 776
775 TestObserver observer(WallpaperManager::Get()); 777 TestObserver observer(WallpaperManager::Get());
776 778
777 // Set the wallpaper to ensure that UpdateWallpaper() will be called when the 779 // Set the wallpaper to ensure that UpdateWallpaper() will be called when the
778 // display configuration changes. 780 // display configuration changes.
779 gfx::ImageSkia image = CreateTestImage(640, 480, kCustomWallpaperColor); 781 gfx::ImageSkia image = CreateTestImage(640, 480, kCustomWallpaperColor);
780 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); 782 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH);
781 783
782 // Small wallpaper images should be used for configurations less than or 784 // Small wallpaper images should be used for configurations less than or
783 // equal to kSmallWallpaperMaxWidth by kSmallWallpaperMaxHeight, even if 785 // equal to kSmallWallpaperMaxWidth by kSmallWallpaperMaxHeight, even if
784 // multiple displays are connected. 786 // multiple displays are connected.
785 UpdateDisplay("800x600"); 787 UpdateDisplay("800x600");
786 WaitAsyncWallpaperLoadFinished(); 788 WaitAsyncWallpaperLoadFinished();
789 WallpaperManager::GetAppropriateResolutionForTesting();
787 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, 790 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL,
788 WallpaperManager::Get()->GetAppropriateResolution()); 791 WallpaperManager::Get()->GetAppropriateResolution());
789 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); 792 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset());
790 793
791 UpdateDisplay("800x600,800x600"); 794 UpdateDisplay("800x600,800x600");
792 WaitAsyncWallpaperLoadFinished(); 795 WaitAsyncWallpaperLoadFinished();
796 WallpaperManager::GetAppropriateResolutionForTesting();
793 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, 797 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL,
794 WallpaperManager::Get()->GetAppropriateResolution()); 798 WallpaperManager::Get()->GetAppropriateResolution());
795 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); 799 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset());
796 800
797 UpdateDisplay("1366x800"); 801 UpdateDisplay("1366x800");
798 WaitAsyncWallpaperLoadFinished(); 802 WaitAsyncWallpaperLoadFinished();
803 WallpaperManager::GetAppropriateResolutionForTesting();
799 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, 804 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL,
800 WallpaperManager::Get()->GetAppropriateResolution()); 805 WallpaperManager::Get()->GetAppropriateResolution());
801 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); 806 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset());
802 807
803 // At larger sizes, large wallpapers should be used. 808 // At larger sizes, large wallpapers should be used.
804 UpdateDisplay("1367x800"); 809 UpdateDisplay("1367x800");
805 WaitAsyncWallpaperLoadFinished(); 810 WaitAsyncWallpaperLoadFinished();
811 WallpaperManager::GetAppropriateResolutionForTesting();
806 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, 812 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE,
807 WallpaperManager::Get()->GetAppropriateResolution()); 813 WallpaperManager::Get()->GetAppropriateResolution());
808 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); 814 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset());
809 815
810 UpdateDisplay("1367x801"); 816 UpdateDisplay("1367x801");
811 WaitAsyncWallpaperLoadFinished(); 817 WaitAsyncWallpaperLoadFinished();
818 WallpaperManager::GetAppropriateResolutionForTesting();
812 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, 819 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE,
813 WallpaperManager::Get()->GetAppropriateResolution()); 820 WallpaperManager::Get()->GetAppropriateResolution());
814 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); 821 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset());
815 822
816 UpdateDisplay("2560x1700"); 823 UpdateDisplay("2560x1700");
817 WaitAsyncWallpaperLoadFinished(); 824 WaitAsyncWallpaperLoadFinished();
825 WallpaperManager::GetAppropriateResolutionForTesting();
818 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, 826 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE,
819 WallpaperManager::Get()->GetAppropriateResolution()); 827 WallpaperManager::Get()->GetAppropriateResolution());
820 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); 828 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset());
821 829
822 // Rotated smaller screen may use larger image. 830 // Rotated smaller screen may use larger image.
823 UpdateDisplay("800x600/r"); 831 UpdateDisplay("800x600/r");
824 WaitAsyncWallpaperLoadFinished(); 832 WaitAsyncWallpaperLoadFinished();
833 WallpaperManager::GetAppropriateResolutionForTesting();
825 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, 834 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL,
826 WallpaperManager::Get()->GetAppropriateResolution()); 835 WallpaperManager::Get()->GetAppropriateResolution());
827 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); 836 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset());
828 837
829 UpdateDisplay("800x600/r,800x600"); 838 UpdateDisplay("800x600/r,800x600");
830 WaitAsyncWallpaperLoadFinished(); 839 WaitAsyncWallpaperLoadFinished();
840 WallpaperManager::GetAppropriateResolutionForTesting();
831 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, 841 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL,
832 WallpaperManager::Get()->GetAppropriateResolution()); 842 WallpaperManager::Get()->GetAppropriateResolution());
833 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); 843 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset());
834 UpdateDisplay("1366x800/r"); 844 UpdateDisplay("1366x800/r");
845 WallpaperManager::GetAppropriateResolutionForTesting();
835 WaitAsyncWallpaperLoadFinished(); 846 WaitAsyncWallpaperLoadFinished();
836 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, 847 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE,
837 WallpaperManager::Get()->GetAppropriateResolution()); 848 WallpaperManager::Get()->GetAppropriateResolution());
838 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); 849 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset());
839 850
840 // Max display size didn't chagne. 851 // Max display size didn't chagne.
841 UpdateDisplay("900x800/r,400x1366"); 852 UpdateDisplay("900x800/r,400x1366");
853 WallpaperManager::GetAppropriateResolutionForTesting();
842 WaitAsyncWallpaperLoadFinished(); 854 WaitAsyncWallpaperLoadFinished();
843 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); 855 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset());
844 } 856 }
845 857
846 // Test that WallpaperManager loads the appropriate wallpaper 858 // Test that WallpaperManager loads the appropriate wallpaper
847 // images as specified via command-line flags in various situations. 859 // images as specified via command-line flags in various situations.
848 // Splitting these into separate tests avoids needing to run animations. 860 // Splitting these into separate tests avoids needing to run animations.
849 // TODO(derat): Combine these into a single test 861 // TODO(derat): Combine these into a single test
850 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallDefaultWallpaper) { 862 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallDefaultWallpaper) {
851 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) 863 if (!ash::test::AshTestHelper::SupportsMultipleDisplays())
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 ImageIsNearColor(controller_->GetWallpaper(), kCustomWallpaperColor)); 950 ImageIsNearColor(controller_->GetWallpaper(), kCustomWallpaperColor));
939 951
940 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); 952 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string());
941 WaitAsyncWallpaperLoadFinished(); 953 WaitAsyncWallpaperLoadFinished();
942 954
943 EXPECT_TRUE( 955 EXPECT_TRUE(
944 ImageIsNearColor(controller_->GetWallpaper(), kSmallWallpaperColor)); 956 ImageIsNearColor(controller_->GetWallpaper(), kSmallWallpaperColor));
945 } 957 }
946 958
947 } // namespace chromeos 959 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wallpaper_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698