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 "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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 base::FilePath wallpaper_path = | 103 base::FilePath wallpaper_path = |
104 WallpaperManager::Get()->GetCustomWallpaperPath(sub_dir, | 104 WallpaperManager::Get()->GetCustomWallpaperPath(sub_dir, |
105 username_hash, | 105 username_hash, |
106 id); | 106 id); |
107 if (!base::DirectoryExists(wallpaper_path.DirName())) | 107 if (!base::DirectoryExists(wallpaper_path.DirName())) |
108 base::CreateDirectory(wallpaper_path.DirName()); | 108 base::CreateDirectory(wallpaper_path.DirName()); |
109 | 109 |
110 return wallpaper_path; | 110 return wallpaper_path; |
111 } | 111 } |
112 | 112 |
113 // Logs in |username|. | 113 // Logs in |user_id|. |
114 void LogIn(const std::string& username, const std::string& username_hash) { | 114 void LogIn(const AccountId& user_id, const std::string& user_id_hash) { |
115 user_manager::UserManager::Get()->UserLoggedIn( | 115 user_manager::UserManager::Get()->UserLoggedIn(user_id, user_id_hash, |
116 username, username_hash, false); | 116 false); |
117 WaitAsyncWallpaperLoadStarted(); | 117 WaitAsyncWallpaperLoadStarted(); |
118 } | 118 } |
119 | 119 |
120 // Logs in |username| and sets it as child account. | 120 // Logs in |user_id| and sets it as child account. |
121 void LogInAsChild( | 121 void LogInAsChild(const AccountId& user_id, const std::string& user_id_hash) { |
122 const std::string& username, const std::string& username_hash) { | 122 user_manager::UserManager::Get()->UserLoggedIn(user_id, user_id_hash, |
123 user_manager::UserManager::Get()->UserLoggedIn( | 123 false); |
124 username, username_hash, false); | |
125 user_manager::User* user = | 124 user_manager::User* user = |
126 user_manager::UserManager::Get()->FindUserAndModify(username); | 125 user_manager::UserManager::Get()->FindUserAndModify(user_id); |
127 user_manager::UserManager::Get()->ChangeUserChildStatus( | 126 user_manager::UserManager::Get()->ChangeUserChildStatus( |
128 user, true /* is_child */); | 127 user, true /* is_child */); |
129 } | 128 } |
130 | 129 |
131 int LoadedWallpapers() { | 130 int LoadedWallpapers() { |
132 return WallpaperManager::Get()->loaded_wallpapers_for_test(); | 131 return WallpaperManager::Get()->loaded_wallpapers_for_test(); |
133 } | 132 } |
134 | 133 |
135 void CacheUserWallpaper(const std::string& user) { | 134 void CacheUserWallpaper(const std::string& user) { |
136 WallpaperManager::Get()->CacheUserWallpaper(user); | 135 WallpaperManager::Get()->CacheUserWallpaper(user); |
(...skipping 24 matching lines...) Expand all Loading... |
161 | 160 |
162 private: | 161 private: |
163 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBrowserTest); | 162 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBrowserTest); |
164 }; | 163 }; |
165 | 164 |
166 // Tests that the appropriate custom wallpaper (large vs. small) is loaded | 165 // Tests that the appropriate custom wallpaper (large vs. small) is loaded |
167 // depending on the desktop resolution. | 166 // depending on the desktop resolution. |
168 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 167 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
169 LoadCustomLargeWallpaperForLargeExternalScreen) { | 168 LoadCustomLargeWallpaperForLargeExternalScreen) { |
170 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); | 169 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); |
171 LogIn(kTestUser1, kTestUser1Hash); | 170 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
172 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); | 171 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); |
173 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( | 172 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( |
174 wallpaper::kSmallWallpaperSubDir, kTestUser1Hash, id); | 173 wallpaper::kSmallWallpaperSubDir, kTestUser1Hash, id); |
175 base::FilePath large_wallpaper_path = GetCustomWallpaperPath( | 174 base::FilePath large_wallpaper_path = GetCustomWallpaperPath( |
176 wallpaper::kLargeWallpaperSubDir, kTestUser1Hash, id); | 175 wallpaper::kLargeWallpaperSubDir, kTestUser1Hash, id); |
177 | 176 |
178 // Saves the small/large resolution wallpapers to small/large custom | 177 // Saves the small/large resolution wallpapers to small/large custom |
179 // wallpaper paths. | 178 // wallpaper paths. |
180 ASSERT_TRUE(wallpaper_manager_test_utils::WriteJPEGFile( | 179 ASSERT_TRUE(wallpaper_manager_test_utils::WriteJPEGFile( |
181 small_wallpaper_path, | 180 small_wallpaper_path, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height()); | 236 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height()); |
238 } | 237 } |
239 | 238 |
240 // If chrome tries to reload the same wallpaper twice, the latter request should | 239 // If chrome tries to reload the same wallpaper twice, the latter request should |
241 // be prevented. Otherwise, there are some strange animation issues as | 240 // be prevented. Otherwise, there are some strange animation issues as |
242 // described in crbug.com/158383. | 241 // described in crbug.com/158383. |
243 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 242 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
244 PreventReloadingSameWallpaper) { | 243 PreventReloadingSameWallpaper) { |
245 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); | 244 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); |
246 // New user log in, a default wallpaper is loaded. | 245 // New user log in, a default wallpaper is loaded. |
247 LogIn(kTestUser1, kTestUser1Hash); | 246 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
248 EXPECT_EQ(1, LoadedWallpapers()); | 247 EXPECT_EQ(1, LoadedWallpapers()); |
249 // Loads the same wallpaper before the initial one finished. It should be | 248 // Loads the same wallpaper before the initial one finished. It should be |
250 // prevented. | 249 // prevented. |
251 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 250 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
252 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 251 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
253 EXPECT_EQ(1, LoadedWallpapers()); | 252 EXPECT_EQ(1, LoadedWallpapers()); |
254 // Loads the same wallpaper after the initial one finished. It should be | 253 // Loads the same wallpaper after the initial one finished. It should be |
255 // prevented. | 254 // prevented. |
256 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 255 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
257 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 256 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
(...skipping 30 matching lines...) Expand all Loading... |
288 EXPECT_EQ(2, LoadedWallpapers()); | 287 EXPECT_EQ(2, LoadedWallpapers()); |
289 } | 288 } |
290 | 289 |
291 // Some users have old user profiles which may have legacy wallpapers. And these | 290 // Some users have old user profiles which may have legacy wallpapers. And these |
292 // lagacy wallpapers should migrate to new wallpaper picker version seamlessly. | 291 // lagacy wallpapers should migrate to new wallpaper picker version seamlessly. |
293 // This tests make sure we compatible with migrated old wallpapers. | 292 // This tests make sure we compatible with migrated old wallpapers. |
294 // crosbug.com/38429 | 293 // crosbug.com/38429 |
295 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 294 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
296 PRE_UseMigratedWallpaperInfo) { | 295 PRE_UseMigratedWallpaperInfo) { |
297 // New user log in, a default wallpaper is loaded. | 296 // New user log in, a default wallpaper is loaded. |
298 LogIn(kTestUser1, kTestUser1Hash); | 297 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
299 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user | 298 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user |
300 // wallpaper info directly to simulate the wallpaper migration. See | 299 // wallpaper info directly to simulate the wallpaper migration. See |
301 // crosbug.com/38429 for details about why we modify wallpaper info this way. | 300 // crosbug.com/38429 for details about why we modify wallpaper info this way. |
302 WallpaperInfo info = {"123", WALLPAPER_LAYOUT_CENTER_CROPPED, | 301 WallpaperInfo info = {"123", WALLPAPER_LAYOUT_CENTER_CROPPED, |
303 user_manager::User::DEFAULT, | 302 user_manager::User::DEFAULT, |
304 base::Time::Now().LocalMidnight()}; | 303 base::Time::Now().LocalMidnight()}; |
305 base::FilePath user_data_dir; | 304 base::FilePath user_data_dir; |
306 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 305 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
307 ASSERT_TRUE(wallpaper_manager_test_utils::WriteJPEGFile( | 306 ASSERT_TRUE(wallpaper_manager_test_utils::WriteJPEGFile( |
308 user_data_dir.Append("123"), | 307 user_data_dir.Append("123"), |
309 wallpaper_manager_test_utils::kWallpaperSize, | 308 wallpaper_manager_test_utils::kWallpaperSize, |
310 wallpaper_manager_test_utils::kWallpaperSize, | 309 wallpaper_manager_test_utils::kWallpaperSize, |
311 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 310 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
312 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); | 311 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); |
313 } | 312 } |
314 | 313 |
315 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 314 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
316 UseMigratedWallpaperInfo) { | 315 UseMigratedWallpaperInfo) { |
317 LogIn(kTestUser1, kTestUser1Hash); | 316 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
318 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 317 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
319 // This test should finish normally. If timeout, it is probably because | 318 // This test should finish normally. If timeout, it is probably because |
320 // migrated wallpaper is somehow not loaded. Bad things can happen if | 319 // migrated wallpaper is somehow not loaded. Bad things can happen if |
321 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. | 320 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. |
322 } | 321 } |
323 | 322 |
324 // Some users have old user profiles which may never get a chance to migrate. | 323 // Some users have old user profiles which may never get a chance to migrate. |
325 // This tests make sure we compatible with these profiles. | 324 // This tests make sure we compatible with these profiles. |
326 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 325 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
327 PRE_UsePreMigrationWallpaperInfo) { | 326 PRE_UsePreMigrationWallpaperInfo) { |
328 // New user log in, a default wallpaper is loaded. | 327 // New user log in, a default wallpaper is loaded. |
329 LogIn(kTestUser1, kTestUser1Hash); | 328 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
330 // Old wallpaper migration code doesn't exist in codebase anymore. So if | 329 // Old wallpaper migration code doesn't exist in codebase anymore. So if |
331 // user's profile is not migrated, it is the same as no wallpaper info. To | 330 // user's profile is not migrated, it is the same as no wallpaper info. To |
332 // simulate this, we remove user's wallpaper info here. | 331 // simulate this, we remove user's wallpaper info here. |
333 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); | 332 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); |
334 } | 333 } |
335 | 334 |
336 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 335 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
337 UsePreMigrationWallpaperInfo) { | 336 UsePreMigrationWallpaperInfo) { |
338 LogIn(kTestUser1, kTestUser1Hash); | 337 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
339 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 338 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
340 // This test should finish normally. If timeout, it is probably because chrome | 339 // This test should finish normally. If timeout, it is probably because chrome |
341 // can not handle pre migrated user profile (M21 profile or older). | 340 // can not handle pre migrated user profile (M21 profile or older). |
342 } | 341 } |
343 | 342 |
344 // Test for http://crbug.com/265689. When hooked up a large external monitor, | 343 // Test for http://crbug.com/265689. When hooked up a large external monitor, |
345 // the default large resolution wallpaper should load. | 344 // the default large resolution wallpaper should load. |
346 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 345 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
347 HotPlugInScreenAtGAIALoginScreen) { | 346 HotPlugInScreenAtGAIALoginScreen) { |
348 UpdateDisplay("800x600"); | 347 UpdateDisplay("800x600"); |
(...skipping 16 matching lines...) Expand all Loading... |
365 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); | 364 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); |
366 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); | 365 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); |
367 } | 366 } |
368 }; | 367 }; |
369 | 368 |
370 // Same test as WallpaperManagerBrowserTest.UseMigratedWallpaperInfo. But | 369 // Same test as WallpaperManagerBrowserTest.UseMigratedWallpaperInfo. But |
371 // disabled boot and login animation. | 370 // disabled boot and login animation. |
372 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, | 371 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, |
373 PRE_UseMigratedWallpaperInfo) { | 372 PRE_UseMigratedWallpaperInfo) { |
374 // New user log in, a default wallpaper is loaded. | 373 // New user log in, a default wallpaper is loaded. |
375 LogIn(kTestUser1, kTestUser1Hash); | 374 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
376 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user | 375 // Old wallpaper migration code doesn't exist in codebase anymore. Modify user |
377 // wallpaper info directly to simulate the wallpaper migration. See | 376 // wallpaper info directly to simulate the wallpaper migration. See |
378 // crosbug.com/38429 for details about why we modify wallpaper info this way. | 377 // crosbug.com/38429 for details about why we modify wallpaper info this way. |
379 WallpaperInfo info = {"123", WALLPAPER_LAYOUT_CENTER_CROPPED, | 378 WallpaperInfo info = {"123", WALLPAPER_LAYOUT_CENTER_CROPPED, |
380 user_manager::User::DEFAULT, | 379 user_manager::User::DEFAULT, |
381 base::Time::Now().LocalMidnight()}; | 380 base::Time::Now().LocalMidnight()}; |
382 base::FilePath user_data_dir; | 381 base::FilePath user_data_dir; |
383 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 382 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
384 ASSERT_TRUE(wallpaper_manager_test_utils::WriteJPEGFile( | 383 ASSERT_TRUE(wallpaper_manager_test_utils::WriteJPEGFile( |
385 user_data_dir.Append("123"), | 384 user_data_dir.Append("123"), |
386 wallpaper_manager_test_utils::kWallpaperSize, | 385 wallpaper_manager_test_utils::kWallpaperSize, |
387 wallpaper_manager_test_utils::kWallpaperSize, | 386 wallpaper_manager_test_utils::kWallpaperSize, |
388 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 387 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
389 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); | 388 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); |
390 } | 389 } |
391 | 390 |
392 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, | 391 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, |
393 UseMigratedWallpaperInfo) { | 392 UseMigratedWallpaperInfo) { |
394 LogIn(kTestUser1, kTestUser1Hash); | 393 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
395 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 394 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
396 // This test should finish normally. If timeout, it is probably because | 395 // This test should finish normally. If timeout, it is probably because |
397 // migrated wallpaper is somehow not loaded. Bad things can happen if | 396 // migrated wallpaper is somehow not loaded. Bad things can happen if |
398 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. | 397 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. |
399 } | 398 } |
400 | 399 |
401 // Same test as WallpaperManagerBrowserTest.UsePreMigrationWallpaperInfo. But | 400 // Same test as WallpaperManagerBrowserTest.UsePreMigrationWallpaperInfo. But |
402 // disabled boot and login animation. | 401 // disabled boot and login animation. |
403 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, | 402 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, |
404 PRE_UsePreMigrationWallpaperInfo) { | 403 PRE_UsePreMigrationWallpaperInfo) { |
405 // New user log in, a default wallpaper is loaded. | 404 // New user log in, a default wallpaper is loaded. |
406 LogIn(kTestUser1, kTestUser1Hash); | 405 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
407 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 406 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
408 // Old wallpaper migration code doesn't exist in codebase anymore. So if | 407 // Old wallpaper migration code doesn't exist in codebase anymore. So if |
409 // user's profile is not migrated, it is the same as no wallpaper info. To | 408 // user's profile is not migrated, it is the same as no wallpaper info. To |
410 // simulate this, we remove user's wallpaper info here. | 409 // simulate this, we remove user's wallpaper info here. |
411 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); | 410 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); |
412 } | 411 } |
413 | 412 |
414 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, | 413 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestNoAnimation, |
415 UsePreMigrationWallpaperInfo) { | 414 UsePreMigrationWallpaperInfo) { |
416 LogIn(kTestUser1, kTestUser1Hash); | 415 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
417 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 416 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
418 // This test should finish normally. If timeout, it is probably because chrome | 417 // This test should finish normally. If timeout, it is probably because chrome |
419 // can not handle pre migrated user profile (M21 profile or older). | 418 // can not handle pre migrated user profile (M21 profile or older). |
420 } | 419 } |
421 | 420 |
422 class WallpaperManagerBrowserTestCrashRestore | 421 class WallpaperManagerBrowserTestCrashRestore |
423 : public WallpaperManagerBrowserTest { | 422 : public WallpaperManagerBrowserTest { |
424 public: | 423 public: |
425 void SetUpCommandLine(base::CommandLine* command_line) override { | 424 void SetUpCommandLine(base::CommandLine* command_line) override { |
426 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); | 425 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); |
427 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); | 426 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); |
428 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); | 427 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); |
429 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 428 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
430 } | 429 } |
431 }; | 430 }; |
432 | 431 |
433 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCrashRestore, | 432 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCrashRestore, |
434 PRE_RestoreWallpaper) { | 433 PRE_RestoreWallpaper) { |
435 LogIn(kTestUser1, kTestUser1Hash); | 434 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
436 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 435 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
437 } | 436 } |
438 | 437 |
439 // Test for crbug.com/270278. It simulates a browser crash and verifies if user | 438 // Test for crbug.com/270278. It simulates a browser crash and verifies if user |
440 // wallpaper is loaded. | 439 // wallpaper is loaded. |
441 // Fails on the MSAN bots. See http://crbug.com/444477 | 440 // Fails on the MSAN bots. See http://crbug.com/444477 |
442 #if defined(MEMORY_SANITIZER) | 441 #if defined(MEMORY_SANITIZER) |
443 #define MAYBE_RestoreWallpaper DISABLED_RestoreWallpaper | 442 #define MAYBE_RestoreWallpaper DISABLED_RestoreWallpaper |
444 #else | 443 #else |
445 #define MAYBE_RestoreWallpaper RestoreWallpaper | 444 #define MAYBE_RestoreWallpaper RestoreWallpaper |
(...skipping 14 matching lines...) Expand all Loading... |
460 // Creates a test image of size 1x1. | 459 // Creates a test image of size 1x1. |
461 gfx::ImageSkia CreateTestImage(SkColor color) { | 460 gfx::ImageSkia CreateTestImage(SkColor color) { |
462 return wallpaper_manager_test_utils::CreateTestImage(1, 1, color); | 461 return wallpaper_manager_test_utils::CreateTestImage(1, 1, color); |
463 } | 462 } |
464 }; | 463 }; |
465 | 464 |
466 // Sets kTestUser1's wallpaper to a custom wallpaper. | 465 // Sets kTestUser1's wallpaper to a custom wallpaper. |
467 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate, | 466 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate, |
468 PRE_VerifyWallpaperCache) { | 467 PRE_VerifyWallpaperCache) { |
469 // Add kTestUser1 to user list. kTestUser1 is the default login profile. | 468 // Add kTestUser1 to user list. kTestUser1 is the default login profile. |
470 LogIn(kTestUser1, kTestUser1Hash); | 469 LogIn(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
471 | 470 |
472 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); | 471 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); |
473 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); | 472 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); |
474 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( | 473 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( |
475 wallpaper::kSmallWallpaperSubDir, kTestUser1Hash, id); | 474 wallpaper::kSmallWallpaperSubDir, kTestUser1Hash, id); |
476 base::FilePath large_wallpaper_path = GetCustomWallpaperPath( | 475 base::FilePath large_wallpaper_path = GetCustomWallpaperPath( |
477 wallpaper::kLargeWallpaperSubDir, kTestUser1Hash, id); | 476 wallpaper::kLargeWallpaperSubDir, kTestUser1Hash, id); |
478 | 477 |
479 // Saves the small/large resolution wallpapers to small/large custom | 478 // Saves the small/large resolution wallpapers to small/large custom |
480 // wallpaper paths. | 479 // wallpaper paths. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 525 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
527 scoped_ptr<WallpaperManager::TestApi> test_api; | 526 scoped_ptr<WallpaperManager::TestApi> test_api; |
528 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); | 527 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); |
529 gfx::ImageSkia cached_wallpaper; | 528 gfx::ImageSkia cached_wallpaper; |
530 // Previous custom wallpaper should be cached after user login. | 529 // Previous custom wallpaper should be cached after user login. |
531 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 530 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
532 base::FilePath original_path; | 531 base::FilePath original_path; |
533 EXPECT_TRUE(test_api->GetPathFromCache(kTestUser1, &original_path)); | 532 EXPECT_TRUE(test_api->GetPathFromCache(kTestUser1, &original_path)); |
534 EXPECT_FALSE(original_path.empty()); | 533 EXPECT_FALSE(original_path.empty()); |
535 | 534 |
536 LogIn(kTestUser2, kTestUser2Hash); | 535 LogIn(AccountId::FromUserEmail(kTestUser2), kTestUser2Hash); |
537 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 536 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
538 // Login another user should not delete logged in user's wallpaper cache. | 537 // Login another user should not delete logged in user's wallpaper cache. |
539 // Note active user is still kTestUser1. | 538 // Note active user is still kTestUser1. |
540 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 539 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
541 base::FilePath path; | 540 base::FilePath path; |
542 EXPECT_TRUE(test_api->GetPathFromCache(kTestUser1, &path)); | 541 EXPECT_TRUE(test_api->GetPathFromCache(kTestUser1, &path)); |
543 EXPECT_EQ(original_path, path); | 542 EXPECT_EQ(original_path, path); |
544 | 543 |
545 gfx::ImageSkia red_wallpaper = CreateTestImage(SK_ColorRED); | 544 gfx::ImageSkia red_wallpaper = CreateTestImage(SK_ColorRED); |
546 wallpaper_manager->SetWallpaperFromImageSkia(kTestUser1, | 545 wallpaper_manager->SetWallpaperFromImageSkia(kTestUser1, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 746 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
748 controller_->GetWallpaper(), | 747 controller_->GetWallpaper(), |
749 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); | 748 wallpaper_manager_test_utils::kLargeDefaultWallpaperColor)); |
750 } | 749 } |
751 | 750 |
752 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { | 751 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallGuestWallpaper) { |
753 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 752 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
754 return; | 753 return; |
755 CreateCmdlineWallpapers(); | 754 CreateCmdlineWallpapers(); |
756 user_manager::UserManager::Get()->UserLoggedIn( | 755 user_manager::UserManager::Get()->UserLoggedIn( |
757 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); | 756 chromeos::login::GuestAccountId(), chromeos::login::kGuestUserName, |
| 757 false); |
758 UpdateDisplay("800x600"); | 758 UpdateDisplay("800x600"); |
759 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 759 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
760 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 760 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
761 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 761 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
762 controller_->GetWallpaper(), | 762 controller_->GetWallpaper(), |
763 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); | 763 wallpaper_manager_test_utils::kSmallGuestWallpaperColor)); |
764 } | 764 } |
765 | 765 |
766 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { | 766 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeGuestWallpaper) { |
767 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 767 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
768 return; | 768 return; |
769 | 769 |
770 CreateCmdlineWallpapers(); | 770 CreateCmdlineWallpapers(); |
771 user_manager::UserManager::Get()->UserLoggedIn( | 771 user_manager::UserManager::Get()->UserLoggedIn( |
772 chromeos::login::kGuestUserName, chromeos::login::kGuestUserName, false); | 772 chromeos::login::GuestAccountId(), chromeos::login::kGuestUserName, |
| 773 false); |
773 UpdateDisplay("1600x1200"); | 774 UpdateDisplay("1600x1200"); |
774 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 775 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
775 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 776 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
776 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 777 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
777 controller_->GetWallpaper(), | 778 controller_->GetWallpaper(), |
778 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); | 779 wallpaper_manager_test_utils::kLargeGuestWallpaperColor)); |
779 } | 780 } |
780 | 781 |
781 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallChildWallpaper) { | 782 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, SmallChildWallpaper) { |
782 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 783 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
783 return; | 784 return; |
784 CreateCmdlineWallpapers(); | 785 CreateCmdlineWallpapers(); |
785 LogInAsChild(kTestUser1, kTestUser1Hash); | 786 LogInAsChild(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
786 UpdateDisplay("800x600"); | 787 UpdateDisplay("800x600"); |
787 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 788 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
788 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 789 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
789 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 790 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
790 controller_->GetWallpaper(), | 791 controller_->GetWallpaper(), |
791 wallpaper_manager_test_utils::kSmallChildWallpaperColor)); | 792 wallpaper_manager_test_utils::kSmallChildWallpaperColor)); |
792 } | 793 } |
793 | 794 |
794 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeChildWallpaper) { | 795 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, LargeChildWallpaper) { |
795 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 796 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
796 return; | 797 return; |
797 | 798 |
798 CreateCmdlineWallpapers(); | 799 CreateCmdlineWallpapers(); |
799 LogInAsChild(kTestUser1, kTestUser1Hash); | 800 LogInAsChild(AccountId::FromUserEmail(kTestUser1), kTestUser1Hash); |
800 UpdateDisplay("1600x1200"); | 801 UpdateDisplay("1600x1200"); |
801 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 802 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
802 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 803 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
803 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 804 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
804 controller_->GetWallpaper(), | 805 controller_->GetWallpaper(), |
805 wallpaper_manager_test_utils::kLargeChildWallpaperColor)); | 806 wallpaper_manager_test_utils::kLargeChildWallpaperColor)); |
806 } | 807 } |
807 | 808 |
808 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 809 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
809 SwitchBetweenDefaultAndCustom) { | 810 SwitchBetweenDefaultAndCustom) { |
810 // Start loading the default wallpaper. | 811 // Start loading the default wallpaper. |
811 UpdateDisplay("640x480"); | 812 UpdateDisplay("640x480"); |
812 CreateCmdlineWallpapers(); | 813 CreateCmdlineWallpapers(); |
813 user_manager::UserManager::Get()->UserLoggedIn( | 814 user_manager::UserManager::Get()->UserLoggedIn( |
814 chromeos::login::kStubUser, "test_hash", false); | 815 chromeos::login::StubAccountId(), "test_hash", false); |
815 | 816 |
816 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 817 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
817 | 818 |
818 // Custom wallpaper should be applied immediately, canceling the default | 819 // Custom wallpaper should be applied immediately, canceling the default |
819 // wallpaper load task. | 820 // wallpaper load task. |
820 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( | 821 gfx::ImageSkia image = wallpaper_manager_test_utils::CreateTestImage( |
821 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); | 822 640, 480, wallpaper_manager_test_utils::kCustomWallpaperColor); |
822 WallpaperManager::Get()->SetCustomWallpaper(chromeos::login::kStubUser, | 823 WallpaperManager::Get()->SetCustomWallpaper(chromeos::login::kStubUser, |
823 "test_hash", | 824 "test_hash", |
824 "test-nofile.jpeg", | 825 "test-nofile.jpeg", |
825 WALLPAPER_LAYOUT_STRETCH, | 826 WALLPAPER_LAYOUT_STRETCH, |
826 user_manager::User::CUSTOMIZED, | 827 user_manager::User::CUSTOMIZED, |
827 image, | 828 image, |
828 true); | 829 true); |
829 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 830 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
830 | 831 |
831 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 832 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
832 controller_->GetWallpaper(), | 833 controller_->GetWallpaper(), |
833 wallpaper_manager_test_utils::kCustomWallpaperColor)); | 834 wallpaper_manager_test_utils::kCustomWallpaperColor)); |
834 | 835 |
835 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 836 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
836 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); | 837 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); |
837 | 838 |
838 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( | 839 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( |
839 controller_->GetWallpaper(), | 840 controller_->GetWallpaper(), |
840 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); | 841 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); |
841 } | 842 } |
842 | 843 |
843 } // namespace chromeos | 844 } // namespace chromeos |
OLD | NEW |