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

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

Issue 190993003: Invalidate all wallpaper cache if display configuration changed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win compile Created 6 years, 9 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 | 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/ash_resources/grit/ash_resources.h" 7 #include "ash/ash_resources/grit/ash_resources.h"
8 #include "ash/desktop_background/desktop_background_controller.h" 8 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "ash/desktop_background/desktop_background_controller_observer.h" 9 #include "ash/desktop_background/desktop_background_controller_observer.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 int kSmallWallpaperHeight = ash::kSmallWallpaperMaxHeight; 46 int kSmallWallpaperHeight = ash::kSmallWallpaperMaxHeight;
47 47
48 const char kTestUser1[] = "test1@domain.com"; 48 const char kTestUser1[] = "test1@domain.com";
49 const char kTestUser1Hash[] = "test1@domain.com-hash"; 49 const char kTestUser1Hash[] = "test1@domain.com-hash";
50 const char kTestUser2[] = "test2@domain.com"; 50 const char kTestUser2[] = "test2@domain.com";
51 const char kTestUser2Hash[] = "test2@domain.com-hash"; 51 const char kTestUser2Hash[] = "test2@domain.com-hash";
52 52
53 } // namespace 53 } // namespace
54 54
55 class WallpaperManagerBrowserTest : public InProcessBrowserTest, 55 class WallpaperManagerBrowserTest : public InProcessBrowserTest,
56 public DesktopBackgroundControllerObserver { 56 public DesktopBackgroundControllerObserver,
57 public testing::WithParamInterface<bool> {
57 public: 58 public:
58 WallpaperManagerBrowserTest () : controller_(NULL), 59 WallpaperManagerBrowserTest () : controller_(NULL),
59 local_state_(NULL) { 60 local_state_(NULL) {
60 } 61 }
61 62
62 virtual ~WallpaperManagerBrowserTest () {} 63 virtual ~WallpaperManagerBrowserTest () {}
63 64
64 virtual void SetUpOnMainThread() OVERRIDE { 65 virtual void SetUpOnMainThread() OVERRIDE {
65 controller_ = ash::Shell::GetInstance()->desktop_background_controller(); 66 controller_ = ash::Shell::GetInstance()->desktop_background_controller();
66 controller_->AddObserver(this); 67 controller_->AddObserver(this);
67 local_state_ = g_browser_process->local_state(); 68 local_state_ = g_browser_process->local_state();
68 UpdateDisplay("800x600"); 69 UpdateDisplay("800x600");
69 } 70 }
70 71
71 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 72 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
72 command_line->AppendSwitch(switches::kLoginManager); 73 command_line->AppendSwitch(switches::kLoginManager);
73 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); 74 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
75 if (GetParam())
76 command_line->AppendSwitch(::switches::kMultiProfiles);
74 } 77 }
75 78
76 virtual void CleanUpOnMainThread() OVERRIDE { 79 virtual void CleanUpOnMainThread() OVERRIDE {
77 controller_->RemoveObserver(this); 80 controller_->RemoveObserver(this);
78 controller_ = NULL; 81 controller_ = NULL;
79 } 82 }
80 83
81 // Update the display configuration as given in |display_specs|. 84 // Update the display configuration as given in |display_specs|.
82 // See ash::test::DisplayManagerTestApi::UpdateDisplay for more 85 // See ash::test::DisplayManagerTestApi::UpdateDisplay for more
83 // details. 86 // details.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 146
144 DesktopBackgroundController* controller_; 147 DesktopBackgroundController* controller_;
145 PrefService* local_state_; 148 PrefService* local_state_;
146 149
147 private: 150 private:
148 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBrowserTest); 151 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBrowserTest);
149 }; 152 };
150 153
151 // Tests that the appropriate custom wallpaper (large vs. small) is loaded 154 // Tests that the appropriate custom wallpaper (large vs. small) is loaded
152 // depending on the desktop resolution. 155 // depending on the desktop resolution.
153 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 156 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest,
154 LoadCustomLargeWallpaperForLargeExternalScreen) { 157 LoadCustomLargeWallpaperForLargeExternalScreen) {
155 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 158 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
156 LogIn(kTestUser1, kTestUser1Hash); 159 LogIn(kTestUser1, kTestUser1Hash);
157 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); 160 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue());
158 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( 161 base::FilePath small_wallpaper_path = GetCustomWallpaperPath(
159 kSmallWallpaperSubDir, 162 kSmallWallpaperSubDir,
160 kTestUser1Hash, 163 kTestUser1Hash,
161 id); 164 id);
162 base::FilePath large_wallpaper_path = GetCustomWallpaperPath( 165 base::FilePath large_wallpaper_path = GetCustomWallpaperPath(
163 kLargeWallpaperSubDir, 166 kLargeWallpaperSubDir,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 wallpaper = controller_->GetWallpaper(); 222 wallpaper = controller_->GetWallpaper();
220 223
221 // The large resolution custom wallpaper is expected. 224 // The large resolution custom wallpaper is expected.
222 EXPECT_EQ(kLargeWallpaperWidth, wallpaper.width()); 225 EXPECT_EQ(kLargeWallpaperWidth, wallpaper.width());
223 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height()); 226 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height());
224 } 227 }
225 228
226 // If chrome tries to reload the same wallpaper twice, the latter request should 229 // If chrome tries to reload the same wallpaper twice, the latter request should
227 // be prevented. Otherwise, there are some strange animation issues as 230 // be prevented. Otherwise, there are some strange animation issues as
228 // described in crbug.com/158383. 231 // described in crbug.com/158383.
229 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 232 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest,
230 PreventReloadingSameWallpaper) { 233 PreventReloadingSameWallpaper) {
231 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 234 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
232 // New user log in, a default wallpaper is loaded. 235 // New user log in, a default wallpaper is loaded.
233 LogIn(kTestUser1, kTestUser1Hash); 236 LogIn(kTestUser1, kTestUser1Hash);
234 EXPECT_EQ(1, LoadedWallpapers()); 237 EXPECT_EQ(1, LoadedWallpapers());
235 // Loads the same wallpaper before the initial one finished. It should be 238 // Loads the same wallpaper before the initial one finished. It should be
236 // prevented. 239 // prevented.
237 wallpaper_manager->SetUserWallpaperNow(kTestUser1); 240 wallpaper_manager->SetUserWallpaperNow(kTestUser1);
238 WaitAsyncWallpaperLoadFinished(); 241 WaitAsyncWallpaperLoadFinished();
239 EXPECT_EQ(1, LoadedWallpapers()); 242 EXPECT_EQ(1, LoadedWallpapers());
240 // Loads the same wallpaper after the initial one finished. It should be 243 // Loads the same wallpaper after the initial one finished. It should be
241 // prevented. 244 // prevented.
242 wallpaper_manager->SetUserWallpaperNow(kTestUser1); 245 wallpaper_manager->SetUserWallpaperNow(kTestUser1);
243 WaitAsyncWallpaperLoadFinished(); 246 WaitAsyncWallpaperLoadFinished();
244 EXPECT_EQ(1, LoadedWallpapers()); 247 EXPECT_EQ(1, LoadedWallpapers());
245 wallpaper_manager->ClearWallpaperCache(); 248 wallpaper_manager->ClearDisposableWallpaperCache();
246 249
247 // Change wallpaper to a custom wallpaper. 250 // Change wallpaper to a custom wallpaper.
248 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); 251 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue());
249 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( 252 base::FilePath small_wallpaper_path = GetCustomWallpaperPath(
250 kSmallWallpaperSubDir, 253 kSmallWallpaperSubDir,
251 kTestUser1Hash, 254 kTestUser1Hash,
252 id); 255 id);
253 SaveUserWallpaperData(small_wallpaper_path, 256 SaveUserWallpaperData(small_wallpaper_path,
254 kSmallWallpaperResourceId); 257 kSmallWallpaperResourceId);
255 258
(...skipping 17 matching lines...) Expand all
273 EXPECT_EQ(2, LoadedWallpapers()); 276 EXPECT_EQ(2, LoadedWallpapers());
274 wallpaper_manager->SetUserWallpaperNow(kTestUser1); 277 wallpaper_manager->SetUserWallpaperNow(kTestUser1);
275 WaitAsyncWallpaperLoadFinished(); 278 WaitAsyncWallpaperLoadFinished();
276 EXPECT_EQ(2, LoadedWallpapers()); 279 EXPECT_EQ(2, LoadedWallpapers());
277 } 280 }
278 281
279 // Some users have old user profiles which may have legacy wallpapers. And these 282 // Some users have old user profiles which may have legacy wallpapers. And these
280 // lagacy wallpapers should migrate to new wallpaper picker version seamlessly. 283 // lagacy wallpapers should migrate to new wallpaper picker version seamlessly.
281 // This tests make sure we compatible with migrated old wallpapers. 284 // This tests make sure we compatible with migrated old wallpapers.
282 // crosbug.com/38429 285 // crosbug.com/38429
283 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 286 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest,
284 PRE_UseMigratedWallpaperInfo) { 287 PRE_UseMigratedWallpaperInfo) {
285 // New user log in, a default wallpaper is loaded. 288 // New user log in, a default wallpaper is loaded.
286 LogIn(kTestUser1, kTestUser1Hash); 289 LogIn(kTestUser1, kTestUser1Hash);
287 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user 290 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user
288 // wallpaper info directly to simulate the wallpaper migration. See 291 // wallpaper info directly to simulate the wallpaper migration. See
289 // crosbug.com/38429 for details about why we modify wallpaper info this way. 292 // crosbug.com/38429 for details about why we modify wallpaper info this way.
290 WallpaperInfo info = { 293 WallpaperInfo info = {
291 "123", 294 "123",
292 WALLPAPER_LAYOUT_CENTER_CROPPED, 295 WALLPAPER_LAYOUT_CENTER_CROPPED,
293 User::DEFAULT, 296 User::DEFAULT,
294 base::Time::Now().LocalMidnight() 297 base::Time::Now().LocalMidnight()
295 }; 298 };
296 base::FilePath user_data_dir; 299 base::FilePath user_data_dir;
297 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); 300 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
298 SaveUserWallpaperData(user_data_dir.Append("123"), 301 SaveUserWallpaperData(user_data_dir.Append("123"),
299 kLargeWallpaperResourceId); 302 kLargeWallpaperResourceId);
300 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); 303 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true);
301 } 304 }
302 305
303 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 306 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest,
304 UseMigratedWallpaperInfo) { 307 UseMigratedWallpaperInfo) {
305 LogIn(kTestUser1, kTestUser1Hash); 308 LogIn(kTestUser1, kTestUser1Hash);
306 WaitAsyncWallpaperLoadFinished(); 309 WaitAsyncWallpaperLoadFinished();
307 // This test should finish normally. If timeout, it is probably because 310 // This test should finish normally. If timeout, it is probably because
308 // migrated wallpaper is somehow not loaded. Bad things can happen if 311 // migrated wallpaper is somehow not loaded. Bad things can happen if
309 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. 312 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429.
310 } 313 }
311 314
312 // Some users have old user profiles which may never get a chance to migrate. 315 // Some users have old user profiles which may never get a chance to migrate.
313 // This tests make sure we compatible with these profiles. 316 // This tests make sure we compatible with these profiles.
314 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 317 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest,
315 PRE_UsePreMigrationWallpaperInfo) { 318 PRE_UsePreMigrationWallpaperInfo) {
316 // New user log in, a default wallpaper is loaded. 319 // New user log in, a default wallpaper is loaded.
317 LogIn(kTestUser1, kTestUser1Hash); 320 LogIn(kTestUser1, kTestUser1Hash);
318 // Old wallpaper migration code doesn't exist in codebase anymore. So if 321 // Old wallpaper migration code doesn't exist in codebase anymore. So if
319 // user's profile is not migrated, it is the same as no wallpaper info. To 322 // user's profile is not migrated, it is the same as no wallpaper info. To
320 // simulate this, we remove user's wallpaper info here. 323 // simulate this, we remove user's wallpaper info here.
321 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); 324 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1);
322 } 325 }
323 326
324 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 327 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest,
325 UsePreMigrationWallpaperInfo) { 328 UsePreMigrationWallpaperInfo) {
326 LogIn(kTestUser1, kTestUser1Hash); 329 LogIn(kTestUser1, kTestUser1Hash);
327 WaitAsyncWallpaperLoadFinished(); 330 WaitAsyncWallpaperLoadFinished();
328 // This test should finish normally. If timeout, it is probably because chrome 331 // This test should finish normally. If timeout, it is probably because chrome
329 // can not handle pre migrated user profile (M21 profile or older). 332 // can not handle pre migrated user profile (M21 profile or older).
330 } 333 }
331 334
332 // Test for http://crbug.com/265689. When hooked up a large external monitor, 335 // Test for http://crbug.com/265689. When hooked up a large external monitor,
333 // the default large resolution wallpaper should load. 336 // the default large resolution wallpaper should load.
334 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, 337 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest,
335 HotPlugInScreenAtGAIALoginScreen) { 338 HotPlugInScreenAtGAIALoginScreen) {
336 UpdateDisplay("800x600"); 339 UpdateDisplay("800x600");
337 // Set initial wallpaper to the default wallpaper. 340 // Set initial wallpaper to the default wallpaper.
338 WallpaperManager::Get()->SetDefaultWallpaperNow(UserManager::kStubUser); 341 WallpaperManager::Get()->SetDefaultWallpaperNow(UserManager::kStubUser);
339 WaitAsyncWallpaperLoadFinished(); 342 WaitAsyncWallpaperLoadFinished();
340 343
341 // Hook up a 2000x2000 display. The large resolution custom wallpaper should 344 // Hook up a 2000x2000 display. The large resolution custom wallpaper should
342 // be loaded. 345 // be loaded.
343 UpdateDisplay("800x600,2000x2000"); 346 UpdateDisplay("800x600,2000x2000");
344 WaitAsyncWallpaperLoadFinished(); 347 WaitAsyncWallpaperLoadFinished();
345 } 348 }
346 349
347 class WallpaperManagerBrowserTestNoAnimation 350 class WallpaperManagerBrowserTestNoAnimation
348 : public WallpaperManagerBrowserTest { 351 : public WallpaperManagerBrowserTest {
349 public: 352 public:
350 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 353 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
351 command_line->AppendSwitch(switches::kLoginManager); 354 command_line->AppendSwitch(switches::kLoginManager);
352 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); 355 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
353 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); 356 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations);
354 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); 357 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation);
355 } 358 }
356 }; 359 };
357 360
358 // Same test as WallpaperManagerBrowserTest.UseMigratedWallpaperInfo. But 361 // Same test as WallpaperManagerBrowserTest.UseMigratedWallpaperInfo. But
359 // disabled boot and login animation. 362 // disabled boot and login animation.
360 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, 363 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation,
361 PRE_UseMigratedWallpaperInfo) { 364 PRE_UseMigratedWallpaperInfo) {
362 // New user log in, a default wallpaper is loaded. 365 // New user log in, a default wallpaper is loaded.
363 LogIn(kTestUser1, kTestUser1Hash); 366 LogIn(kTestUser1, kTestUser1Hash);
364 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user 367 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user
365 // wallpaper info directly to simulate the wallpaper migration. See 368 // wallpaper info directly to simulate the wallpaper migration. See
366 // crosbug.com/38429 for details about why we modify wallpaper info this way. 369 // crosbug.com/38429 for details about why we modify wallpaper info this way.
367 WallpaperInfo info = { 370 WallpaperInfo info = {
368 "123", 371 "123",
369 WALLPAPER_LAYOUT_CENTER_CROPPED, 372 WALLPAPER_LAYOUT_CENTER_CROPPED,
370 User::DEFAULT, 373 User::DEFAULT,
371 base::Time::Now().LocalMidnight() 374 base::Time::Now().LocalMidnight()
372 }; 375 };
373 base::FilePath user_data_dir; 376 base::FilePath user_data_dir;
374 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); 377 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
375 SaveUserWallpaperData(user_data_dir.Append("123"), 378 SaveUserWallpaperData(user_data_dir.Append("123"),
376 kLargeWallpaperResourceId); 379 kLargeWallpaperResourceId);
377 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); 380 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true);
378 } 381 }
379 382
380 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, 383 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation,
381 UseMigratedWallpaperInfo) { 384 UseMigratedWallpaperInfo) {
382 LogIn(kTestUser1, kTestUser1Hash); 385 LogIn(kTestUser1, kTestUser1Hash);
383 WaitAsyncWallpaperLoadFinished(); 386 WaitAsyncWallpaperLoadFinished();
384 // This test should finish normally. If timeout, it is probably because 387 // This test should finish normally. If timeout, it is probably because
385 // migrated wallpaper is somehow not loaded. Bad things can happen if 388 // migrated wallpaper is somehow not loaded. Bad things can happen if
386 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. 389 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429.
387 } 390 }
388 391
389 // Same test as WallpaperManagerBrowserTest.UsePreMigrationWallpaperInfo. But 392 // Same test as WallpaperManagerBrowserTest.UsePreMigrationWallpaperInfo. But
390 // disabled boot and login animation. 393 // disabled boot and login animation.
391 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, 394 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation,
392 PRE_UsePreMigrationWallpaperInfo) { 395 PRE_UsePreMigrationWallpaperInfo) {
393 // New user log in, a default wallpaper is loaded. 396 // New user log in, a default wallpaper is loaded.
394 LogIn(kTestUser1, kTestUser1Hash); 397 LogIn(kTestUser1, kTestUser1Hash);
395 WaitAsyncWallpaperLoadFinished(); 398 WaitAsyncWallpaperLoadFinished();
396 // Old wallpaper migration code doesn't exist in codebase anymore. So if 399 // Old wallpaper migration code doesn't exist in codebase anymore. So if
397 // user's profile is not migrated, it is the same as no wallpaper info. To 400 // user's profile is not migrated, it is the same as no wallpaper info. To
398 // simulate this, we remove user's wallpaper info here. 401 // simulate this, we remove user's wallpaper info here.
399 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); 402 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1);
400 } 403 }
401 404
402 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, 405 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation,
403 UsePreMigrationWallpaperInfo) { 406 UsePreMigrationWallpaperInfo) {
404 LogIn(kTestUser1, kTestUser1Hash); 407 LogIn(kTestUser1, kTestUser1Hash);
405 WaitAsyncWallpaperLoadFinished(); 408 WaitAsyncWallpaperLoadFinished();
406 // This test should finish normally. If timeout, it is probably because chrome 409 // This test should finish normally. If timeout, it is probably because chrome
407 // can not handle pre migrated user profile (M21 profile or older). 410 // can not handle pre migrated user profile (M21 profile or older).
408 } 411 }
409 412
410 class WallpaperManagerBrowserTestCrashRestore 413 class WallpaperManagerBrowserTestCrashRestore
411 : public WallpaperManagerBrowserTest { 414 : public WallpaperManagerBrowserTest {
412 public: 415 public:
413 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 416 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
414 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); 417 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations);
415 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); 418 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation);
416 command_line->AppendSwitch(::switches::kMultiProfiles); 419 command_line->AppendSwitch(::switches::kMultiProfiles);
417 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); 420 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1);
418 command_line->AppendSwitchASCII(switches::kLoginProfile, 421 command_line->AppendSwitchASCII(switches::kLoginProfile,
419 CryptohomeClient::GetStubSanitizedUsername(kTestUser1)); 422 CryptohomeClient::GetStubSanitizedUsername(kTestUser1));
420 } 423 }
421 }; 424 };
422 425
423 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCrashRestore, 426 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCrashRestore,
424 PRE_RestoreWallpaper) { 427 PRE_RestoreWallpaper) {
425 LogIn(kTestUser1, kTestUser1Hash); 428 LogIn(kTestUser1, kTestUser1Hash);
426 WaitAsyncWallpaperLoadFinished(); 429 WaitAsyncWallpaperLoadFinished();
427 } 430 }
428 431
429 // Test for crbug.com/270278. It simulates a browser crash and verifies if user 432 // Test for crbug.com/270278. It simulates a browser crash and verifies if user
430 // wallpaper is loaded. 433 // wallpaper is loaded.
431 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCrashRestore, 434 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCrashRestore,
432 RestoreWallpaper) { 435 RestoreWallpaper) {
433 EXPECT_EQ(1, LoadedWallpapers()); 436 EXPECT_EQ(1, LoadedWallpapers());
434 } 437 }
435 438
436 class WallpaperManagerBrowserTestCacheUpdate 439 class WallpaperManagerBrowserTestCacheUpdate
437 : public WallpaperManagerBrowserTest { 440 : public WallpaperManagerBrowserTest {
438 public: 441 public:
439 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 442 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
440 command_line->AppendSwitch(::switches::kMultiProfiles); 443 command_line->AppendSwitch(::switches::kMultiProfiles);
441 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); 444 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1);
442 command_line->AppendSwitchASCII(switches::kLoginProfile, 445 command_line->AppendSwitchASCII(switches::kLoginProfile,
443 CryptohomeClient::GetStubSanitizedUsername(kTestUser1)); 446 CryptohomeClient::GetStubSanitizedUsername(kTestUser1));
444 } 447 }
445 protected: 448 protected:
446 // Creates a test image of size 1x1. 449 // Creates a test image of size 1x1.
447 gfx::ImageSkia CreateTestImage(SkColor color) { 450 gfx::ImageSkia CreateTestImage(SkColor color) {
448 SkBitmap bitmap; 451 SkBitmap bitmap;
449 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); 452 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
450 bitmap.allocPixels(); 453 bitmap.allocPixels();
451 bitmap.eraseColor(color); 454 bitmap.eraseColor(color);
452 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 455 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
453 } 456 }
454 }; 457 };
455 458
456 // Sets kTestUser1's wallpaper to a custom wallpaper. 459 // Sets kTestUser1's wallpaper to a custom wallpaper.
457 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate, 460 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCacheUpdate,
458 PRE_VerifyWallpaperCache) { 461 PRE_VerifyWallpaperCache) {
459 // Add kTestUser1 to user list. kTestUser1 is the default login profile. 462 // Add kTestUser1 to user list. kTestUser1 is the default login profile.
460 LogIn(kTestUser1, kTestUser1Hash); 463 LogIn(kTestUser1, kTestUser1Hash);
461 464
462 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); 465 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue());
463 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 466 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
464 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( 467 base::FilePath small_wallpaper_path = GetCustomWallpaperPath(
465 kSmallWallpaperSubDir, 468 kSmallWallpaperSubDir,
466 kTestUser1Hash, 469 kTestUser1Hash,
467 id); 470 id);
(...skipping 29 matching lines...) Expand all
497 500
498 // Tests for crbug.com/339576. Wallpaper cache should be updated in 501 // Tests for crbug.com/339576. Wallpaper cache should be updated in
499 // multi-profile mode when user: 502 // multi-profile mode when user:
500 // 1. chooses an online wallpaper from wallpaper 503 // 1. chooses an online wallpaper from wallpaper
501 // picker(calls SetWallpaperFromImageSkia); 504 // picker(calls SetWallpaperFromImageSkia);
502 // 2. chooses a custom wallpaper from wallpaper 505 // 2. chooses a custom wallpaper from wallpaper
503 // picker(calls SetCustomWallpaper); 506 // picker(calls SetCustomWallpaper);
504 // 3. reverts to a default wallpaper. 507 // 3. reverts to a default wallpaper.
505 // Also, when user login at multi-profile mode, previous logged in users' 508 // Also, when user login at multi-profile mode, previous logged in users'
506 // wallpaper cache should not be deleted. 509 // wallpaper cache should not be deleted.
507 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate, 510 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCacheUpdate,
508 VerifyWallpaperCache) { 511 VerifyWallpaperCache) {
509 WaitAsyncWallpaperLoadFinished(); 512 WaitAsyncWallpaperLoadFinished();
510 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 513 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
511 scoped_ptr<WallpaperManager::TestApi> test_api; 514 scoped_ptr<WallpaperManager::TestApi> test_api;
512 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); 515 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager));
513 gfx::ImageSkia cached_wallpaper; 516 gfx::ImageSkia cached_wallpaper;
514 // Previous custom wallpaper should be cached after user login. 517 // Previous custom wallpaper should be cached after user login.
515 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); 518 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper));
516 519
517 LogIn(kTestUser2, kTestUser2Hash); 520 LogIn(kTestUser2, kTestUser2Hash);
(...skipping 27 matching lines...) Expand all
545 // turned on. 548 // turned on.
546 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); 549 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper));
547 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(green_wallpaper)); 550 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(green_wallpaper));
548 551
549 wallpaper_manager->SetDefaultWallpaperNow(kTestUser1); 552 wallpaper_manager->SetDefaultWallpaperNow(kTestUser1);
550 WaitAsyncWallpaperLoadFinished(); 553 WaitAsyncWallpaperLoadFinished();
551 // SetDefaultWallpaper should invalidate the user's wallpaper cache. 554 // SetDefaultWallpaper should invalidate the user's wallpaper cache.
552 EXPECT_FALSE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); 555 EXPECT_FALSE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper));
553 } 556 }
554 557
558 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestInstantiation,
559 WallpaperManagerBrowserTest,
560 testing::Bool());
561
562 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestNoAnimationInstantiation,
563 WallpaperManagerBrowserTestNoAnimation,
564 testing::Bool());
565
566 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestCrashRestoreInstantiation,
567 WallpaperManagerBrowserTestCrashRestore,
568 testing::Bool());
569
570 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestCacheUpdateInstantiation,
571 WallpaperManagerBrowserTestCacheUpdate,
572 testing::Bool());
573
555 } // namespace chromeos 574 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698