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

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

Issue 11365112: Change PrefStore::ReadResult to a boolean. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/testing_pref_store.h" 5 #include "base/prefs/testing_pref_store.h"
6 #include "chrome/browser/policy/configuration_policy_provider_test.h" 6 #include "chrome/browser/policy/configuration_policy_provider_test.h"
7 #include "chrome/browser/policy/managed_mode_policy_provider.h" 7 #include "chrome/browser/policy/managed_mode_policy_provider.h"
8 #include "chrome/browser/policy/policy_bundle.h" 8 #include "chrome/browser/policy/policy_bundle.h"
9 #include "chrome/browser/policy/policy_map.h" 9 #include "chrome/browser/policy/policy_map.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void TestHarness::InstallDictionaryPolicy( 92 void TestHarness::InstallDictionaryPolicy(
93 const std::string& policy_name, 93 const std::string& policy_name,
94 const base::DictionaryValue* policy_value) { 94 const base::DictionaryValue* policy_value) {
95 InstallPolicy(policy_name, policy_value->DeepCopy()); 95 InstallPolicy(policy_name, policy_value->DeepCopy());
96 } 96 }
97 97
98 void TestHarness::InstallPolicy(const std::string& policy_name, 98 void TestHarness::InstallPolicy(const std::string& policy_name,
99 base::Value* policy_value) { 99 base::Value* policy_value) {
100 base::DictionaryValue* cached_policy = NULL; 100 base::DictionaryValue* cached_policy = NULL;
101 base::Value* value = NULL; 101 base::Value* value = NULL;
102 PrefStore::ReadResult result = 102 if (pref_store_->GetMutableValue(ManagedModePolicyProvider::kPolicies,
103 pref_store_->GetMutableValue(ManagedModePolicyProvider::kPolicies, 103 &value)) {
104 &value); 104 ASSERT_TRUE(value->GetAsDictionary(&cached_policy));
105 switch (result) { 105 } else {
106 case PrefStore::READ_NO_VALUE: 106 cached_policy = new base::DictionaryValue;
107 cached_policy = new base::DictionaryValue; 107 pref_store_->SetValue(ManagedModePolicyProvider::kPolicies,
108 pref_store_->SetValue(ManagedModePolicyProvider::kPolicies, 108 cached_policy);
109 cached_policy);
110 break;
111 case PrefStore::READ_OK:
112 ASSERT_TRUE(value->GetAsDictionary(&cached_policy));
113 break;
114 default:
115 FAIL() << "Invalid result reading policy: " << result;
116 return;
117 } 109 }
110
118 cached_policy->SetWithoutPathExpansion(policy_name, policy_value); 111 cached_policy->SetWithoutPathExpansion(policy_name, policy_value);
119 } 112 }
120 113
121 } // namespace 114 } // namespace
122 115
123 // Instantiate abstract test case for basic policy reading tests. 116 // Instantiate abstract test case for basic policy reading tests.
124 INSTANTIATE_TEST_CASE_P( 117 INSTANTIATE_TEST_CASE_P(
125 ManagedModePolicyProviderTest, 118 ManagedModePolicyProviderTest,
126 ConfigurationPolicyProviderTest, 119 ConfigurationPolicyProviderTest,
127 testing::Values(TestHarness::Create)); 120 testing::Values(TestHarness::Create));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // A newly-created provider should have the same policies. 166 // A newly-created provider should have the same policies.
174 ManagedModePolicyProvider new_provider(pref_store_); 167 ManagedModePolicyProvider new_provider(pref_store_);
175 new_provider.Init(); 168 new_provider.Init();
176 EXPECT_TRUE(new_provider.policies().Equals(expected_bundle)); 169 EXPECT_TRUE(new_provider.policies().Equals(expected_bundle));
177 170
178 // Cleanup. 171 // Cleanup.
179 new_provider.Shutdown(); 172 new_provider.Shutdown();
180 } 173 }
181 174
182 } // namespace policy 175 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698