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