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

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

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