OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 7 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
8 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 8 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
9 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 9 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
10 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 10 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 259 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
260 store_->GetValue(GetParam().pref_name(), NULL)); | 260 store_->GetValue(GetParam().pref_name(), NULL)); |
261 } | 261 } |
262 | 262 |
263 TEST_P(ConfigurationPolicyPrefStoreIntegerTest, SetValue) { | 263 TEST_P(ConfigurationPolicyPrefStoreIntegerTest, SetValue) { |
264 provider_.AddPolicy(GetParam().type(), Value::CreateIntegerValue(2)); | 264 provider_.AddPolicy(GetParam().type(), Value::CreateIntegerValue(2)); |
265 store_->OnUpdatePolicy(); | 265 store_->OnUpdatePolicy(); |
266 const Value* value = NULL; | 266 const Value* value = NULL; |
267 EXPECT_EQ(PrefStore::READ_OK, | 267 EXPECT_EQ(PrefStore::READ_OK, |
268 store_->GetValue(GetParam().pref_name(), &value)); | 268 store_->GetValue(GetParam().pref_name(), &value)); |
269 EXPECT_TRUE(FundamentalValue(2).Equals(value)); | 269 EXPECT_TRUE(base::FundamentalValue(2).Equals(value)); |
270 } | 270 } |
271 | 271 |
272 INSTANTIATE_TEST_CASE_P( | 272 INSTANTIATE_TEST_CASE_P( |
273 ConfigurationPolicyPrefStoreIntegerTestInstance, | 273 ConfigurationPolicyPrefStoreIntegerTestInstance, |
274 ConfigurationPolicyPrefStoreIntegerTest, | 274 ConfigurationPolicyPrefStoreIntegerTest, |
275 testing::Values( | 275 testing::Values( |
276 TypeAndName(kPolicyRestoreOnStartup, | 276 TypeAndName(kPolicyRestoreOnStartup, |
277 prefs::kRestoreOnStartup), | 277 prefs::kRestoreOnStartup), |
278 TypeAndName(kPolicyPolicyRefreshRate, | 278 TypeAndName(kPolicyPolicyRefreshRate, |
279 prefs::kUserPolicyRefreshRate), | 279 prefs::kUserPolicyRefreshRate), |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 provider_.AddPolicy(kPolicyIncognitoModeAvailability, | 716 provider_.AddPolicy(kPolicyIncognitoModeAvailability, |
717 Value::CreateIntegerValue(availability)); | 717 Value::CreateIntegerValue(availability)); |
718 } | 718 } |
719 store_ = new ConfigurationPolicyPrefStore(&provider_); | 719 store_ = new ConfigurationPolicyPrefStore(&provider_); |
720 } | 720 } |
721 | 721 |
722 void VerifyValues(IncognitoModePrefs::Availability availability) { | 722 void VerifyValues(IncognitoModePrefs::Availability availability) { |
723 const Value* value = NULL; | 723 const Value* value = NULL; |
724 EXPECT_EQ(PrefStore::READ_OK, | 724 EXPECT_EQ(PrefStore::READ_OK, |
725 store_->GetValue(prefs::kIncognitoModeAvailability, &value)); | 725 store_->GetValue(prefs::kIncognitoModeAvailability, &value)); |
726 EXPECT_TRUE(FundamentalValue(availability).Equals(value)); | 726 EXPECT_TRUE(base::FundamentalValue(availability).Equals(value)); |
727 } | 727 } |
728 | 728 |
729 MockConfigurationPolicyProvider provider_; | 729 MockConfigurationPolicyProvider provider_; |
730 scoped_refptr<ConfigurationPolicyPrefStore> store_; | 730 scoped_refptr<ConfigurationPolicyPrefStore> store_; |
731 }; | 731 }; |
732 | 732 |
733 // The following testcases verify that if the obsolete IncognitoEnabled | 733 // The following testcases verify that if the obsolete IncognitoEnabled |
734 // policy is not set, the IncognitoModeAvailability values should be copied | 734 // policy is not set, the IncognitoModeAvailability values should be copied |
735 // from IncognitoModeAvailability policy to pref "as is". | 735 // from IncognitoModeAvailability policy to pref "as is". |
736 TEST_F(ConfigurationPolicyPrefStoreIncognitoModeTest, | 736 TEST_F(ConfigurationPolicyPrefStoreIncognitoModeTest, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 | 960 |
961 provider_.SetInitializationComplete(true); | 961 provider_.SetInitializationComplete(true); |
962 EXPECT_FALSE(store_->IsInitializationComplete()); | 962 EXPECT_FALSE(store_->IsInitializationComplete()); |
963 | 963 |
964 store_->OnUpdatePolicy(); | 964 store_->OnUpdatePolicy(); |
965 Mock::VerifyAndClearExpectations(&observer_); | 965 Mock::VerifyAndClearExpectations(&observer_); |
966 EXPECT_TRUE(store_->IsInitializationComplete()); | 966 EXPECT_TRUE(store_->IsInitializationComplete()); |
967 } | 967 } |
968 | 968 |
969 } // namespace policy | 969 } // namespace policy |
OLD | NEW |