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

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "ash/desktop_background/desktop_background_controller.h" 11 #include "ash/desktop_background/desktop_background_controller.h"
11 #include "ash/desktop_background/desktop_background_controller_observer.h" 12 #include "ash/desktop_background/desktop_background_controller_observer.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
17 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
19 #include "base/memory/scoped_ptr.h"
20 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/run_loop.h" 21 #include "base/run_loop.h"
22 #include "chrome/browser/chromeos/login/login_manager_test.h" 22 #include "chrome/browser/chromeos/login/login_manager_test.h"
23 #include "chrome/browser/chromeos/login/startup_utils.h" 23 #include "chrome/browser/chromeos/login/startup_utils.h"
24 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 24 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
26 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u til.h" 26 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u til.h"
27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
28 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 28 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
29 #include "chrome/browser/chromeos/profiles/profile_helper.h" 29 #include "chrome/browser/chromeos/profiles/profile_helper.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 WallpaperManagerPolicyTest() 136 WallpaperManagerPolicyTest()
137 : LoginManagerTest(true), 137 : LoginManagerTest(true),
138 wallpaper_change_count_(0), 138 wallpaper_change_count_(0),
139 fake_session_manager_client_(new FakeSessionManagerClient) { 139 fake_session_manager_client_(new FakeSessionManagerClient) {
140 testUsers_.push_back( 140 testUsers_.push_back(
141 AccountId::FromUserEmail(LoginManagerTest::kEnterpriseUser1)); 141 AccountId::FromUserEmail(LoginManagerTest::kEnterpriseUser1));
142 testUsers_.push_back( 142 testUsers_.push_back(
143 AccountId::FromUserEmail(LoginManagerTest::kEnterpriseUser2)); 143 AccountId::FromUserEmail(LoginManagerTest::kEnterpriseUser2));
144 } 144 }
145 145
146 scoped_ptr<policy::UserPolicyBuilder> GetUserPolicyBuilder( 146 std::unique_ptr<policy::UserPolicyBuilder> GetUserPolicyBuilder(
147 const AccountId& account_id) { 147 const AccountId& account_id) {
148 scoped_ptr<policy::UserPolicyBuilder> 148 std::unique_ptr<policy::UserPolicyBuilder> user_policy_builder(
149 user_policy_builder(new policy::UserPolicyBuilder()); 149 new policy::UserPolicyBuilder());
150 base::FilePath user_keys_dir; 150 base::FilePath user_keys_dir;
151 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir)); 151 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir));
152 const std::string sanitized_user_id = 152 const std::string sanitized_user_id =
153 CryptohomeClient::GetStubSanitizedUsername( 153 CryptohomeClient::GetStubSanitizedUsername(
154 cryptohome::Identification(account_id)); 154 cryptohome::Identification(account_id));
155 const base::FilePath user_key_file = 155 const base::FilePath user_key_file =
156 user_keys_dir.AppendASCII(sanitized_user_id) 156 user_keys_dir.AppendASCII(sanitized_user_id)
157 .AppendASCII("policy.pub"); 157 .AppendASCII("policy.pub");
158 std::vector<uint8_t> user_key_bits; 158 std::vector<uint8_t> user_key_bits;
159 EXPECT_TRUE(user_policy_builder->GetSigningKey()-> 159 EXPECT_TRUE(user_policy_builder->GetSigningKey()->
160 ExportPublicKey(&user_key_bits)); 160 ExportPublicKey(&user_key_bits));
161 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName())); 161 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName()));
162 EXPECT_EQ(base::WriteFile( 162 EXPECT_EQ(base::WriteFile(
163 user_key_file, 163 user_key_file,
164 reinterpret_cast<const char*>(user_key_bits.data()), 164 reinterpret_cast<const char*>(user_key_bits.data()),
165 user_key_bits.size()), 165 user_key_bits.size()),
166 static_cast<int>(user_key_bits.size())); 166 static_cast<int>(user_key_bits.size()));
167 user_policy_builder->policy_data().set_username(account_id.GetUserEmail()); 167 user_policy_builder->policy_data().set_username(account_id.GetUserEmail());
168 return user_policy_builder; 168 return user_policy_builder;
169 } 169 }
170 170
171 // LoginManagerTest: 171 // LoginManagerTest:
172 void SetUpInProcessBrowserTestFixture() override { 172 void SetUpInProcessBrowserTestFixture() override {
173 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( 173 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
174 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); 174 std::unique_ptr<SessionManagerClient>(fake_session_manager_client_));
175 175
176 LoginManagerTest::SetUpInProcessBrowserTestFixture(); 176 LoginManagerTest::SetUpInProcessBrowserTestFixture();
177 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); 177 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
178 } 178 }
179 179
180 void SetUpCommandLine(base::CommandLine* command_line) override { 180 void SetUpCommandLine(base::CommandLine* command_line) override {
181 // Set the same switches as LoginManagerTest, except that kMultiProfiles is 181 // Set the same switches as LoginManagerTest, except that kMultiProfiles is
182 // only set when GetParam() is true and except that kLoginProfile is set 182 // only set when GetParam() is true and except that kLoginProfile is set
183 // when GetParam() is false. The latter seems to be required for the sane 183 // when GetParam() is false. The latter seems to be required for the sane
184 // start-up of user profiles. 184 // start-up of user profiles.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 // Obtain WallpaperInfo for |user_number| from WallpaperManager. 269 // Obtain WallpaperInfo for |user_number| from WallpaperManager.
270 void GetUserWallpaperInfo(int user_number, 270 void GetUserWallpaperInfo(int user_number,
271 wallpaper::WallpaperInfo* wallpaper_info) { 271 wallpaper::WallpaperInfo* wallpaper_info) {
272 WallpaperManager::Get()->GetUserWallpaperInfo(testUsers_[user_number], 272 WallpaperManager::Get()->GetUserWallpaperInfo(testUsers_[user_number],
273 wallpaper_info); 273 wallpaper_info);
274 } 274 }
275 275
276 base::FilePath test_data_dir_; 276 base::FilePath test_data_dir_;
277 scoped_ptr<base::RunLoop> run_loop_; 277 std::unique_ptr<base::RunLoop> run_loop_;
278 int wallpaper_change_count_; 278 int wallpaper_change_count_;
279 scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; 279 std::unique_ptr<policy::UserPolicyBuilder> user_policy_builders_[2];
280 FakeSessionManagerClient* fake_session_manager_client_; 280 FakeSessionManagerClient* fake_session_manager_client_;
281 std::vector<AccountId> testUsers_; 281 std::vector<AccountId> testUsers_;
282 282
283 private: 283 private:
284 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest); 284 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest);
285 }; 285 };
286 286
287 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_SetResetClear) { 287 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_SetResetClear) {
288 RegisterUser(testUsers_[0].GetUserEmail()); 288 RegisterUser(testUsers_[0].GetUserEmail());
289 RegisterUser(testUsers_[1].GetUserEmail()); 289 RegisterUser(testUsers_[1].GetUserEmail());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { 409 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) {
410 LoginUser(testUsers_[0].GetUserEmail()); 410 LoginUser(testUsers_[0].GetUserEmail());
411 411
412 // Wait until wallpaper has been loaded. 412 // Wait until wallpaper has been loaded.
413 RunUntilWallpaperChangeCount(1); 413 RunUntilWallpaperChangeCount(1);
414 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); 414 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor());
415 } 415 }
416 416
417 } // namespace chromeos 417 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698