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

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

Issue 397793002: Eliminate CreateBooleanValue from test files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad merge Created 6 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/policy/javascript_policy_handler.h" 5 #include "chrome/browser/policy/javascript_policy_handler.h"
6 #include "chrome/common/content_settings.h" 6 #include "chrome/common/content_settings.h"
7 #include "chrome/common/pref_names.h" 7 #include "chrome/common/pref_names.h"
8 #include "components/policy/core/browser/configuration_policy_pref_store.h" 8 #include "components/policy/core/browser/configuration_policy_pref_store.h"
9 #include "components/policy/core/browser/configuration_policy_pref_store_test.h" 9 #include "components/policy/core/browser/configuration_policy_pref_store_test.h"
10 #include "components/policy/core/browser/policy_error_map.h" 10 #include "components/policy/core/browser/policy_error_map.h"
11 #include "components/policy/core/common/policy_map.h" 11 #include "components/policy/core/common/policy_map.h"
12 #include "policy/policy_constants.h" 12 #include "policy/policy_constants.h"
13 13
14 namespace policy { 14 namespace policy {
15 15
16 class JavascriptPolicyHandlerTest : public ConfigurationPolicyPrefStoreTest { 16 class JavascriptPolicyHandlerTest : public ConfigurationPolicyPrefStoreTest {
17 virtual void SetUp() OVERRIDE { 17 virtual void SetUp() OVERRIDE {
18 handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( 18 handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
19 new JavascriptPolicyHandler)); 19 new JavascriptPolicyHandler));
20 } 20 }
21 }; 21 };
22 22
23 TEST_F(JavascriptPolicyHandlerTest, JavascriptEnabled) { 23 TEST_F(JavascriptPolicyHandlerTest, JavascriptEnabled) {
24 // This is a boolean policy, but affects an integer preference. 24 // This is a boolean policy, but affects an integer preference.
25 EXPECT_FALSE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); 25 EXPECT_FALSE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL));
26 PolicyMap policy; 26 PolicyMap policy;
27 policy.Set(key::kJavascriptEnabled, 27 policy.Set(key::kJavascriptEnabled,
28 POLICY_LEVEL_MANDATORY, 28 POLICY_LEVEL_MANDATORY,
29 POLICY_SCOPE_USER, 29 POLICY_SCOPE_USER,
30 base::Value::CreateBooleanValue(true), 30 new base::FundamentalValue(true),
31 NULL); 31 NULL);
32 UpdateProviderPolicy(policy); 32 UpdateProviderPolicy(policy);
33 EXPECT_FALSE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); 33 EXPECT_FALSE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL));
34 policy.Set(key::kJavascriptEnabled, 34 policy.Set(key::kJavascriptEnabled,
35 POLICY_LEVEL_MANDATORY, 35 POLICY_LEVEL_MANDATORY,
36 POLICY_SCOPE_USER, 36 POLICY_SCOPE_USER,
37 base::Value::CreateBooleanValue(false), 37 new base::FundamentalValue(false),
38 NULL); 38 NULL);
39 UpdateProviderPolicy(policy); 39 UpdateProviderPolicy(policy);
40 const base::Value* value = NULL; 40 const base::Value* value = NULL;
41 EXPECT_TRUE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, 41 EXPECT_TRUE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting,
42 &value)); 42 &value));
43 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value)); 43 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value));
44 } 44 }
45 45
46 TEST_F(JavascriptPolicyHandlerTest, JavascriptEnabledOverridden) { 46 TEST_F(JavascriptPolicyHandlerTest, JavascriptEnabledOverridden) {
47 EXPECT_FALSE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); 47 EXPECT_FALSE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL));
48 PolicyMap policy; 48 PolicyMap policy;
49 policy.Set(key::kJavascriptEnabled, 49 policy.Set(key::kJavascriptEnabled,
50 POLICY_LEVEL_MANDATORY, 50 POLICY_LEVEL_MANDATORY,
51 POLICY_SCOPE_USER, 51 POLICY_SCOPE_USER,
52 base::Value::CreateBooleanValue(false), 52 new base::FundamentalValue(false),
53 NULL); 53 NULL);
54 UpdateProviderPolicy(policy); 54 UpdateProviderPolicy(policy);
55 const base::Value* value = NULL; 55 const base::Value* value = NULL;
56 EXPECT_TRUE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, 56 EXPECT_TRUE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting,
57 &value)); 57 &value));
58 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value)); 58 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value));
59 // DefaultJavaScriptSetting overrides JavascriptEnabled. 59 // DefaultJavaScriptSetting overrides JavascriptEnabled.
60 policy.Set(key::kDefaultJavaScriptSetting, 60 policy.Set(key::kDefaultJavaScriptSetting,
61 POLICY_LEVEL_MANDATORY, 61 POLICY_LEVEL_MANDATORY,
62 POLICY_SCOPE_USER, 62 POLICY_SCOPE_USER,
63 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW), 63 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW),
64 NULL); 64 NULL);
65 UpdateProviderPolicy(policy); 65 UpdateProviderPolicy(policy);
66 EXPECT_TRUE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, 66 EXPECT_TRUE(store_->GetValue(prefs::kManagedDefaultJavaScriptSetting,
67 &value)); 67 &value));
68 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_ALLOW).Equals(value)); 68 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_ALLOW).Equals(value));
69 } 69 }
70 70
71 } // namespace policy 71 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/file_selection_dialogs_policy_handler_unittest.cc ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698