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