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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_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: iwyu fixes 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/policy/device_cloud_policy_store_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" 15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
18 #include "chrome/test/base/scoped_testing_local_state.h" 18 #include "chrome/test/base/scoped_testing_local_state.h"
19 #include "chrome/test/base/testing_browser_process.h" 19 #include "chrome/test/base/testing_browser_process.h"
20 #include "chromeos/cryptohome/cryptohome_util.h" 20 #include "chromeos/cryptohome/cryptohome_util.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/fake_cryptohome_client.h" 22 #include "chromeos/dbus/fake_cryptohome_client.h"
(...skipping 28 matching lines...) Expand all
51 new EnterpriseInstallAttributes(fake_cryptohome_client_)), 51 new EnterpriseInstallAttributes(fake_cryptohome_client_)),
52 store_(new DeviceCloudPolicyStoreChromeOS( 52 store_(new DeviceCloudPolicyStoreChromeOS(
53 &device_settings_service_, 53 &device_settings_service_,
54 install_attributes_.get(), 54 install_attributes_.get(),
55 base::ThreadTaskRunnerHandle::Get())) {} 55 base::ThreadTaskRunnerHandle::Get())) {}
56 56
57 void SetUp() override { 57 void SetUp() override {
58 DeviceSettingsTestBase::SetUp(); 58 DeviceSettingsTestBase::SetUp();
59 59
60 dbus_setter_->SetCryptohomeClient( 60 dbus_setter_->SetCryptohomeClient(
61 scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); 61 std::unique_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_));
62 62
63 base::RunLoop loop; 63 base::RunLoop loop;
64 EnterpriseInstallAttributes::LockResult result; 64 EnterpriseInstallAttributes::LockResult result;
65 install_attributes_->LockDevice( 65 install_attributes_->LockDevice(
66 PolicyBuilder::kFakeUsername, 66 PolicyBuilder::kFakeUsername,
67 DEVICE_MODE_ENTERPRISE, 67 DEVICE_MODE_ENTERPRISE,
68 PolicyBuilder::kFakeDeviceId, 68 PolicyBuilder::kFakeDeviceId,
69 base::Bind(&CopyLockResult, &loop, &result)); 69 base::Bind(&CopyLockResult, &loop, &result));
70 loop.Run(); 70 loop.Run();
71 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, result); 71 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, result);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 std::string()); 134 std::string());
135 install_attributes_.reset( 135 install_attributes_.reset(
136 new EnterpriseInstallAttributes(fake_cryptohome_client_)); 136 new EnterpriseInstallAttributes(fake_cryptohome_client_));
137 store_.reset(new DeviceCloudPolicyStoreChromeOS( 137 store_.reset(new DeviceCloudPolicyStoreChromeOS(
138 &device_settings_service_, install_attributes_.get(), 138 &device_settings_service_, install_attributes_.get(),
139 base::ThreadTaskRunnerHandle::Get())); 139 base::ThreadTaskRunnerHandle::Get()));
140 } 140 }
141 141
142 ScopedTestingLocalState local_state_; 142 ScopedTestingLocalState local_state_;
143 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; 143 chromeos::FakeCryptohomeClient* fake_cryptohome_client_;
144 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; 144 std::unique_ptr<EnterpriseInstallAttributes> install_attributes_;
145 145
146 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; 146 std::unique_ptr<DeviceCloudPolicyStoreChromeOS> store_;
147 147
148 private: 148 private:
149 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); 149 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest);
150 }; 150 };
151 151
152 TEST_F(DeviceCloudPolicyStoreChromeOSTest, LoadNoKey) { 152 TEST_F(DeviceCloudPolicyStoreChromeOSTest, LoadNoKey) {
153 owner_key_util_->Clear(); 153 owner_key_util_->Clear();
154 store_->Load(); 154 store_->Load();
155 FlushDeviceSettings(); 155 FlushDeviceSettings();
156 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); 156 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { 307 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) {
308 PrepareNewSigningKey(); 308 PrepareNewSigningKey();
309 ResetToNonEnterprise(); 309 ResetToNonEnterprise();
310 store_->InstallInitialPolicy(device_policy_.policy()); 310 store_->InstallInitialPolicy(device_policy_.policy());
311 FlushDeviceSettings(); 311 FlushDeviceSettings();
312 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); 312 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE);
313 } 313 }
314 314
315 } // namespace policy 315 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698