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

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

Issue 6240013: Make proxy settings one atomic dictionary in the PrefStores such that modifications are atomic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/out/Debug
Patch Set: 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 class ConfigurationPolicyPrefStoreProxyTest : public testing::Test { 229 class ConfigurationPolicyPrefStoreProxyTest : public testing::Test {
230 protected: 230 protected:
231 // Verify that all the proxy prefs are set to the specified expected values. 231 // Verify that all the proxy prefs are set to the specified expected values.
232 static void VerifyProxyPrefs( 232 static void VerifyProxyPrefs(
233 const ConfigurationPolicyPrefStore& store, 233 const ConfigurationPolicyPrefStore& store,
234 const std::string& expected_proxy_server, 234 const std::string& expected_proxy_server,
235 const std::string& expected_proxy_pac_url, 235 const std::string& expected_proxy_pac_url,
236 const std::string& expected_proxy_bypass_list, 236 const std::string& expected_proxy_bypass_list,
237 const ProxyPrefs::ProxyMode& expected_proxy_mode) { 237 const ProxyPrefs::ProxyMode& expected_proxy_mode) {
238 Value* value = NULL; 238 Value* value = NULL;
239 239 ASSERT_EQ(PrefStore::READ_OK,
240 store.GetValue(prefs::kProxy, &value));
241 ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType());
242 ProxyPrefsDictionary dict((DictionaryValue*) value);
battre 2011/01/27 15:19:35 changed this and two other occurrences to static_c
243 std::string s;
240 if (expected_proxy_server.empty()) { 244 if (expected_proxy_server.empty()) {
241 EXPECT_EQ(PrefStore::READ_USE_DEFAULT, 245 EXPECT_FALSE(dict.GetProxyServer(&s));
242 store.GetValue(prefs::kProxyServer, NULL));
243 } else { 246 } else {
244 EXPECT_EQ(PrefStore::READ_OK, 247 ASSERT_TRUE(dict.GetProxyServer(&s));
245 store.GetValue(prefs::kProxyServer, &value)); 248 EXPECT_EQ(expected_proxy_server, s);
246 EXPECT_TRUE(StringValue(expected_proxy_server).Equals(value));
247 } 249 }
248 if (expected_proxy_pac_url.empty()) { 250 if (expected_proxy_pac_url.empty()) {
249 EXPECT_EQ(PrefStore::READ_USE_DEFAULT, 251 EXPECT_FALSE(dict.GetPacUrl(&s));
250 store.GetValue(prefs::kProxyPacUrl, NULL));
251 } else { 252 } else {
252 EXPECT_EQ(PrefStore::READ_OK, 253 ASSERT_TRUE(dict.GetPacUrl(&s));
253 store.GetValue(prefs::kProxyPacUrl, &value)); 254 EXPECT_EQ(expected_proxy_pac_url, s);
254 EXPECT_TRUE(StringValue(expected_proxy_pac_url).Equals(value));
255 } 255 }
256 if (expected_proxy_bypass_list.empty()) { 256 if (expected_proxy_bypass_list.empty()) {
257 EXPECT_EQ(PrefStore::READ_USE_DEFAULT, 257 EXPECT_FALSE(dict.GetBypassList(&s));
258 store.GetValue(prefs::kProxyBypassList, NULL));
259 } else { 258 } else {
260 EXPECT_EQ(PrefStore::READ_OK, 259 ASSERT_TRUE(dict.GetBypassList(&s));
261 store.GetValue(prefs::kProxyBypassList, &value)); 260 EXPECT_EQ(expected_proxy_bypass_list, s);
262 EXPECT_TRUE(StringValue(expected_proxy_bypass_list).Equals(value));
263 } 261 }
264 EXPECT_EQ(PrefStore::READ_OK, store.GetValue(prefs::kProxyMode, &value)); 262 ProxyPrefs::ProxyMode mode;
265 EXPECT_TRUE(FundamentalValue(expected_proxy_mode).Equals(value)); 263 ASSERT_TRUE(dict.GetMode(&mode));
264 EXPECT_EQ(expected_proxy_mode, mode);
266 } 265 }
267 }; 266 };
268 267
269 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptions) { 268 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptions) {
270 MockConfigurationPolicyProvider provider; 269 MockConfigurationPolicyProvider provider;
271 provider.AddPolicy(kPolicyProxyBypassList, 270 provider.AddPolicy(kPolicyProxyBypassList,
272 Value::CreateStringValue("http://chromium.org/override")); 271 Value::CreateStringValue("http://chromium.org/override"));
273 provider.AddPolicy(kPolicyProxyServer, 272 provider.AddPolicy(kPolicyProxyServer,
274 Value::CreateStringValue("chromium.org")); 273 Value::CreateStringValue("chromium.org"));
275 provider.AddPolicy(kPolicyProxyServerMode, 274 provider.AddPolicy(kPolicyProxyServerMode,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 provider.AddPolicy(kPolicyProxyPacUrl, 399 provider.AddPolicy(kPolicyProxyPacUrl,
401 Value::CreateStringValue("http://short.org/proxy.pac")); 400 Value::CreateStringValue("http://short.org/proxy.pac"));
402 provider.AddPolicy(kPolicyProxyBypassList, 401 provider.AddPolicy(kPolicyProxyBypassList,
403 Value::CreateStringValue( 402 Value::CreateStringValue(
404 "http://chromium.org/override")); 403 "http://chromium.org/override"));
405 provider.AddPolicy(kPolicyProxyServer, 404 provider.AddPolicy(kPolicyProxyServer,
406 Value::CreateStringValue("chromium.org")); 405 Value::CreateStringValue("chromium.org"));
407 406
408 scoped_refptr<ConfigurationPolicyPrefStore> store( 407 scoped_refptr<ConfigurationPolicyPrefStore> store(
409 new ConfigurationPolicyPrefStore(&provider)); 408 new ConfigurationPolicyPrefStore(&provider));
410 EXPECT_EQ(PrefStore::READ_NO_VALUE, 409 Value* value = NULL;
411 store->GetValue(prefs::kProxyMode, NULL)); 410 ASSERT_EQ(PrefStore::READ_NO_VALUE,
411 store->GetValue(prefs::kProxy, &value));
412 } 412 }
413 } 413 }
414 414
415 class ConfigurationPolicyPrefStoreDefaultSearchTest : public testing::Test { 415 class ConfigurationPolicyPrefStoreDefaultSearchTest : public testing::Test {
416 }; 416 };
417 417
418 // Checks that if the policy for default search is valid, i.e. there's a 418 // Checks that if the policy for default search is valid, i.e. there's a
419 // search URL, that all the elements have been given proper defaults. 419 // search URL, that all the elements have been given proper defaults.
420 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) { 420 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) {
421 const char* const search_url = "http://test.com/search?t={searchTerms}"; 421 const char* const search_url = "http://test.com/search?t={searchTerms}";
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
« no previous file with comments | « chrome/browser/policy/configuration_policy_pref_store.cc ('k') | chrome/browser/policy/managed_prefs_banner_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698