OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/policy/user_policy_test_helper.h" | 5 #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 command_line->AppendSwitchASCII(policy::switches::kDeviceManagementUrl, | 84 command_line->AppendSwitchASCII(policy::switches::kDeviceManagementUrl, |
85 test_server_->GetServiceURL().spec()); | 85 test_server_->GetServiceURL().spec()); |
86 } | 86 } |
87 | 87 |
88 void UserPolicyTestHelper::WaitForInitialPolicy(Profile* profile) { | 88 void UserPolicyTestHelper::WaitForInitialPolicy(Profile* profile) { |
89 BrowserPolicyConnector* const connector = | 89 BrowserPolicyConnector* const connector = |
90 g_browser_process->browser_policy_connector(); | 90 g_browser_process->browser_policy_connector(); |
91 connector->ScheduleServiceInitialization(0); | 91 connector->ScheduleServiceInitialization(0); |
92 | 92 |
93 UserCloudPolicyManagerChromeOS* const policy_manager = | 93 UserCloudPolicyManagerChromeOS* const policy_manager = |
94 UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile); | 94 UserCloudPolicyManagerFactoryChromeOS::GetCloudPolicyManagerForProfile( |
| 95 profile); |
95 | 96 |
96 // Give a bogus OAuth token to the |policy_manager|. This should make its | 97 // Give a bogus OAuth token to the |policy_manager|. This should make its |
97 // CloudPolicyClient fetch the DMToken. | 98 // CloudPolicyClient fetch the DMToken. |
98 ASSERT_FALSE(policy_manager->core()->client()->is_registered()); | 99 ASSERT_FALSE(policy_manager->core()->client()->is_registered()); |
99 const enterprise_management::DeviceRegisterRequest::Type registration_type = | 100 const enterprise_management::DeviceRegisterRequest::Type registration_type = |
100 enterprise_management::DeviceRegisterRequest::USER; | 101 enterprise_management::DeviceRegisterRequest::USER; |
101 policy_manager->core()->client()->Register( | 102 policy_manager->core()->client()->Register( |
102 registration_type, | 103 registration_type, |
103 enterprise_management::DeviceRegisterRequest::FLAVOR_USER_REGISTRATION, | 104 enterprise_management::DeviceRegisterRequest::FLAVOR_USER_REGISTRATION, |
104 "bogus", std::string(), std::string(), std::string()); | 105 "bogus", std::string(), std::string(), std::string()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 const int bytes_written = | 142 const int bytes_written = |
142 base::WriteFile(PolicyFilePath(), policy.data(), policy.size()); | 143 base::WriteFile(PolicyFilePath(), policy.data(), policy.size()); |
143 ASSERT_EQ(static_cast<int>(policy.size()), bytes_written); | 144 ASSERT_EQ(static_cast<int>(policy.size()), bytes_written); |
144 } | 145 } |
145 | 146 |
146 base::FilePath UserPolicyTestHelper::PolicyFilePath() const { | 147 base::FilePath UserPolicyTestHelper::PolicyFilePath() const { |
147 return temp_dir_.GetPath().AppendASCII("policy.json"); | 148 return temp_dir_.GetPath().AppendASCII("policy.json"); |
148 } | 149 } |
149 | 150 |
150 } // namespace policy | 151 } // namespace policy |
OLD | NEW |