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

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_unittest.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"
6
5 #include <cstdlib> 7 #include <cstdlib>
6 #include <cstring> 8 #include <cstring>
9 #include <memory>
7 10
8 #include "ash/desktop_background/desktop_background_controller.h" 11 #include "ash/desktop_background/desktop_background_controller.h"
9 #include "ash/desktop_background/desktop_background_controller_observer.h" 12 #include "ash/desktop_background/desktop_background_controller_observer.h"
10 #include "ash/shell.h" 13 #include "ash/shell.h"
11 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
12 #include "ash/test/display_manager_test_api.h" 15 #include "ash/test/display_manager_test_api.h"
13 #include "ash/test/test_user_wallpaper_delegate.h" 16 #include "ash/test/test_user_wallpaper_delegate.h"
14 #include "base/command_line.h" 17 #include "base/command_line.h"
15 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
17 #include "base/files/scoped_temp_dir.h" 20 #include "base/files/scoped_temp_dir.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "chrome/browser/chromeos/login/startup_utils.h" 21 #include "chrome/browser/chromeos/login/startup_utils.h"
20 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 22 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
21 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 23 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
22 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
23 #include "chrome/browser/chromeos/settings/cros_settings.h" 24 #include "chrome/browser/chromeos/settings/cros_settings.h"
24 #include "chrome/browser/chromeos/settings/device_settings_service.h" 25 #include "chrome/browser/chromeos/settings/device_settings_service.h"
25 #include "chrome/browser/prefs/browser_prefs.h" 26 #include "chrome/browser/prefs/browser_prefs.h"
26 #include "chrome/test/base/testing_browser_process.h" 27 #include "chrome/test/base/testing_browser_process.h"
27 #include "chromeos/chromeos_switches.h" 28 #include "chromeos/chromeos_switches.h"
28 #include "chromeos/settings/cros_settings_names.h" 29 #include "chromeos/settings/cros_settings_names.h"
29 #include "chromeos/settings/cros_settings_provider.h" 30 #include "chromeos/settings/cros_settings_provider.h"
30 #include "components/prefs/pref_service.h" 31 #include "components/prefs/pref_service.h"
31 #include "components/prefs/testing_pref_service.h" 32 #include "components/prefs/testing_pref_service.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 base::FilePath path2("path2"); 83 base::FilePath path2("path2");
83 base::FilePath path3("path3"); 84 base::FilePath path3("path3");
84 fake_user_manager()->AddUser(test_account_id_1); 85 fake_user_manager()->AddUser(test_account_id_1);
85 fake_user_manager()->AddUser(test_account_id_2); 86 fake_user_manager()->AddUser(test_account_id_2);
86 fake_user_manager()->AddUser(test_account_id_3); 87 fake_user_manager()->AddUser(test_account_id_3);
87 88
88 // Login two users. 89 // Login two users.
89 fake_user_manager()->LoginUser(test_account_id_1); 90 fake_user_manager()->LoginUser(test_account_id_1);
90 fake_user_manager()->LoginUser(test_account_id_2); 91 fake_user_manager()->LoginUser(test_account_id_2);
91 92
92 scoped_ptr<WallpaperManager::TestApi> test_api; 93 std::unique_ptr<WallpaperManager::TestApi> test_api;
93 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get())); 94 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get()));
94 95
95 gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED); 96 gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED);
96 gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN); 97 gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN);
97 gfx::ImageSkia test_user_3_wallpaper = CreateTestImage(SK_ColorWHITE); 98 gfx::ImageSkia test_user_3_wallpaper = CreateTestImage(SK_ColorWHITE);
98 test_api->SetWallpaperCache(test_account_id_1, path1, test_user_1_wallpaper); 99 test_api->SetWallpaperCache(test_account_id_1, path1, test_user_1_wallpaper);
99 test_api->SetWallpaperCache(test_account_id_2, path2, test_user_2_wallpaper); 100 test_api->SetWallpaperCache(test_account_id_2, path2, test_user_2_wallpaper);
100 test_api->SetWallpaperCache(test_account_id_3, path3, test_user_3_wallpaper); 101 test_api->SetWallpaperCache(test_account_id_3, path3, test_user_3_wallpaper);
101 102
102 test_api->ClearDisposableWallpaperCache(); 103 test_api->ClearDisposableWallpaperCache();
(...skipping 22 matching lines...) Expand all
125 TEST_F(WallpaperManagerCacheTest, CacheClearedOnUserRemoval) { 126 TEST_F(WallpaperManagerCacheTest, CacheClearedOnUserRemoval) {
126 const AccountId test_account_id_1 = 127 const AccountId test_account_id_1 =
127 AccountId::FromUserEmail("test1@example.com"); 128 AccountId::FromUserEmail("test1@example.com");
128 const AccountId test_account_id_2 = 129 const AccountId test_account_id_2 =
129 AccountId::FromUserEmail("test2@example.com"); 130 AccountId::FromUserEmail("test2@example.com");
130 const base::FilePath path1("user1_custom_path"); 131 const base::FilePath path1("user1_custom_path");
131 const base::FilePath path2("user2_custom_path"); 132 const base::FilePath path2("user2_custom_path");
132 fake_user_manager()->AddUser(test_account_id_1); 133 fake_user_manager()->AddUser(test_account_id_1);
133 fake_user_manager()->AddUser(test_account_id_2); 134 fake_user_manager()->AddUser(test_account_id_2);
134 135
135 scoped_ptr<WallpaperManager::TestApi> test_api( 136 std::unique_ptr<WallpaperManager::TestApi> test_api(
136 new WallpaperManager::TestApi(WallpaperManager::Get())); 137 new WallpaperManager::TestApi(WallpaperManager::Get()));
137 138
138 const gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED); 139 const gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED);
139 const gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN); 140 const gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN);
140 test_api->SetWallpaperCache(test_account_id_1, path1, test_user_1_wallpaper); 141 test_api->SetWallpaperCache(test_account_id_1, path1, test_user_1_wallpaper);
141 test_api->SetWallpaperCache(test_account_id_2, path2, test_user_2_wallpaper); 142 test_api->SetWallpaperCache(test_account_id_2, path2, test_user_2_wallpaper);
142 143
143 gfx::ImageSkia cached_wallpaper; 144 gfx::ImageSkia cached_wallpaper;
144 // Test that both user1 and user2's wallpaper can be found in cache. 145 // Test that both user1 and user2's wallpaper can be found in cache.
145 EXPECT_TRUE( 146 EXPECT_TRUE(
146 test_api->GetWallpaperFromCache(test_account_id_1, &cached_wallpaper)); 147 test_api->GetWallpaperFromCache(test_account_id_1, &cached_wallpaper));
147 EXPECT_TRUE( 148 EXPECT_TRUE(
148 test_api->GetWallpaperFromCache(test_account_id_2, &cached_wallpaper)); 149 test_api->GetWallpaperFromCache(test_account_id_2, &cached_wallpaper));
149 150
150 // Remove user2. 151 // Remove user2.
151 fake_user_manager()->RemoveUserFromList(test_account_id_2); 152 fake_user_manager()->RemoveUserFromList(test_account_id_2);
152 153
153 // Test that only user1's wallpaper can be found in cache. 154 // Test that only user1's wallpaper can be found in cache.
154 EXPECT_TRUE( 155 EXPECT_TRUE(
155 test_api->GetWallpaperFromCache(test_account_id_1, &cached_wallpaper)); 156 test_api->GetWallpaperFromCache(test_account_id_1, &cached_wallpaper));
156 EXPECT_FALSE( 157 EXPECT_FALSE(
157 test_api->GetWallpaperFromCache(test_account_id_2, &cached_wallpaper)); 158 test_api->GetWallpaperFromCache(test_account_id_2, &cached_wallpaper));
158 } 159 }
159 160
160 } // namespace chromeos 161 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698