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

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

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/desktop_background/desktop_background_controller.h" 9 #include "ash/desktop_background/desktop_background_controller.h"
10 #include "ash/desktop_background/desktop_background_controller_observer.h" 10 #include "ash/desktop_background/desktop_background_controller_observer.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // default wallpapers. 150 // default wallpapers.
151 void CreateCmdlineWallpapers() { 151 void CreateCmdlineWallpapers() {
152 wallpaper_dir_.reset(new base::ScopedTempDir); 152 wallpaper_dir_.reset(new base::ScopedTempDir);
153 ASSERT_TRUE(wallpaper_dir_->CreateUniqueTempDir()); 153 ASSERT_TRUE(wallpaper_dir_->CreateUniqueTempDir());
154 wallpaper_manager_test_utils::CreateCmdlineWallpapers( 154 wallpaper_manager_test_utils::CreateCmdlineWallpapers(
155 *wallpaper_dir_, &wallpaper_manager_command_line_); 155 *wallpaper_dir_, &wallpaper_manager_command_line_);
156 } 156 }
157 157
158 ash::DesktopBackgroundController* controller_; 158 ash::DesktopBackgroundController* controller_;
159 PrefService* local_state_; 159 PrefService* local_state_;
160 scoped_ptr<base::CommandLine> wallpaper_manager_command_line_; 160 std::unique_ptr<base::CommandLine> wallpaper_manager_command_line_;
161 161
162 // Directory created by CreateCmdlineWallpapers () to store default 162 // Directory created by CreateCmdlineWallpapers () to store default
163 // wallpaper images. 163 // wallpaper images.
164 scoped_ptr<base::ScopedTempDir> wallpaper_dir_; 164 std::unique_ptr<base::ScopedTempDir> wallpaper_dir_;
165 165
166 const AccountId test_account_id1_ = AccountId::FromUserEmail(kTestUser1); 166 const AccountId test_account_id1_ = AccountId::FromUserEmail(kTestUser1);
167 const AccountId test_account_id2_ = AccountId::FromUserEmail(kTestUser2); 167 const AccountId test_account_id2_ = AccountId::FromUserEmail(kTestUser2);
168 168
169 const wallpaper::WallpaperFilesId test_account1_wallpaper_files_id_ = 169 const wallpaper::WallpaperFilesId test_account1_wallpaper_files_id_ =
170 wallpaper::WallpaperFilesId::FromString(kTestUser1Hash); 170 wallpaper::WallpaperFilesId::FromString(kTestUser1Hash);
171 const wallpaper::WallpaperFilesId test_account2_wallpaper_files_id_ = 171 const wallpaper::WallpaperFilesId test_account2_wallpaper_files_id_ =
172 wallpaper::WallpaperFilesId::FromString(kTestUser2Hash); 172 wallpaper::WallpaperFilesId::FromString(kTestUser2Hash);
173 173
174 private: 174 private:
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 508
509 std::string relative_path = 509 std::string relative_path =
510 base::FilePath(test_account1_wallpaper_files_id_.id()).Append(id).value(); 510 base::FilePath(test_account1_wallpaper_files_id_.id()).Append(id).value();
511 // Saves wallpaper info to local state for user |test_account_id1_|. 511 // Saves wallpaper info to local state for user |test_account_id1_|.
512 WallpaperInfo info = {relative_path, WALLPAPER_LAYOUT_CENTER_CROPPED, 512 WallpaperInfo info = {relative_path, WALLPAPER_LAYOUT_CENTER_CROPPED,
513 user_manager::User::CUSTOMIZED, 513 user_manager::User::CUSTOMIZED,
514 base::Time::Now().LocalMidnight()}; 514 base::Time::Now().LocalMidnight()};
515 wallpaper_manager->SetUserWallpaperInfo(test_account_id1_, info, true); 515 wallpaper_manager->SetUserWallpaperInfo(test_account_id1_, info, true);
516 wallpaper_manager->SetUserWallpaperNow(test_account_id1_); 516 wallpaper_manager->SetUserWallpaperNow(test_account_id1_);
517 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); 517 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished();
518 scoped_ptr<WallpaperManager::TestApi> test_api; 518 std::unique_ptr<WallpaperManager::TestApi> test_api;
519 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); 519 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager));
520 // Verify SetUserWallpaperNow updates wallpaper cache. 520 // Verify SetUserWallpaperNow updates wallpaper cache.
521 gfx::ImageSkia cached_wallpaper; 521 gfx::ImageSkia cached_wallpaper;
522 EXPECT_TRUE( 522 EXPECT_TRUE(
523 test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper)); 523 test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper));
524 base::FilePath path; 524 base::FilePath path;
525 EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &path)); 525 EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &path));
526 EXPECT_FALSE(path.empty()); 526 EXPECT_FALSE(path.empty());
527 } 527 }
528 528
529 // Tests for crbug.com/339576. Wallpaper cache should be updated in 529 // Tests for crbug.com/339576. Wallpaper cache should be updated in
530 // multi-profile mode when user: 530 // multi-profile mode when user:
531 // 1. chooses an online wallpaper from wallpaper 531 // 1. chooses an online wallpaper from wallpaper
532 // picker (calls SetWallpaperFromImageSkia); 532 // picker (calls SetWallpaperFromImageSkia);
533 // 2. chooses a custom wallpaper from wallpaper 533 // 2. chooses a custom wallpaper from wallpaper
534 // picker (calls SetCustomWallpaper); 534 // picker (calls SetCustomWallpaper);
535 // 3. reverts to a default wallpaper. 535 // 3. reverts to a default wallpaper.
536 // Also, when user login at multi-profile mode, previous logged in users' 536 // Also, when user login at multi-profile mode, previous logged in users'
537 // wallpaper cache should not be deleted. 537 // wallpaper cache should not be deleted.
538 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate, 538 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTestCacheUpdate,
539 VerifyWallpaperCache) { 539 VerifyWallpaperCache) {
540 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); 540 WallpaperManager* wallpaper_manager = WallpaperManager::Get();
541 541
542 // Force load initial wallpaper 542 // Force load initial wallpaper
543 // (simulate DesktopBackgroundController::UpdateDisplay()). 543 // (simulate DesktopBackgroundController::UpdateDisplay()).
544 wallpaper_manager->UpdateWallpaper(true); 544 wallpaper_manager->UpdateWallpaper(true);
545 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); 545 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished();
546 scoped_ptr<WallpaperManager::TestApi> test_api; 546 std::unique_ptr<WallpaperManager::TestApi> test_api;
547 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); 547 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager));
548 gfx::ImageSkia cached_wallpaper; 548 gfx::ImageSkia cached_wallpaper;
549 // Previous custom wallpaper should be cached after user login. 549 // Previous custom wallpaper should be cached after user login.
550 EXPECT_TRUE( 550 EXPECT_TRUE(
551 test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper)); 551 test_api->GetWallpaperFromCache(test_account_id1_, &cached_wallpaper));
552 base::FilePath original_path; 552 base::FilePath original_path;
553 EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &original_path)); 553 EXPECT_TRUE(test_api->GetPathFromCache(test_account_id1_, &original_path));
554 EXPECT_FALSE(original_path.empty()); 554 EXPECT_FALSE(original_path.empty());
555 555
556 LogIn(test_account_id2_, kTestUser2Hash); 556 LogIn(test_account_id2_, kTestUser2Hash);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 853
854 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); 854 WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId());
855 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); 855 wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished();
856 856
857 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( 857 EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor(
858 controller_->GetWallpaper(), 858 controller_->GetWallpaper(),
859 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); 859 wallpaper_manager_test_utils::kSmallDefaultWallpaperColor));
860 } 860 }
861 861
862 } // namespace chromeos 862 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698