OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
80 KeyedService* BuildFakeProfileInvalidationProvider( | 80 KeyedService* BuildFakeProfileInvalidationProvider( |
81 content::BrowserContext* context) { | 81 content::BrowserContext* context) { |
82 return new invalidation::ProfileInvalidationProvider( | 82 return new invalidation::ProfileInvalidationProvider( |
83 scoped_ptr<invalidation::InvalidationService>( | 83 scoped_ptr<invalidation::InvalidationService>( |
84 new invalidation::FakeInvalidationService)); | 84 new invalidation::FakeInvalidationService)); |
85 } | 85 } |
86 | 86 |
| 87 #if !defined(OS_CHROMEOS) |
| 88 const char* GetTestGaiaId() { |
| 89 return "gaia-id-user@example.com"; |
| 90 } |
| 91 #endif |
| 92 |
87 const char* GetTestUser() { | 93 const char* GetTestUser() { |
88 #if defined(OS_CHROMEOS) | 94 #if defined(OS_CHROMEOS) |
89 return chromeos::login::kStubUser; | 95 return chromeos::login::kStubUser; |
90 #else | 96 #else |
91 return "user@example.com"; | 97 return "user@example.com"; |
92 #endif | 98 #endif |
93 } | 99 } |
94 | 100 |
95 std::string GetEmptyPolicy() { | 101 std::string GetEmptyPolicy() { |
96 const char kEmptyPolicy[] = | 102 const char kEmptyPolicy[] = |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 UserCloudPolicyManagerChromeOS* policy_manager = | 245 UserCloudPolicyManagerChromeOS* policy_manager = |
240 UserCloudPolicyManagerFactoryChromeOS::GetForProfile( | 246 UserCloudPolicyManagerFactoryChromeOS::GetForProfile( |
241 browser()->profile()); | 247 browser()->profile()); |
242 ASSERT_TRUE(policy_manager); | 248 ASSERT_TRUE(policy_manager); |
243 #else | 249 #else |
244 // Mock a signed-in user. This is used by the UserCloudPolicyStore to pass | 250 // Mock a signed-in user. This is used by the UserCloudPolicyStore to pass |
245 // the username to the UserCloudPolicyValidator. | 251 // the username to the UserCloudPolicyValidator. |
246 SigninManager* signin_manager = | 252 SigninManager* signin_manager = |
247 SigninManagerFactory::GetForProfile(browser()->profile()); | 253 SigninManagerFactory::GetForProfile(browser()->profile()); |
248 ASSERT_TRUE(signin_manager); | 254 ASSERT_TRUE(signin_manager); |
249 signin_manager->SetAuthenticatedUsername(GetTestUser()); | 255 signin_manager->SetAuthenticatedAccountInfo(GetTestGaiaId(), GetTestUser()); |
250 | 256 |
251 UserCloudPolicyManager* policy_manager = | 257 UserCloudPolicyManager* policy_manager = |
252 UserCloudPolicyManagerFactory::GetForBrowserContext( | 258 UserCloudPolicyManagerFactory::GetForBrowserContext( |
253 browser()->profile()); | 259 browser()->profile()); |
254 ASSERT_TRUE(policy_manager); | 260 ASSERT_TRUE(policy_manager); |
255 policy_manager->Connect( | 261 policy_manager->Connect( |
256 g_browser_process->local_state(), | 262 g_browser_process->local_state(), |
257 g_browser_process->system_request_context(), | 263 g_browser_process->system_request_context(), |
258 UserCloudPolicyManager::CreateCloudPolicyClient( | 264 UserCloudPolicyManager::CreateCloudPolicyClient( |
259 connector->device_management_service(), | 265 connector->device_management_service(), |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 500 |
495 // They should now serialize to the same bytes. | 501 // They should now serialize to the same bytes. |
496 std::string chrome_settings_serialized; | 502 std::string chrome_settings_serialized; |
497 std::string cloud_policy_serialized; | 503 std::string cloud_policy_serialized; |
498 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); | 504 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); |
499 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); | 505 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); |
500 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); | 506 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); |
501 } | 507 } |
502 | 508 |
503 } // namespace policy | 509 } // namespace policy |
OLD | NEW |