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

Side by Side Diff: chrome/browser/policy/profile_policy_connector_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/profile_policy_connector.h" 5 #include "chrome/browser/policy/profile_policy_connector.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/test/base/testing_browser_process.h" 9 #include "chrome/test/base/testing_browser_process.h"
10 #include "components/autofill/core/common/autofill_pref_names.h" 10 #include "components/autofill/core/common/autofill_pref_names.h"
11 #include "components/policy/core/browser/browser_policy_connector.h" 11 #include "components/policy/core/browser/browser_policy_connector.h"
12 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 12 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
13 #include "components/policy/core/common/cloud/cloud_policy_manager.h" 13 #include "components/policy/core/common/cloud/cloud_policy_manager.h"
14 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" 14 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h"
15 #include "components/policy/core/common/mock_configuration_policy_provider.h" 15 #include "components/policy/core/common/mock_configuration_policy_provider.h"
16 #include "components/policy/core/common/policy_bundle.h" 16 #include "components/policy/core/common/policy_bundle.h"
17 #include "components/policy/core/common/policy_map.h" 17 #include "components/policy/core/common/policy_map.h"
18 #include "components/policy/core/common/policy_service.h" 18 #include "components/policy/core/common/policy_service.h"
19 #include "components/policy/core/common/policy_types.h"
19 #include "components/policy/core/common/schema_registry.h" 20 #include "components/policy/core/common/schema_registry.h"
20 #include "policy/policy_constants.h" 21 #include "policy/policy_constants.h"
21 #include "policy/proto/device_management_backend.pb.h" 22 #include "policy/proto/device_management_backend.pb.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 using testing::Return; 26 using testing::Return;
26 using testing::_; 27 using testing::_;
27 28
28 namespace policy { 29 namespace policy {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 EXPECT_FALSE( 91 EXPECT_FALSE(
91 connector.IsPolicyFromCloudPolicy(autofill::prefs::kAutofillEnabled)); 92 connector.IsPolicyFromCloudPolicy(autofill::prefs::kAutofillEnabled));
92 PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, std::string()); 93 PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, std::string());
93 EXPECT_FALSE(connector.policy_service()->GetPolicies(chrome_ns).GetValue( 94 EXPECT_FALSE(connector.policy_service()->GetPolicies(chrome_ns).GetValue(
94 key::kAutoFillEnabled)); 95 key::kAutoFillEnabled));
95 96
96 // Set the policy at the cloud provider. 97 // Set the policy at the cloud provider.
97 cloud_policy_store_.policy_map_.Set(key::kAutoFillEnabled, 98 cloud_policy_store_.policy_map_.Set(key::kAutoFillEnabled,
98 POLICY_LEVEL_MANDATORY, 99 POLICY_LEVEL_MANDATORY,
99 POLICY_SCOPE_USER, 100 POLICY_SCOPE_USER,
101 POLICY_SOURCE_CLOUD,
100 new base::FundamentalValue(false), 102 new base::FundamentalValue(false),
101 nullptr); 103 nullptr);
102 cloud_policy_store_.NotifyStoreLoaded(); 104 cloud_policy_store_.NotifyStoreLoaded();
103 base::RunLoop().RunUntilIdle(); 105 base::RunLoop().RunUntilIdle();
104 EXPECT_TRUE(connector.IsPolicyFromCloudPolicy(key::kAutoFillEnabled)); 106 EXPECT_TRUE(connector.IsPolicyFromCloudPolicy(key::kAutoFillEnabled));
105 const base::Value* value = 107 const base::Value* value =
106 connector.policy_service()->GetPolicies(chrome_ns).GetValue( 108 connector.policy_service()->GetPolicies(chrome_ns).GetValue(
107 key::kAutoFillEnabled); 109 key::kAutoFillEnabled);
108 ASSERT_TRUE(value); 110 ASSERT_TRUE(value);
109 EXPECT_TRUE(base::FundamentalValue(false).Equals(value)); 111 EXPECT_TRUE(base::FundamentalValue(false).Equals(value));
110 112
111 // Now test with a higher-priority provider also setting the policy. 113 // Now test with a higher-priority provider also setting the policy.
112 PolicyMap map; 114 PolicyMap map;
113 map.Set(key::kAutoFillEnabled, 115 map.Set(key::kAutoFillEnabled,
114 POLICY_LEVEL_MANDATORY, 116 POLICY_LEVEL_MANDATORY,
115 POLICY_SCOPE_USER, 117 POLICY_SCOPE_USER,
118 POLICY_SOURCE_CLOUD,
116 new base::FundamentalValue(true), 119 new base::FundamentalValue(true),
117 nullptr); 120 nullptr);
118 mock_provider_.UpdateChromePolicy(map); 121 mock_provider_.UpdateChromePolicy(map);
119 EXPECT_FALSE(connector.IsPolicyFromCloudPolicy(key::kAutoFillEnabled)); 122 EXPECT_FALSE(connector.IsPolicyFromCloudPolicy(key::kAutoFillEnabled));
120 value = connector.policy_service()->GetPolicies(chrome_ns).GetValue( 123 value = connector.policy_service()->GetPolicies(chrome_ns).GetValue(
121 key::kAutoFillEnabled); 124 key::kAutoFillEnabled);
122 ASSERT_TRUE(value); 125 ASSERT_TRUE(value);
123 EXPECT_TRUE(base::FundamentalValue(true).Equals(value)); 126 EXPECT_TRUE(base::FundamentalValue(true).Equals(value));
124 127
125 // Cleanup. 128 // Cleanup.
126 connector.Shutdown(); 129 connector.Shutdown();
127 } 130 }
128 131
129 } // namespace policy 132 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_startup_browsertest.cc ('k') | chrome/browser/prefs/proxy_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698