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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc

Issue 2371213002: Refactor: Inject StatisticsProvider as a dependency of DeviceCloudPolicyInitializer. (Closed)
Patch Set: Address Maksim's comments. Created 4 years, 2 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
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 class DeviceCloudPolicyManagerChromeOSTest 107 class DeviceCloudPolicyManagerChromeOSTest
108 : public chromeos::DeviceSettingsTestBase, 108 : public chromeos::DeviceSettingsTestBase,
109 public DeviceCloudPolicyManagerChromeOS::Observer { 109 public DeviceCloudPolicyManagerChromeOS::Observer {
110 protected: 110 protected:
111 DeviceCloudPolicyManagerChromeOSTest() 111 DeviceCloudPolicyManagerChromeOSTest()
112 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), 112 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()),
113 state_keys_broker_(&fake_session_manager_client_, 113 state_keys_broker_(&fake_session_manager_client_,
114 base::ThreadTaskRunnerHandle::Get()), 114 base::ThreadTaskRunnerHandle::Get()),
115 store_(NULL) { 115 store_(NULL) {
116 fake_statistics_provider_.SetMachineStatistic("serial_numer", "test_sn"); 116 fake_statistics_provider_.SetMachineStatistic(
117 chromeos::system::kSerialNumberKey, "test_sn");
118 fake_statistics_provider_.SetMachineStatistic(
119 chromeos::system::kHardwareClassKey, "test_hw");
117 std::vector<std::string> state_keys; 120 std::vector<std::string> state_keys;
118 state_keys.push_back("1"); 121 state_keys.push_back("1");
119 state_keys.push_back("2"); 122 state_keys.push_back("2");
120 state_keys.push_back("3"); 123 state_keys.push_back("3");
121 fake_session_manager_client_.set_server_backed_state_keys(state_keys); 124 fake_session_manager_client_.set_server_backed_state_keys(state_keys);
122 } 125 }
123 126
124 ~DeviceCloudPolicyManagerChromeOSTest() override { 127 ~DeviceCloudPolicyManagerChromeOSTest() override {
125 chromeos::system::StatisticsProvider::SetTestProvider(NULL); 128 chromeos::system::StatisticsProvider::SetTestProvider(NULL);
126 } 129 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 base::Bind(&CopyLockResult, &loop, &result)); 203 base::Bind(&CopyLockResult, &loop, &result));
201 loop.Run(); 204 loop.Run();
202 ASSERT_EQ(chromeos::InstallAttributes::LOCK_SUCCESS, result); 205 ASSERT_EQ(chromeos::InstallAttributes::LOCK_SUCCESS, result);
203 } 206 }
204 207
205 void ConnectManager() { 208 void ConnectManager() {
206 std::unique_ptr<chromeos::attestation::AttestationFlow> unique_flow( 209 std::unique_ptr<chromeos::attestation::AttestationFlow> unique_flow(
207 CreateAttestationFlow()); 210 CreateAttestationFlow());
208 manager_->Initialize(&local_state_); 211 manager_->Initialize(&local_state_);
209 manager_->AddDeviceCloudPolicyManagerObserver(this); 212 manager_->AddDeviceCloudPolicyManagerObserver(this);
210 initializer_.reset(new DeviceCloudPolicyInitializer( 213 initializer_ = base::MakeUnique<DeviceCloudPolicyInitializer>(
211 &local_state_, &device_management_service_, 214 &local_state_, &device_management_service_,
212 base::ThreadTaskRunnerHandle::Get(), install_attributes_.get(), 215 base::ThreadTaskRunnerHandle::Get(), install_attributes_.get(),
213 &state_keys_broker_, store_, manager_.get(), 216 &state_keys_broker_, store_, manager_.get(),
214 cryptohome::AsyncMethodCaller::GetInstance(), std::move(unique_flow))); 217 cryptohome::AsyncMethodCaller::GetInstance(), std::move(unique_flow),
218 &fake_statistics_provider_);
215 initializer_->SetSigningServiceForTesting( 219 initializer_->SetSigningServiceForTesting(
216 base::MakeUnique<FakeSigningService>()); 220 base::MakeUnique<FakeSigningService>());
217 initializer_->Init(); 221 initializer_->Init();
218 } 222 }
219 223
220 void VerifyPolicyPopulated() { 224 void VerifyPolicyPopulated() {
221 PolicyBundle bundle; 225 PolicyBundle bundle;
222 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 226 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
223 .Set(key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY, 227 .Set(key::kDeviceMetricsReportingEnabled, POLICY_LEVEL_MANDATORY,
224 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 228 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 DeviceCloudPolicyManagerChromeOSEnrollmentTest, 797 DeviceCloudPolicyManagerChromeOSEnrollmentTest,
794 ::testing::Values(false, true)); 798 ::testing::Values(false, true));
795 799
796 INSTANTIATE_TEST_CASE_P( 800 INSTANTIATE_TEST_CASE_P(
797 Cert, 801 Cert,
798 DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, 802 DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest,
799 ::testing::Values(false, true)); 803 ::testing::Values(false, true));
800 804
801 } // namespace 805 } // namespace
802 } // namespace policy 806 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698