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

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

Issue 11415015: Remove use of index in wallpaper picker code and some refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser tests Created 8 years, 1 month 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 | Annotate | Revision Log
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/desktop_background/desktop_background_resources.h"
8 #include "ash/desktop_background/desktop_background_controller.h" 7 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "ash/desktop_background/desktop_background_controller_observer.h" 8 #include "ash/desktop_background/desktop_background_controller_observer.h"
10 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
11 #include "ash/shell.h" 10 #include "ash/shell.h"
12 #include "ash/test/display_manager_test_api.h" 11 #include "ash/test/display_manager_test_api.h"
13 #include "base/file_util.h" 12 #include "base/file_util.h"
14 #include "base/message_loop.h" 13 #include "base/message_loop.h"
15 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
16 #include "base/time.h" 15 #include "base/time.h"
17 #include "base/values.h" 16 #include "base/values.h"
(...skipping 19 matching lines...) Expand all
37 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight; 36 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight;
38 #else 37 #else
39 // The defualt wallpaper for non official build is a gradient wallpaper which 38 // The defualt wallpaper for non official build is a gradient wallpaper which
40 // stretches to fit screen. 39 // stretches to fit screen.
41 int kExpectedSmallWallpaperWidth = 256; 40 int kExpectedSmallWallpaperWidth = 256;
42 int kExpectedSmallWallpaperHeight = ash::kSmallWallpaperMaxHeight; 41 int kExpectedSmallWallpaperHeight = ash::kSmallWallpaperMaxHeight;
43 int kExpectedLargeWallpaperWidth = 256; 42 int kExpectedLargeWallpaperWidth = 256;
44 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight; 43 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight;
45 #endif 44 #endif
46 45
47
48 } // namespace 46 } // namespace
49 47
50 class WallpaperManagerBrowserTest : public CrosInProcessBrowserTest, 48 class WallpaperManagerBrowserTest : public CrosInProcessBrowserTest,
51 public DesktopBackgroundControllerObserver { 49 public DesktopBackgroundControllerObserver {
52 public: 50 public:
53 WallpaperManagerBrowserTest () : controller_(NULL), 51 WallpaperManagerBrowserTest () : controller_(NULL),
54 local_state_(NULL) { 52 local_state_(NULL) {
55 } 53 }
56 54
57 virtual ~WallpaperManagerBrowserTest () {} 55 virtual ~WallpaperManagerBrowserTest () {}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 118
121 // The large resolution wallpaper should be loaded when a large external screen 119 // The large resolution wallpaper should be loaded when a large external screen
122 // is hooked up. If the external screen is smaller than small wallpaper 120 // is hooked up. If the external screen is smaller than small wallpaper
123 // resolution, do not load large resolution wallpaper. 121 // resolution, do not load large resolution wallpaper.
124 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 122 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest,
125 LoadLargeWallpaperForLargeExternalScreen) { 123 LoadLargeWallpaperForLargeExternalScreen) {
126 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 124 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
127 125
128 WallpaperInfo info = { 126 WallpaperInfo info = {
129 "", 127 "",
130 CENTER_CROPPED, 128 WALLPAPER_LAYOUT_CENTER_CROPPED,
131 User::DEFAULT, 129 User::DEFAULT,
132 base::Time::Now().LocalMidnight() 130 base::Time::Now().LocalMidnight()
133 }; 131 };
134 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); 132 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true);
135 133
136 SetUserWallpaper(kTestUser1); 134 SetUserWallpaper(kTestUser1);
137 WaitAsyncWallpaperLoad(); 135 WaitAsyncWallpaperLoad();
138 gfx::ImageSkia wallpaper = controller_->GetWallpaper(); 136 gfx::ImageSkia wallpaper = controller_->GetWallpaper();
139 137
140 // Display is initialized to 800x600. The small resolution default wallpaper 138 // Display is initialized to 800x600. The small resolution default wallpaper
(...skipping 23 matching lines...) Expand all
164 // This test is similar to LoadLargeWallpaperForExternalScreen test. Instead of 162 // This test is similar to LoadLargeWallpaperForExternalScreen test. Instead of
165 // testing default wallpaper, it tests custom wallpaper. 163 // testing default wallpaper, it tests custom wallpaper.
166 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 164 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest,
167 LoadCustomLargeWallpaperForLargeExternalScreen) { 165 LoadCustomLargeWallpaperForLargeExternalScreen) {
168 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 166 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
169 FilePath small_wallpaper_path = 167 FilePath small_wallpaper_path =
170 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true); 168 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true);
171 FilePath large_wallpaper_path = 169 FilePath large_wallpaper_path =
172 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, false); 170 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, false);
173 171
174 int index = ash::GetDefaultWallpaperIndex();
175 // Saves the small/large resolution wallpapers to small/large custom 172 // Saves the small/large resolution wallpapers to small/large custom
176 // wallpaper paths. 173 // wallpaper paths.
177 SaveUserWallpaperData(kTestUser1, 174 SaveUserWallpaperData(kTestUser1,
178 small_wallpaper_path, 175 small_wallpaper_path,
179 GetWallpaperViewInfo(index, SMALL).id); 176 ash::kDefaultSmallWallpaper.idr);
180 SaveUserWallpaperData(kTestUser1, 177 SaveUserWallpaperData(kTestUser1,
181 large_wallpaper_path, 178 large_wallpaper_path,
182 GetWallpaperViewInfo(index, LARGE).id); 179 ash::kDefaultLargeWallpaper.idr);
183 180
184 // Saves wallpaper info to local state for user |kTestUser1|. 181 // Saves wallpaper info to local state for user |kTestUser1|.
185 WallpaperInfo info = { 182 WallpaperInfo info = {
186 "DUMMY", 183 "DUMMY",
187 CENTER_CROPPED, 184 WALLPAPER_LAYOUT_CENTER_CROPPED,
188 User::CUSTOMIZED, 185 User::CUSTOMIZED,
189 base::Time::Now().LocalMidnight() 186 base::Time::Now().LocalMidnight()
190 }; 187 };
191 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); 188 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true);
192 189
193 // Add user |kTestUser1|. 190 // Add user |kTestUser1|.
194 191
195 SetUserWallpaper(kTestUser1); 192 SetUserWallpaper(kTestUser1);
196 WaitAsyncWallpaperLoad(); 193 WaitAsyncWallpaperLoad();
197 gfx::ImageSkia wallpaper = controller_->GetWallpaper(); 194 gfx::ImageSkia wallpaper = controller_->GetWallpaper();
(...skipping 24 matching lines...) Expand all
222 219
223 // If chrome tries to reload the same wallpaper twice, the latter request should 220 // If chrome tries to reload the same wallpaper twice, the latter request should
224 // be prevented. Otherwise, there are some strange animation issues as 221 // be prevented. Otherwise, there are some strange animation issues as
225 // described in crbug.com/158383. 222 // described in crbug.com/158383.
226 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 223 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest,
227 PreventReloadingSameWallpaper) { 224 PreventReloadingSameWallpaper) {
228 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 225 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
229 FilePath small_wallpaper_path = 226 FilePath small_wallpaper_path =
230 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true); 227 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true);
231 228
232 int index = ash::GetDefaultWallpaperIndex();
233 SaveUserWallpaperData(kTestUser1, 229 SaveUserWallpaperData(kTestUser1,
234 small_wallpaper_path, 230 small_wallpaper_path,
235 GetWallpaperViewInfo(index, SMALL).id); 231 ash::kDefaultSmallWallpaper.idr);
236 232
237 // Saves wallpaper info to local state for user |kTestUser1|. 233 // Saves wallpaper info to local state for user |kTestUser1|.
238 WallpaperInfo info = { 234 WallpaperInfo info = {
239 "DUMMY", 235 "DUMMY",
240 CENTER_CROPPED, 236 WALLPAPER_LAYOUT_CENTER_CROPPED,
241 User::CUSTOMIZED, 237 User::CUSTOMIZED,
242 base::Time::Now().LocalMidnight() 238 base::Time::Now().LocalMidnight()
243 }; 239 };
244 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); 240 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true);
245 241
246 SetUserWallpaper(kTestUser1); 242 SetUserWallpaper(kTestUser1);
247 EXPECT_EQ(1, LoadedWallpapers()); 243 EXPECT_EQ(1, LoadedWallpapers());
248 // Loads the same wallpaper before the initial one finished. It should be 244 // Loads the same wallpaper before the initial one finished. It should be
249 // prevented. 245 // prevented.
250 SetUserWallpaper(kTestUser1); 246 SetUserWallpaper(kTestUser1);
(...skipping 14 matching lines...) Expand all
265 // Loads the same wallpaper before the initial one finished. It should be 261 // Loads the same wallpaper before the initial one finished. It should be
266 // prevented. 262 // prevented.
267 SetUserWallpaper(kTestUser1); 263 SetUserWallpaper(kTestUser1);
268 EXPECT_EQ(2, LoadedWallpapers()); 264 EXPECT_EQ(2, LoadedWallpapers());
269 WaitAsyncWallpaperLoad(); 265 WaitAsyncWallpaperLoad();
270 SetUserWallpaper(kTestUser1); 266 SetUserWallpaper(kTestUser1);
271 EXPECT_EQ(2, LoadedWallpapers()); 267 EXPECT_EQ(2, LoadedWallpapers());
272 } 268 }
273 269
274 } // namepace chromeos 270 } // namepace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wallpaper_manager.cc ('k') | chrome/browser/chromeos/login/webui_login_display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698