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

Side by Side Diff: chrome/browser/policy/configuration_policy_pref_store_unittest.cc

Issue 6002015: Policy: generate boilerplate policy type and constant code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nacl build Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
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
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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 646
647 PrefStoreObserverMock observer_; 647 PrefStoreObserverMock observer_;
648 }; 648 };
649 649
650 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { 650 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) {
651 Value* value = NULL; 651 Value* value = NULL;
652 EXPECT_EQ(PrefStore::READ_NO_VALUE, 652 EXPECT_EQ(PrefStore::READ_NO_VALUE,
653 store_.GetValue(prefs::kHomePage, NULL)); 653 store_.GetValue(prefs::kHomePage, NULL));
654 654
655 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); 655 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1);
656 provider_.AddPolicy(kPolicyHomePage, 656 provider_.AddPolicy(kPolicyHomepageLocation,
657 Value::CreateStringValue("http://www.chromium.org")); 657 Value::CreateStringValue("http://www.chromium.org"));
658 store_.OnUpdatePolicy(); 658 store_.OnUpdatePolicy();
659 Mock::VerifyAndClearExpectations(&observer_); 659 Mock::VerifyAndClearExpectations(&observer_);
660 EXPECT_EQ(PrefStore::READ_OK, 660 EXPECT_EQ(PrefStore::READ_OK,
661 store_.GetValue(prefs::kHomePage, &value)); 661 store_.GetValue(prefs::kHomePage, &value));
662 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value)); 662 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value));
663 663
664 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0); 664 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0);
665 store_.OnUpdatePolicy(); 665 store_.OnUpdatePolicy();
666 Mock::VerifyAndClearExpectations(&observer_); 666 Mock::VerifyAndClearExpectations(&observer_);
667 667
668 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); 668 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1);
669 provider_.RemovePolicy(kPolicyHomePage); 669 provider_.RemovePolicy(kPolicyHomepageLocation);
670 store_.OnUpdatePolicy(); 670 store_.OnUpdatePolicy();
671 Mock::VerifyAndClearExpectations(&observer_); 671 Mock::VerifyAndClearExpectations(&observer_);
672 EXPECT_EQ(PrefStore::READ_NO_VALUE, 672 EXPECT_EQ(PrefStore::READ_NO_VALUE,
673 store_.GetValue(prefs::kHomePage, NULL)); 673 store_.GetValue(prefs::kHomePage, NULL));
674 } 674 }
675 675
676 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) { 676 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) {
677 EXPECT_FALSE(store_.IsInitializationComplete()); 677 EXPECT_FALSE(store_.IsInitializationComplete());
678 678
679 EXPECT_CALL(observer_, OnInitializationCompleted()).Times(1); 679 EXPECT_CALL(observer_, OnInitializationCompleted()).Times(1);
680 680
681 provider_.SetInitializationComplete(true); 681 provider_.SetInitializationComplete(true);
682 EXPECT_FALSE(store_.IsInitializationComplete()); 682 EXPECT_FALSE(store_.IsInitializationComplete());
683 683
684 store_.OnUpdatePolicy(); 684 store_.OnUpdatePolicy();
685 Mock::VerifyAndClearExpectations(&observer_); 685 Mock::VerifyAndClearExpectations(&observer_);
686 EXPECT_TRUE(store_.IsInitializationComplete()); 686 EXPECT_TRUE(store_.IsInitializationComplete());
687 } 687 }
688 688
689 } // namespace policy 689 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698