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