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

Side by Side Diff: chrome/browser/profiles/incognito_mode_policy_handler_unittest.cc

Issue 1350913006: Revert of Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 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/prefs/incognito_mode_prefs.h" 5 #include "chrome/browser/prefs/incognito_mode_prefs.h"
6 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" 6 #include "chrome/browser/profiles/incognito_mode_policy_handler.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/common/policy_types.h"
11 #include "policy/policy_constants.h" 10 #include "policy/policy_constants.h"
12 11
13 namespace policy { 12 namespace policy {
14 13
15 // Tests Incognito mode availability preference setting. 14 // Tests Incognito mode availability preference setting.
16 class IncognitoModePolicyHandlerTest 15 class IncognitoModePolicyHandlerTest
17 : public ConfigurationPolicyPrefStoreTest { 16 : public ConfigurationPolicyPrefStoreTest {
18 public: 17 public:
19 void SetUp() override { 18 void SetUp() override {
20 handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( 19 handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
21 new IncognitoModePolicyHandler)); 20 new IncognitoModePolicyHandler));
22 } 21 }
23 protected: 22 protected:
24 static const int kIncognitoModeAvailabilityNotSet = -1; 23 static const int kIncognitoModeAvailabilityNotSet = -1;
25 24
26 enum ObsoleteIncognitoEnabledValue { 25 enum ObsoleteIncognitoEnabledValue {
27 INCOGNITO_ENABLED_UNKNOWN, 26 INCOGNITO_ENABLED_UNKNOWN,
28 INCOGNITO_ENABLED_TRUE, 27 INCOGNITO_ENABLED_TRUE,
29 INCOGNITO_ENABLED_FALSE 28 INCOGNITO_ENABLED_FALSE
30 }; 29 };
31 30
32 void SetPolicies(ObsoleteIncognitoEnabledValue incognito_enabled, 31 void SetPolicies(ObsoleteIncognitoEnabledValue incognito_enabled,
33 int availability) { 32 int availability) {
34 PolicyMap policy; 33 PolicyMap policy;
35 if (incognito_enabled != INCOGNITO_ENABLED_UNKNOWN) { 34 if (incognito_enabled != INCOGNITO_ENABLED_UNKNOWN) {
36 policy.Set(key::kIncognitoEnabled, 35 policy.Set(key::kIncognitoEnabled,
37 POLICY_LEVEL_MANDATORY, 36 POLICY_LEVEL_MANDATORY,
38 POLICY_SCOPE_USER, 37 POLICY_SCOPE_USER,
39 POLICY_SOURCE_CLOUD,
40 new base::FundamentalValue(incognito_enabled == 38 new base::FundamentalValue(incognito_enabled ==
41 INCOGNITO_ENABLED_TRUE), 39 INCOGNITO_ENABLED_TRUE),
42 NULL); 40 NULL);
43 } 41 }
44 if (availability >= 0) { 42 if (availability >= 0) {
45 policy.Set(key::kIncognitoModeAvailability, 43 policy.Set(key::kIncognitoModeAvailability,
46 POLICY_LEVEL_MANDATORY, 44 POLICY_LEVEL_MANDATORY,
47 POLICY_SCOPE_USER, 45 POLICY_SCOPE_USER,
48 POLICY_SOURCE_CLOUD,
49 new base::FundamentalValue(availability), 46 new base::FundamentalValue(availability),
50 NULL); 47 NULL);
51 } 48 }
52 UpdateProviderPolicy(policy); 49 UpdateProviderPolicy(policy);
53 } 50 }
54 51
55 void VerifyValues(IncognitoModePrefs::Availability availability) { 52 void VerifyValues(IncognitoModePrefs::Availability availability) {
56 const base::Value* value = NULL; 53 const base::Value* value = NULL;
57 EXPECT_TRUE(store_->GetValue(prefs::kIncognitoModeAvailability, &value)); 54 EXPECT_TRUE(store_->GetValue(prefs::kIncognitoModeAvailability, &value));
58 EXPECT_TRUE(base::FundamentalValue(availability).Equals(value)); 55 EXPECT_TRUE(base::FundamentalValue(availability).Equals(value));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 VerifyValues(IncognitoModePrefs::ENABLED); 105 VerifyValues(IncognitoModePrefs::ENABLED);
109 } 106 }
110 107
111 TEST_F(IncognitoModePolicyHandlerTest, 108 TEST_F(IncognitoModePolicyHandlerTest,
112 ObsoletePolicySetsPreferenceToDisabled) { 109 ObsoletePolicySetsPreferenceToDisabled) {
113 SetPolicies(INCOGNITO_ENABLED_FALSE, kIncognitoModeAvailabilityNotSet); 110 SetPolicies(INCOGNITO_ENABLED_FALSE, kIncognitoModeAvailabilityNotSet);
114 VerifyValues(IncognitoModePrefs::DISABLED); 111 VerifyValues(IncognitoModePrefs::DISABLED);
115 } 112 }
116 113
117 } // namespace policy 114 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/prefs/synced_pref_change_registrar_browsertest.cc ('k') | chrome/browser/resources/policy.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698