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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_provider_unittest.cc

Issue 270663002: Implemented profile-aware owner key loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes, rebase. Created 6 years, 7 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 | Annotate | Revision Log
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/settings/device_settings_provider.h" 5 #include "chrome/browser/chromeos/settings/device_settings_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Verify the change has not been applied. 132 // Verify the change has not been applied.
133 const base::Value* saved_value = provider_->Get(kStatsReportingPref); 133 const base::Value* saved_value = provider_->Get(kStatsReportingPref);
134 ASSERT_TRUE(saved_value); 134 ASSERT_TRUE(saved_value);
135 bool bool_value; 135 bool bool_value;
136 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); 136 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value));
137 EXPECT_FALSE(bool_value); 137 EXPECT_FALSE(bool_value);
138 } 138 }
139 139
140 TEST_F(DeviceSettingsProviderTest, SetPrefSucceed) { 140 TEST_F(DeviceSettingsProviderTest, SetPrefSucceed) {
141 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); 141 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
142 device_settings_service_.SetUsername(device_policy_.policy_data().username()); 142 crypto::ScopedPK11Slot slot;
143 device_settings_service_.InitOwner(device_policy_.policy_data().username(),
144 slot.Pass());
143 FlushDeviceSettings(); 145 FlushDeviceSettings();
144 146
145 base::FundamentalValue value(true); 147 base::FundamentalValue value(true);
146 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); 148 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber());
147 EXPECT_CALL(*this, SettingChanged(kStatsReportingPref)).Times(1); 149 EXPECT_CALL(*this, SettingChanged(kStatsReportingPref)).Times(1);
148 provider_->Set(kStatsReportingPref, value); 150 provider_->Set(kStatsReportingPref, value);
149 Mock::VerifyAndClearExpectations(this); 151 Mock::VerifyAndClearExpectations(this);
150 152
151 // Process the store. 153 // Process the store.
152 device_settings_test_helper_.set_policy_blob(std::string()); 154 device_settings_test_helper_.set_policy_blob(std::string());
153 FlushDeviceSettings(); 155 FlushDeviceSettings();
154 156
155 // Verify that the device policy has been adjusted. 157 // Verify that the device policy has been adjusted.
156 ASSERT_TRUE(device_settings_service_.device_settings()); 158 ASSERT_TRUE(device_settings_service_.device_settings());
157 EXPECT_TRUE(device_settings_service_.device_settings()-> 159 EXPECT_TRUE(device_settings_service_.device_settings()->
158 metrics_enabled().metrics_enabled()); 160 metrics_enabled().metrics_enabled());
159 161
160 // Verify the change has been applied. 162 // Verify the change has been applied.
161 const base::Value* saved_value = provider_->Get(kStatsReportingPref); 163 const base::Value* saved_value = provider_->Get(kStatsReportingPref);
162 ASSERT_TRUE(saved_value); 164 ASSERT_TRUE(saved_value);
163 bool bool_value; 165 bool bool_value;
164 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); 166 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value));
165 EXPECT_TRUE(bool_value); 167 EXPECT_TRUE(bool_value);
166 } 168 }
167 169
168 TEST_F(DeviceSettingsProviderTest, SetPrefTwice) { 170 TEST_F(DeviceSettingsProviderTest, SetPrefTwice) {
169 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); 171 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
170 device_settings_service_.SetUsername(device_policy_.policy_data().username()); 172 crypto::ScopedPK11Slot slot;
173 device_settings_service_.InitOwner(device_policy_.policy_data().username(),
174 slot.Pass());
171 FlushDeviceSettings(); 175 FlushDeviceSettings();
172 176
173 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); 177 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber());
174 178
175 base::StringValue value1("beta"); 179 base::StringValue value1("beta");
176 provider_->Set(kReleaseChannel, value1); 180 provider_->Set(kReleaseChannel, value1);
177 base::StringValue value2("dev"); 181 base::StringValue value2("dev");
178 provider_->Set(kReleaseChannel, value2); 182 provider_->Set(kReleaseChannel, value2);
179 183
180 // Let the changes propagate through the system. 184 // Let the changes propagate through the system.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 policy::PolicyBuilder::kFakeUsername); 283 policy::PolicyBuilder::kFakeUsername);
280 entry_dict->SetInteger(kAccountsPrefDeviceLocalAccountsKeyType, 284 entry_dict->SetInteger(kAccountsPrefDeviceLocalAccountsKeyType,
281 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); 285 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION);
282 expected_accounts.Append(entry_dict.release()); 286 expected_accounts.Append(entry_dict.release());
283 const base::Value* actual_accounts = 287 const base::Value* actual_accounts =
284 provider_->Get(kAccountsPrefDeviceLocalAccounts); 288 provider_->Get(kAccountsPrefDeviceLocalAccounts);
285 EXPECT_TRUE(base::Value::Equals(&expected_accounts, actual_accounts)); 289 EXPECT_TRUE(base::Value::Equals(&expected_accounts, actual_accounts));
286 } 290 }
287 291
288 } // namespace chromeos 292 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/power_policy_browsertest.cc ('k') | chrome/browser/chromeos/settings/device_settings_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698