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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_manager_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_manager_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8
8 #include <algorithm> 9 #include <algorithm>
10 #include <memory>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
13 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
14 #include "base/macros.h" 16 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/ptr_util.h"
16 #include "base/run_loop.h" 18 #include "base/run_loop.h"
17 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
18 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 20 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
19 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 21 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
20 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
21 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
22 #include "chrome/browser/chromeos/policy/enrollment_config.h" 24 #include "chrome/browser/chromeos/policy/enrollment_config.h"
23 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" 25 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
24 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" 26 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
25 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 27 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 EnterpriseInstallAttributes::LockResult* out, 75 EnterpriseInstallAttributes::LockResult* out,
74 EnterpriseInstallAttributes::LockResult result) { 76 EnterpriseInstallAttributes::LockResult result) {
75 *out = result; 77 *out = result;
76 loop->Quit(); 78 loop->Quit();
77 } 79 }
78 80
79 class TestingDeviceCloudPolicyManagerChromeOS 81 class TestingDeviceCloudPolicyManagerChromeOS
80 : public DeviceCloudPolicyManagerChromeOS { 82 : public DeviceCloudPolicyManagerChromeOS {
81 public: 83 public:
82 TestingDeviceCloudPolicyManagerChromeOS( 84 TestingDeviceCloudPolicyManagerChromeOS(
83 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store, 85 std::unique_ptr<DeviceCloudPolicyStoreChromeOS> store,
84 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 86 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
85 ServerBackedStateKeysBroker* state_keys_broker) 87 ServerBackedStateKeysBroker* state_keys_broker)
86 : DeviceCloudPolicyManagerChromeOS(std::move(store), 88 : DeviceCloudPolicyManagerChromeOS(std::move(store),
87 task_runner, 89 task_runner,
88 state_keys_broker) {} 90 state_keys_broker) {}
89 ~TestingDeviceCloudPolicyManagerChromeOS() override {} 91 ~TestingDeviceCloudPolicyManagerChromeOS() override {}
90 }; 92 };
91 93
92 class DeviceCloudPolicyManagerChromeOSTest 94 class DeviceCloudPolicyManagerChromeOSTest
93 : public chromeos::DeviceSettingsTestBase, 95 : public chromeos::DeviceSettingsTestBase,
(...skipping 13 matching lines...) Expand all
107 } 109 }
108 110
109 ~DeviceCloudPolicyManagerChromeOSTest() override { 111 ~DeviceCloudPolicyManagerChromeOSTest() override {
110 chromeos::system::StatisticsProvider::SetTestProvider(NULL); 112 chromeos::system::StatisticsProvider::SetTestProvider(NULL);
111 } 113 }
112 114
113 void SetUp() override { 115 void SetUp() override {
114 DeviceSettingsTestBase::SetUp(); 116 DeviceSettingsTestBase::SetUp();
115 117
116 dbus_setter_->SetCryptohomeClient( 118 dbus_setter_->SetCryptohomeClient(
117 scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); 119 std::unique_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_));
118 120
119 install_attributes_.reset( 121 install_attributes_.reset(
120 new EnterpriseInstallAttributes(fake_cryptohome_client_)); 122 new EnterpriseInstallAttributes(fake_cryptohome_client_));
121 store_ = new DeviceCloudPolicyStoreChromeOS( 123 store_ = new DeviceCloudPolicyStoreChromeOS(
122 &device_settings_service_, install_attributes_.get(), 124 &device_settings_service_, install_attributes_.get(),
123 base::ThreadTaskRunnerHandle::Get()); 125 base::ThreadTaskRunnerHandle::Get());
124 manager_.reset(new TestingDeviceCloudPolicyManagerChromeOS( 126 manager_.reset(new TestingDeviceCloudPolicyManagerChromeOS(
125 make_scoped_ptr(store_), base::ThreadTaskRunnerHandle::Get(), 127 base::WrapUnique(store_), base::ThreadTaskRunnerHandle::Get(),
126 &state_keys_broker_)); 128 &state_keys_broker_));
127 129
128 chrome::RegisterLocalState(local_state_.registry()); 130 chrome::RegisterLocalState(local_state_.registry());
129 manager_->Init(&schema_registry_); 131 manager_->Init(&schema_registry_);
130 132
131 // DeviceOAuth2TokenService uses the system request context to fetch 133 // DeviceOAuth2TokenService uses the system request context to fetch
132 // OAuth tokens, then writes the token to local state, encrypting it 134 // OAuth tokens, then writes the token to local state, encrypting it
133 // first with methods in CryptohomeTokenEncryptor. 135 // first with methods in CryptohomeTokenEncryptor.
134 request_context_getter_ = new net::TestURLRequestContextGetter( 136 request_context_getter_ = new net::TestURLRequestContextGetter(
135 base::ThreadTaskRunnerHandle::Get()); 137 base::ThreadTaskRunnerHandle::Get());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 DM_STATUS_TEMPORARY_UNAVAILABLE)); 206 DM_STATUS_TEMPORARY_UNAVAILABLE));
205 EXPECT_CALL( 207 EXPECT_CALL(
206 device_management_service_, 208 device_management_service_,
207 StartJob(dm_protocol::kValueRequestRemoteCommands, _, _, _, _, _)) 209 StartJob(dm_protocol::kValueRequestRemoteCommands, _, _, _, _, _))
208 .Times(AnyNumber()); 210 .Times(AnyNumber());
209 } 211 }
210 212
211 MOCK_METHOD0(OnDeviceCloudPolicyManagerConnected, void()); 213 MOCK_METHOD0(OnDeviceCloudPolicyManagerConnected, void());
212 MOCK_METHOD0(OnDeviceCloudPolicyManagerDisconnected, void()); 214 MOCK_METHOD0(OnDeviceCloudPolicyManagerDisconnected, void());
213 215
214 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; 216 std::unique_ptr<EnterpriseInstallAttributes> install_attributes_;
215 217
216 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 218 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
217 net::TestURLFetcherFactory url_fetcher_factory_; 219 net::TestURLFetcherFactory url_fetcher_factory_;
218 int url_fetcher_response_code_; 220 int url_fetcher_response_code_;
219 std::string url_fetcher_response_string_; 221 std::string url_fetcher_response_string_;
220 TestingPrefServiceSimple local_state_; 222 TestingPrefServiceSimple local_state_;
221 MockDeviceManagementService device_management_service_; 223 MockDeviceManagementService device_management_service_;
222 MockDeviceManagementService consumer_device_management_service_; 224 MockDeviceManagementService consumer_device_management_service_;
223 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 225 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
224 chromeos::ScopedTestCrosSettings test_cros_settings_; 226 chromeos::ScopedTestCrosSettings test_cros_settings_;
225 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; 227 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_;
226 chromeos::FakeSessionManagerClient fake_session_manager_client_; 228 chromeos::FakeSessionManagerClient fake_session_manager_client_;
227 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; 229 chromeos::FakeCryptohomeClient* fake_cryptohome_client_;
228 ServerBackedStateKeysBroker state_keys_broker_; 230 ServerBackedStateKeysBroker state_keys_broker_;
229 231
230 DeviceCloudPolicyStoreChromeOS* store_; 232 DeviceCloudPolicyStoreChromeOS* store_;
231 SchemaRegistry schema_registry_; 233 SchemaRegistry schema_registry_;
232 scoped_ptr<TestingDeviceCloudPolicyManagerChromeOS> manager_; 234 std::unique_ptr<TestingDeviceCloudPolicyManagerChromeOS> manager_;
233 scoped_ptr<DeviceCloudPolicyInitializer> initializer_; 235 std::unique_ptr<DeviceCloudPolicyInitializer> initializer_;
234 236
235 private: 237 private:
236 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest); 238 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest);
237 }; 239 };
238 240
239 TEST_F(DeviceCloudPolicyManagerChromeOSTest, FreshDevice) { 241 TEST_F(DeviceCloudPolicyManagerChromeOSTest, FreshDevice) {
240 owner_key_util_->Clear(); 242 owner_key_util_->Clear();
241 FlushDeviceSettings(); 243 FlushDeviceSettings();
242 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); 244 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
243 245
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 750
749 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, 751 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest,
750 RobotRefreshSaveFailed) { 752 RobotRefreshSaveFailed) {
751 // Without the system salt, the robot token can't be stored. 753 // Without the system salt, the robot token can't be stored.
752 RunTest(); 754 RunTest();
753 ExpectFailedEnrollment(EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED); 755 ExpectFailedEnrollment(EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED);
754 } 756 }
755 757
756 } // namespace 758 } // namespace
757 } // namespace policy 759 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698