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

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

Issue 2714493002: Load DeviceLocalAccount policy and DeviceSettings immediately on restore after Chrome crash. (Closed)
Patch Set: add flag to correctly process LoadImmediately() call Created 3 years, 10 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/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 base::MessageLoop loop_; 57 base::MessageLoop loop_;
58 SchemaRegistry schema_registry_; 58 SchemaRegistry schema_registry_;
59 MockConfigurationPolicyProvider mock_provider_; 59 MockConfigurationPolicyProvider mock_provider_;
60 MockCloudPolicyStore cloud_policy_store_; 60 MockCloudPolicyStore cloud_policy_store_;
61 std::unique_ptr<CloudPolicyManager> cloud_policy_manager_; 61 std::unique_ptr<CloudPolicyManager> cloud_policy_manager_;
62 }; 62 };
63 63
64 TEST_F(ProfilePolicyConnectorTest, IsManagedForManagedUsers) { 64 TEST_F(ProfilePolicyConnectorTest, IsManagedForManagedUsers) {
65 ProfilePolicyConnector connector; 65 ProfilePolicyConnector connector;
66 connector.Init(nullptr /* user */, &schema_registry_, 66 connector.Init(nullptr /* user */, &schema_registry_,
67 cloud_policy_manager_.get(), &cloud_policy_store_); 67 cloud_policy_manager_.get(), &cloud_policy_store_, false);
68 EXPECT_FALSE(connector.IsManaged()); 68 EXPECT_FALSE(connector.IsManaged());
69 EXPECT_EQ(connector.GetManagementDomain(), ""); 69 EXPECT_EQ(connector.GetManagementDomain(), "");
70 70
71 cloud_policy_store_.policy_.reset(new enterprise_management::PolicyData()); 71 cloud_policy_store_.policy_.reset(new enterprise_management::PolicyData());
72 cloud_policy_store_.policy_->set_username("test@testdomain.com"); 72 cloud_policy_store_.policy_->set_username("test@testdomain.com");
73 cloud_policy_store_.policy_->set_state( 73 cloud_policy_store_.policy_->set_state(
74 enterprise_management::PolicyData::ACTIVE); 74 enterprise_management::PolicyData::ACTIVE);
75 EXPECT_TRUE(connector.IsManaged()); 75 EXPECT_TRUE(connector.IsManaged());
76 EXPECT_EQ(connector.GetManagementDomain(), "testdomain.com"); 76 EXPECT_EQ(connector.GetManagementDomain(), "testdomain.com");
77 77
78 // Cleanup. 78 // Cleanup.
79 connector.Shutdown(); 79 connector.Shutdown();
80 } 80 }
81 81
82 TEST_F(ProfilePolicyConnectorTest, IsProfilePolicy) { 82 TEST_F(ProfilePolicyConnectorTest, IsProfilePolicy) {
83 ProfilePolicyConnector connector; 83 ProfilePolicyConnector connector;
84 connector.Init(nullptr /* user */, &schema_registry_, 84 connector.Init(nullptr /* user */, &schema_registry_,
85 cloud_policy_manager_.get(), &cloud_policy_store_); 85 cloud_policy_manager_.get(), &cloud_policy_store_, false);
86 86
87 // No policy is set initially. 87 // No policy is set initially.
88 EXPECT_FALSE(connector.IsProfilePolicy(autofill::prefs::kAutofillEnabled)); 88 EXPECT_FALSE(connector.IsProfilePolicy(autofill::prefs::kAutofillEnabled));
89 PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, std::string()); 89 PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, std::string());
90 EXPECT_FALSE(connector.policy_service()->GetPolicies(chrome_ns).GetValue( 90 EXPECT_FALSE(connector.policy_service()->GetPolicies(chrome_ns).GetValue(
91 key::kAutoFillEnabled)); 91 key::kAutoFillEnabled));
92 92
93 // Set the policy at the cloud provider. 93 // Set the policy at the cloud provider.
94 cloud_policy_store_.policy_map_.Set( 94 cloud_policy_store_.policy_map_.Set(
95 key::kAutoFillEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 95 key::kAutoFillEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
(...skipping 18 matching lines...) Expand all
114 value = connector.policy_service()->GetPolicies(chrome_ns).GetValue( 114 value = connector.policy_service()->GetPolicies(chrome_ns).GetValue(
115 key::kAutoFillEnabled); 115 key::kAutoFillEnabled);
116 ASSERT_TRUE(value); 116 ASSERT_TRUE(value);
117 EXPECT_TRUE(base::FundamentalValue(true).Equals(value)); 117 EXPECT_TRUE(base::FundamentalValue(true).Equals(value));
118 118
119 // Cleanup. 119 // Cleanup.
120 connector.Shutdown(); 120 connector.Shutdown();
121 } 121 }
122 122
123 } // namespace policy 123 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698