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

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: merge with ToT 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) 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/ref_counted.h" 6 #include "base/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/proxy_prefs.h" 9 #include "chrome/browser/prefs/proxy_prefs.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
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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 663
664 PrefStoreObserverMock observer_; 664 PrefStoreObserverMock observer_;
665 }; 665 };
666 666
667 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { 667 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) {
668 Value* value = NULL; 668 Value* value = NULL;
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 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); 672 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1);
673 provider_.AddPolicy(kPolicyHomePage, 673 provider_.AddPolicy(kPolicyHomepageLocation,
674 Value::CreateStringValue("http://www.chromium.org")); 674 Value::CreateStringValue("http://www.chromium.org"));
675 store_->OnUpdatePolicy(); 675 store_->OnUpdatePolicy();
676 Mock::VerifyAndClearExpectations(&observer_); 676 Mock::VerifyAndClearExpectations(&observer_);
677 EXPECT_EQ(PrefStore::READ_OK, 677 EXPECT_EQ(PrefStore::READ_OK,
678 store_->GetValue(prefs::kHomePage, &value)); 678 store_->GetValue(prefs::kHomePage, &value));
679 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value)); 679 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value));
680 680
681 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0); 681 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0);
682 store_->OnUpdatePolicy(); 682 store_->OnUpdatePolicy();
683 Mock::VerifyAndClearExpectations(&observer_); 683 Mock::VerifyAndClearExpectations(&observer_);
684 684
685 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); 685 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1);
686 provider_.RemovePolicy(kPolicyHomePage); 686 provider_.RemovePolicy(kPolicyHomepageLocation);
687 store_->OnUpdatePolicy(); 687 store_->OnUpdatePolicy();
688 Mock::VerifyAndClearExpectations(&observer_); 688 Mock::VerifyAndClearExpectations(&observer_);
689 EXPECT_EQ(PrefStore::READ_NO_VALUE, 689 EXPECT_EQ(PrefStore::READ_NO_VALUE,
690 store_->GetValue(prefs::kHomePage, NULL)); 690 store_->GetValue(prefs::kHomePage, NULL));
691 } 691 }
692 692
693 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) { 693 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) {
694 EXPECT_FALSE(store_->IsInitializationComplete()); 694 EXPECT_FALSE(store_->IsInitializationComplete());
695 695
696 EXPECT_CALL(observer_, OnInitializationCompleted()).Times(1); 696 EXPECT_CALL(observer_, OnInitializationCompleted()).Times(1);
697 697
698 provider_.SetInitializationComplete(true); 698 provider_.SetInitializationComplete(true);
699 EXPECT_FALSE(store_->IsInitializationComplete()); 699 EXPECT_FALSE(store_->IsInitializationComplete());
700 700
701 store_->OnUpdatePolicy(); 701 store_->OnUpdatePolicy();
702 Mock::VerifyAndClearExpectations(&observer_); 702 Mock::VerifyAndClearExpectations(&observer_);
703 EXPECT_TRUE(store_->IsInitializationComplete()); 703 EXPECT_TRUE(store_->IsInitializationComplete());
704 } 704 }
705 705
706 } // namespace policy 706 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698