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

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

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Rebased. Created 5 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/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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Verify the change has not been applied. 255 // Verify the change has not been applied.
256 const base::Value* saved_value = provider_->Get(kStatsReportingPref); 256 const base::Value* saved_value = provider_->Get(kStatsReportingPref);
257 ASSERT_TRUE(saved_value); 257 ASSERT_TRUE(saved_value);
258 bool bool_value; 258 bool bool_value;
259 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); 259 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value));
260 EXPECT_FALSE(bool_value); 260 EXPECT_FALSE(bool_value);
261 } 261 }
262 262
263 TEST_F(DeviceSettingsProviderTest, SetPrefSucceed) { 263 TEST_F(DeviceSettingsProviderTest, SetPrefSucceed) {
264 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); 264 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
265 InitOwner(device_policy_.policy_data().username(), true); 265 InitOwner(AccountId::FromUserEmail(device_policy_.policy_data().username()),
266 true);
266 FlushDeviceSettings(); 267 FlushDeviceSettings();
267 268
268 base::FundamentalValue value(true); 269 base::FundamentalValue value(true);
269 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); 270 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber());
270 EXPECT_CALL(*this, SettingChanged(kStatsReportingPref)).Times(1); 271 EXPECT_CALL(*this, SettingChanged(kStatsReportingPref)).Times(1);
271 provider_->Set(kStatsReportingPref, value); 272 provider_->Set(kStatsReportingPref, value);
272 Mock::VerifyAndClearExpectations(this); 273 Mock::VerifyAndClearExpectations(this);
273 274
274 // Process the store. 275 // Process the store.
275 device_settings_test_helper_.set_policy_blob(std::string()); 276 device_settings_test_helper_.set_policy_blob(std::string());
276 FlushDeviceSettings(); 277 FlushDeviceSettings();
277 278
278 // Verify that the device policy has been adjusted. 279 // Verify that the device policy has been adjusted.
279 ASSERT_TRUE(device_settings_service_.device_settings()); 280 ASSERT_TRUE(device_settings_service_.device_settings());
280 EXPECT_TRUE(device_settings_service_.device_settings()-> 281 EXPECT_TRUE(device_settings_service_.device_settings()->
281 metrics_enabled().metrics_enabled()); 282 metrics_enabled().metrics_enabled());
282 283
283 // Verify the change has been applied. 284 // Verify the change has been applied.
284 const base::Value* saved_value = provider_->Get(kStatsReportingPref); 285 const base::Value* saved_value = provider_->Get(kStatsReportingPref);
285 ASSERT_TRUE(saved_value); 286 ASSERT_TRUE(saved_value);
286 bool bool_value; 287 bool bool_value;
287 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); 288 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value));
288 EXPECT_TRUE(bool_value); 289 EXPECT_TRUE(bool_value);
289 } 290 }
290 291
291 TEST_F(DeviceSettingsProviderTest, SetPrefTwice) { 292 TEST_F(DeviceSettingsProviderTest, SetPrefTwice) {
292 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); 293 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
293 InitOwner(device_policy_.policy_data().username(), true); 294 InitOwner(AccountId::FromUserEmail(device_policy_.policy_data().username()),
295 true);
294 FlushDeviceSettings(); 296 FlushDeviceSettings();
295 297
296 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); 298 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber());
297 299
298 base::StringValue value1("beta"); 300 base::StringValue value1("beta");
299 provider_->Set(kReleaseChannel, value1); 301 provider_->Set(kReleaseChannel, value1);
300 base::StringValue value2("dev"); 302 base::StringValue value2("dev");
301 provider_->Set(kReleaseChannel, value2); 303 provider_->Set(kReleaseChannel, value2);
302 304
303 // Let the changes propagate through the system. 305 // Let the changes propagate through the system.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 entry_dict->SetInteger(kAccountsPrefDeviceLocalAccountsKeyType, 405 entry_dict->SetInteger(kAccountsPrefDeviceLocalAccountsKeyType,
404 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); 406 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION);
405 expected_accounts.Append(entry_dict.release()); 407 expected_accounts.Append(entry_dict.release());
406 const base::Value* actual_accounts = 408 const base::Value* actual_accounts =
407 provider_->Get(kAccountsPrefDeviceLocalAccounts); 409 provider_->Get(kAccountsPrefDeviceLocalAccounts);
408 EXPECT_TRUE(base::Value::Equals(&expected_accounts, actual_accounts)); 410 EXPECT_TRUE(base::Value::Equals(&expected_accounts, actual_accounts));
409 } 411 }
410 412
411 TEST_F(DeviceSettingsProviderTest, OwnerIsStillSetWhenDeviceIsConsumerManaged) { 413 TEST_F(DeviceSettingsProviderTest, OwnerIsStillSetWhenDeviceIsConsumerManaged) {
412 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); 414 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
413 InitOwner(device_policy_.policy_data().username(), true); 415 InitOwner(AccountId::FromUserEmail(device_policy_.policy_data().username()),
416 true);
414 device_policy_.policy_data().set_management_mode( 417 device_policy_.policy_data().set_management_mode(
415 em::PolicyData::CONSUMER_MANAGED); 418 em::PolicyData::CONSUMER_MANAGED);
416 device_policy_.policy_data().set_request_token("test request token"); 419 device_policy_.policy_data().set_request_token("test request token");
417 device_policy_.Build(); 420 device_policy_.Build();
418 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); 421 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
419 FlushDeviceSettings(); 422 FlushDeviceSettings();
420 423
421 // Expect that kDeviceOwner is not empty. 424 // Expect that kDeviceOwner is not empty.
422 const base::Value* value = provider_->Get(kDeviceOwner); 425 const base::Value* value = provider_->Get(kDeviceOwner);
423 ASSERT_TRUE(value); 426 ASSERT_TRUE(value);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 502 }
500 503
501 TEST_F(DeviceSettingsProviderTest, DecodeLogUploadSettings) { 504 TEST_F(DeviceSettingsProviderTest, DecodeLogUploadSettings) {
502 SetLogUploadSettings(true); 505 SetLogUploadSettings(true);
503 VerifyLogUploadSettings(true); 506 VerifyLogUploadSettings(true);
504 507
505 SetLogUploadSettings(false); 508 SetLogUploadSettings(false);
506 VerifyLogUploadSettings(false); 509 VerifyLogUploadSettings(false);
507 } 510 }
508 } // namespace chromeos 511 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698