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

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

Issue 10417032: Disable sync promo when RestoreOnStartupURLs policy is used (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 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
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 <string> 5 #include <string>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "chrome/browser/policy/configuration_policy_handler.h" 9 #include "chrome/browser/policy/configuration_policy_handler.h"
10 #include "chrome/browser/policy/configuration_policy_pref_store.h" 10 #include "chrome/browser/policy/configuration_policy_pref_store.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_EQ(PrefStore::READ_OK, 80 EXPECT_EQ(PrefStore::READ_OK,
81 store_->GetValue(GetParam().pref_name(), &value)); 81 store_->GetValue(GetParam().pref_name(), &value));
82 ASSERT_TRUE(value); 82 ASSERT_TRUE(value);
83 EXPECT_TRUE(in_value->Equals(value)); 83 EXPECT_TRUE(in_value->Equals(value));
84 } 84 }
85 85
86 INSTANTIATE_TEST_CASE_P( 86 INSTANTIATE_TEST_CASE_P(
87 ConfigurationPolicyPrefStoreListTestInstance, 87 ConfigurationPolicyPrefStoreListTestInstance,
88 ConfigurationPolicyPrefStoreListTest, 88 ConfigurationPolicyPrefStoreListTest,
89 testing::Values( 89 testing::Values(
90 PolicyAndPref(key::kRestoreOnStartupURLs,
91 prefs::kURLsToRestoreOnStartup),
92 PolicyAndPref(key::kDisabledPlugins, 90 PolicyAndPref(key::kDisabledPlugins,
93 prefs::kPluginsDisabledPlugins), 91 prefs::kPluginsDisabledPlugins),
94 PolicyAndPref(key::kDisabledPluginsExceptions, 92 PolicyAndPref(key::kDisabledPluginsExceptions,
95 prefs::kPluginsDisabledPluginsExceptions), 93 prefs::kPluginsDisabledPluginsExceptions),
96 PolicyAndPref(key::kEnabledPlugins, 94 PolicyAndPref(key::kEnabledPlugins,
97 prefs::kPluginsEnabledPlugins), 95 prefs::kPluginsEnabledPlugins),
98 PolicyAndPref(key::kDisabledSchemes, 96 PolicyAndPref(key::kDisabledSchemes,
99 prefs::kDisabledSchemes), 97 prefs::kDisabledSchemes),
100 PolicyAndPref(key::kAutoSelectCertificateForUrls, 98 PolicyAndPref(key::kAutoSelectCertificateForUrls,
101 prefs::kManagedAutoSelectCertificateForUrls), 99 prefs::kManagedAutoSelectCertificateForUrls),
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 // DefaultJavaScriptSetting overrides JavascriptEnabled. 1062 // DefaultJavaScriptSetting overrides JavascriptEnabled.
1065 policy.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, 1063 policy.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY,
1066 POLICY_SCOPE_USER, 1064 POLICY_SCOPE_USER,
1067 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); 1065 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW));
1068 provider_.UpdateChromePolicy(policy); 1066 provider_.UpdateChromePolicy(policy);
1069 EXPECT_EQ(PrefStore::READ_OK, 1067 EXPECT_EQ(PrefStore::READ_OK,
1070 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value)); 1068 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value));
1071 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_ALLOW).Equals(value)); 1069 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_ALLOW).Equals(value));
1072 } 1070 }
1073 1071
1072 TEST_F(ConfigurationPolicyPrefStoreOthersTest, RestoreOnStartupURLs) {
1073 EXPECT_EQ(PrefStore::READ_NO_VALUE,
1074 store_->GetValue(prefs::kURLsToRestoreOnStartup, NULL));
1075 EXPECT_EQ(PrefStore::READ_NO_VALUE,
1076 store_->GetValue(prefs::kSyncPromoShowOnFirstRunAllowed, NULL));
1077 base::ListValue* in_urls = new base::ListValue();
1078 in_urls->Append(base::Value::CreateStringValue("test1"));
1079 in_urls->Append(base::Value::CreateStringValue("test2,"));
1080 PolicyMap policy;
1081 policy.Set(key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY,
1082 POLICY_SCOPE_USER, in_urls);
1083 provider_.UpdateChromePolicy(policy);
1084 const base::Value* out_urls = NULL;
1085 EXPECT_EQ(PrefStore::READ_OK,
1086 store_->GetValue(prefs::kURLsToRestoreOnStartup, &out_urls));
1087 ASSERT_TRUE(out_urls);
1088 EXPECT_TRUE(in_urls->Equals(out_urls));
1089 const base::Value* out_sync_promo_enabled = NULL;
1090 EXPECT_EQ(PrefStore::READ_OK,
1091 store_->GetValue(prefs::kSyncPromoShowOnFirstRunAllowed,
1092 &out_sync_promo_enabled));
1093 ASSERT_TRUE(out_sync_promo_enabled);
1094 EXPECT_TRUE(base::Value::CreateBooleanValue(false)->
Mattias Nissler (ping if slow) 2012/05/22 14:58:41 You are leaking the created value here. An alterna
bartfab (slow) 2012/05/22 15:30:54 I leaked it on purpose because I figured in_urls w
Mattias Nissler (ping if slow) 2012/05/22 15:35:44 The rule is "Never leak a thing!", even in unit te
1095 Equals(out_sync_promo_enabled));
1096 }
1097
1074 } // namespace policy 1098 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698