| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/policy/configuration_policy_pref_store.h" | 6 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 7 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 7 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
| 8 #include "chrome/browser/prefs/proxy_prefs.h" | 8 #include "chrome/browser/prefs/proxy_prefs.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 Value* value; | 64 Value* value; |
| 65 EXPECT_EQ(PrefStore::READ_OK, | 65 EXPECT_EQ(PrefStore::READ_OK, |
| 66 store_.GetValue(GetParam().pref_name(), &value)); | 66 store_.GetValue(GetParam().pref_name(), &value)); |
| 67 EXPECT_TRUE(in_value->Equals(value)); | 67 EXPECT_TRUE(in_value->Equals(value)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 INSTANTIATE_TEST_CASE_P( | 70 INSTANTIATE_TEST_CASE_P( |
| 71 ConfigurationPolicyPrefStoreListTestInstance, | 71 ConfigurationPolicyPrefStoreListTestInstance, |
| 72 ConfigurationPolicyPrefStoreListTest, | 72 ConfigurationPolicyPrefStoreListTest, |
| 73 testing::Values( | 73 testing::Values( |
| 74 TypeAndName(kPolicyURLsToRestoreOnStartup, | 74 TypeAndName(kPolicyRestoreOnStartupURLs, |
| 75 prefs::kURLsToRestoreOnStartup), | 75 prefs::kURLsToRestoreOnStartup), |
| 76 TypeAndName(kPolicyExtensionInstallAllowList, | 76 TypeAndName(kPolicyExtensionInstallWhitelist, |
| 77 prefs::kExtensionInstallAllowList), | 77 prefs::kExtensionInstallAllowList), |
| 78 TypeAndName(kPolicyExtensionInstallDenyList, | 78 TypeAndName(kPolicyExtensionInstallBlacklist, |
| 79 prefs::kExtensionInstallDenyList), | 79 prefs::kExtensionInstallDenyList), |
| 80 TypeAndName(kPolicyDisabledPlugins, | 80 TypeAndName(kPolicyDisabledPlugins, |
| 81 prefs::kPluginsPluginsBlacklist))); | 81 prefs::kPluginsPluginsBlacklist))); |
| 82 | 82 |
| 83 // Test cases for string-valued policy settings. | 83 // Test cases for string-valued policy settings. |
| 84 class ConfigurationPolicyPrefStoreStringTest | 84 class ConfigurationPolicyPrefStoreStringTest |
| 85 : public ConfigurationPolicyPrefStoreTestBase< | 85 : public ConfigurationPolicyPrefStoreTestBase< |
| 86 testing::TestWithParam<TypeAndName> > { | 86 testing::TestWithParam<TypeAndName> > { |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 TEST_P(ConfigurationPolicyPrefStoreStringTest, GetDefault) { | 89 TEST_P(ConfigurationPolicyPrefStoreStringTest, GetDefault) { |
| 90 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 90 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 91 store_.GetValue(GetParam().pref_name(), NULL)); | 91 store_.GetValue(GetParam().pref_name(), NULL)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 TEST_P(ConfigurationPolicyPrefStoreStringTest, SetValue) { | 94 TEST_P(ConfigurationPolicyPrefStoreStringTest, SetValue) { |
| 95 provider_.AddPolicy(GetParam().type(), | 95 provider_.AddPolicy(GetParam().type(), |
| 96 Value::CreateStringValue("http://chromium.org")); | 96 Value::CreateStringValue("http://chromium.org")); |
| 97 store_.OnUpdatePolicy(); | 97 store_.OnUpdatePolicy(); |
| 98 Value* value; | 98 Value* value; |
| 99 EXPECT_EQ(PrefStore::READ_OK, | 99 EXPECT_EQ(PrefStore::READ_OK, |
| 100 store_.GetValue(GetParam().pref_name(), &value)); | 100 store_.GetValue(GetParam().pref_name(), &value)); |
| 101 EXPECT_TRUE(StringValue("http://chromium.org").Equals(value)); | 101 EXPECT_TRUE(StringValue("http://chromium.org").Equals(value)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 INSTANTIATE_TEST_CASE_P( | 104 INSTANTIATE_TEST_CASE_P( |
| 105 ConfigurationPolicyPrefStoreStringTestInstance, | 105 ConfigurationPolicyPrefStoreStringTestInstance, |
| 106 ConfigurationPolicyPrefStoreStringTest, | 106 ConfigurationPolicyPrefStoreStringTest, |
| 107 testing::Values( | 107 testing::Values( |
| 108 TypeAndName(kPolicyHomePage, | 108 TypeAndName(kPolicyHomepageLocation, |
| 109 prefs::kHomePage), | 109 prefs::kHomePage), |
| 110 TypeAndName(kPolicyApplicationLocale, | 110 TypeAndName(kPolicyApplicationLocaleValue, |
| 111 prefs::kApplicationLocale), | 111 prefs::kApplicationLocale), |
| 112 TypeAndName(kPolicyApplicationLocale, | 112 TypeAndName(kPolicyApplicationLocaleValue, |
| 113 prefs::kApplicationLocale), | 113 prefs::kApplicationLocale), |
| 114 TypeAndName(kPolicyAuthSchemes, | 114 TypeAndName(kPolicyAuthSchemes, |
| 115 prefs::kAuthSchemes), | 115 prefs::kAuthSchemes), |
| 116 TypeAndName(kPolicyAuthServerWhitelist, | 116 TypeAndName(kPolicyAuthServerWhitelist, |
| 117 prefs::kAuthServerWhitelist), | 117 prefs::kAuthServerWhitelist), |
| 118 TypeAndName(kPolicyAuthNegotiateDelegateWhitelist, | 118 TypeAndName(kPolicyAuthNegotiateDelegateWhitelist, |
| 119 prefs::kAuthNegotiateDelegateWhitelist), | 119 prefs::kAuthNegotiateDelegateWhitelist), |
| 120 TypeAndName(kPolicyGSSAPILibraryName, | 120 TypeAndName(kPolicyGSSAPILibraryName, |
| 121 prefs::kGSSAPILibraryName))); | 121 prefs::kGSSAPILibraryName))); |
| 122 | 122 |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 | 643 |
| 644 PrefStoreObserverMock observer_; | 644 PrefStoreObserverMock observer_; |
| 645 }; | 645 }; |
| 646 | 646 |
| 647 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { | 647 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { |
| 648 Value* value = NULL; | 648 Value* value = NULL; |
| 649 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 649 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 650 store_.GetValue(prefs::kHomePage, NULL)); | 650 store_.GetValue(prefs::kHomePage, NULL)); |
| 651 | 651 |
| 652 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); | 652 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); |
| 653 provider_.AddPolicy(kPolicyHomePage, | 653 provider_.AddPolicy(kPolicyHomepageLocation, |
| 654 Value::CreateStringValue("http://www.chromium.org")); | 654 Value::CreateStringValue("http://www.chromium.org")); |
| 655 store_.OnUpdatePolicy(); | 655 store_.OnUpdatePolicy(); |
| 656 Mock::VerifyAndClearExpectations(&observer_); | 656 Mock::VerifyAndClearExpectations(&observer_); |
| 657 EXPECT_EQ(PrefStore::READ_OK, | 657 EXPECT_EQ(PrefStore::READ_OK, |
| 658 store_.GetValue(prefs::kHomePage, &value)); | 658 store_.GetValue(prefs::kHomePage, &value)); |
| 659 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value)); | 659 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value)); |
| 660 | 660 |
| 661 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0); | 661 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0); |
| 662 store_.OnUpdatePolicy(); | 662 store_.OnUpdatePolicy(); |
| 663 Mock::VerifyAndClearExpectations(&observer_); | 663 Mock::VerifyAndClearExpectations(&observer_); |
| 664 | 664 |
| 665 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); | 665 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); |
| 666 provider_.RemovePolicy(kPolicyHomePage); | 666 provider_.RemovePolicy(kPolicyHomepageLocation); |
| 667 store_.OnUpdatePolicy(); | 667 store_.OnUpdatePolicy(); |
| 668 Mock::VerifyAndClearExpectations(&observer_); | 668 Mock::VerifyAndClearExpectations(&observer_); |
| 669 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 669 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 670 store_.GetValue(prefs::kHomePage, NULL)); | 670 store_.GetValue(prefs::kHomePage, NULL)); |
| 671 } | 671 } |
| 672 | 672 |
| 673 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) { | 673 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) { |
| 674 EXPECT_FALSE(store_.IsInitializationComplete()); | 674 EXPECT_FALSE(store_.IsInitializationComplete()); |
| 675 | 675 |
| 676 EXPECT_CALL(observer_, OnInitializationCompleted()).Times(1); | 676 EXPECT_CALL(observer_, OnInitializationCompleted()).Times(1); |
| 677 | 677 |
| 678 provider_.SetInitializationComplete(true); | 678 provider_.SetInitializationComplete(true); |
| 679 EXPECT_FALSE(store_.IsInitializationComplete()); | 679 EXPECT_FALSE(store_.IsInitializationComplete()); |
| 680 | 680 |
| 681 store_.OnUpdatePolicy(); | 681 store_.OnUpdatePolicy(); |
| 682 Mock::VerifyAndClearExpectations(&observer_); | 682 Mock::VerifyAndClearExpectations(&observer_); |
| 683 EXPECT_TRUE(store_.IsInitializationComplete()); | 683 EXPECT_TRUE(store_.IsInitializationComplete()); |
| 684 } | 684 } |
| 685 | 685 |
| 686 } // namespace policy | 686 } // namespace policy |
| OLD | NEW |