OLD | NEW |
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 Loading... |
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(AccountId::FromUserEmail(device_policy_.policy_data().username()), | 265 InitOwner(device_policy_.policy_data().username(), true); |
266 true); | |
267 FlushDeviceSettings(); | 266 FlushDeviceSettings(); |
268 | 267 |
269 base::FundamentalValue value(true); | 268 base::FundamentalValue value(true); |
270 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); | 269 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); |
271 EXPECT_CALL(*this, SettingChanged(kStatsReportingPref)).Times(1); | 270 EXPECT_CALL(*this, SettingChanged(kStatsReportingPref)).Times(1); |
272 provider_->Set(kStatsReportingPref, value); | 271 provider_->Set(kStatsReportingPref, value); |
273 Mock::VerifyAndClearExpectations(this); | 272 Mock::VerifyAndClearExpectations(this); |
274 | 273 |
275 // Process the store. | 274 // Process the store. |
276 device_settings_test_helper_.set_policy_blob(std::string()); | 275 device_settings_test_helper_.set_policy_blob(std::string()); |
277 FlushDeviceSettings(); | 276 FlushDeviceSettings(); |
278 | 277 |
279 // Verify that the device policy has been adjusted. | 278 // Verify that the device policy has been adjusted. |
280 ASSERT_TRUE(device_settings_service_.device_settings()); | 279 ASSERT_TRUE(device_settings_service_.device_settings()); |
281 EXPECT_TRUE(device_settings_service_.device_settings()-> | 280 EXPECT_TRUE(device_settings_service_.device_settings()-> |
282 metrics_enabled().metrics_enabled()); | 281 metrics_enabled().metrics_enabled()); |
283 | 282 |
284 // Verify the change has been applied. | 283 // Verify the change has been applied. |
285 const base::Value* saved_value = provider_->Get(kStatsReportingPref); | 284 const base::Value* saved_value = provider_->Get(kStatsReportingPref); |
286 ASSERT_TRUE(saved_value); | 285 ASSERT_TRUE(saved_value); |
287 bool bool_value; | 286 bool bool_value; |
288 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); | 287 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); |
289 EXPECT_TRUE(bool_value); | 288 EXPECT_TRUE(bool_value); |
290 } | 289 } |
291 | 290 |
292 TEST_F(DeviceSettingsProviderTest, SetPrefTwice) { | 291 TEST_F(DeviceSettingsProviderTest, SetPrefTwice) { |
293 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); | 292 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); |
294 InitOwner(AccountId::FromUserEmail(device_policy_.policy_data().username()), | 293 InitOwner(device_policy_.policy_data().username(), true); |
295 true); | |
296 FlushDeviceSettings(); | 294 FlushDeviceSettings(); |
297 | 295 |
298 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); | 296 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); |
299 | 297 |
300 base::StringValue value1("beta"); | 298 base::StringValue value1("beta"); |
301 provider_->Set(kReleaseChannel, value1); | 299 provider_->Set(kReleaseChannel, value1); |
302 base::StringValue value2("dev"); | 300 base::StringValue value2("dev"); |
303 provider_->Set(kReleaseChannel, value2); | 301 provider_->Set(kReleaseChannel, value2); |
304 | 302 |
305 // Let the changes propagate through the system. | 303 // Let the changes propagate through the system. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 entry_dict->SetInteger(kAccountsPrefDeviceLocalAccountsKeyType, | 403 entry_dict->SetInteger(kAccountsPrefDeviceLocalAccountsKeyType, |
406 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); | 404 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
407 expected_accounts.Append(entry_dict.release()); | 405 expected_accounts.Append(entry_dict.release()); |
408 const base::Value* actual_accounts = | 406 const base::Value* actual_accounts = |
409 provider_->Get(kAccountsPrefDeviceLocalAccounts); | 407 provider_->Get(kAccountsPrefDeviceLocalAccounts); |
410 EXPECT_TRUE(base::Value::Equals(&expected_accounts, actual_accounts)); | 408 EXPECT_TRUE(base::Value::Equals(&expected_accounts, actual_accounts)); |
411 } | 409 } |
412 | 410 |
413 TEST_F(DeviceSettingsProviderTest, OwnerIsStillSetWhenDeviceIsConsumerManaged) { | 411 TEST_F(DeviceSettingsProviderTest, OwnerIsStillSetWhenDeviceIsConsumerManaged) { |
414 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); | 412 owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey()); |
415 InitOwner(AccountId::FromUserEmail(device_policy_.policy_data().username()), | 413 InitOwner(device_policy_.policy_data().username(), true); |
416 true); | |
417 device_policy_.policy_data().set_management_mode( | 414 device_policy_.policy_data().set_management_mode( |
418 em::PolicyData::CONSUMER_MANAGED); | 415 em::PolicyData::CONSUMER_MANAGED); |
419 device_policy_.policy_data().set_request_token("test request token"); | 416 device_policy_.policy_data().set_request_token("test request token"); |
420 device_policy_.Build(); | 417 device_policy_.Build(); |
421 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); | 418 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); |
422 FlushDeviceSettings(); | 419 FlushDeviceSettings(); |
423 | 420 |
424 // Expect that kDeviceOwner is not empty. | 421 // Expect that kDeviceOwner is not empty. |
425 const base::Value* value = provider_->Get(kDeviceOwner); | 422 const base::Value* value = provider_->Get(kDeviceOwner); |
426 ASSERT_TRUE(value); | 423 ASSERT_TRUE(value); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 499 } |
503 | 500 |
504 TEST_F(DeviceSettingsProviderTest, DecodeLogUploadSettings) { | 501 TEST_F(DeviceSettingsProviderTest, DecodeLogUploadSettings) { |
505 SetLogUploadSettings(true); | 502 SetLogUploadSettings(true); |
506 VerifyLogUploadSettings(true); | 503 VerifyLogUploadSettings(true); |
507 | 504 |
508 SetLogUploadSettings(false); | 505 SetLogUploadSettings(false); |
509 VerifyLogUploadSettings(false); | 506 VerifyLogUploadSettings(false); |
510 } | 507 } |
511 } // namespace chromeos | 508 } // namespace chromeos |
OLD | NEW |