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 "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/test/base/testing_browser_process.h" | 26 #include "chrome/test/base/testing_browser_process.h" |
27 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
28 #include "chrome/test/base/testing_profile_manager.h" | 28 #include "chrome/test/base/testing_profile_manager.h" |
29 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 29 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
30 #include "components/policy/core/common/cloud/mock_cloud_external_data_manager.h
" | 30 #include "components/policy/core/common/cloud/mock_cloud_external_data_manager.h
" |
31 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 31 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
32 #include "components/policy/core/common/cloud/mock_device_management_service.h" | 32 #include "components/policy/core/common/cloud/mock_device_management_service.h" |
33 #include "components/policy/core/common/external_data_fetcher.h" | 33 #include "components/policy/core/common/external_data_fetcher.h" |
34 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 34 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
35 #include "components/policy/core/common/policy_types.h" | |
36 #include "components/policy/core/common/schema_registry.h" | 35 #include "components/policy/core/common/schema_registry.h" |
37 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 36 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
38 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 37 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
39 #include "components/signin/core/browser/signin_manager.h" | 38 #include "components/signin/core/browser/signin_manager.h" |
40 #include "components/syncable_prefs/pref_service_syncable.h" | 39 #include "components/syncable_prefs/pref_service_syncable.h" |
41 #include "components/user_manager/fake_user_manager.h" | 40 #include "components/user_manager/fake_user_manager.h" |
42 #include "content/public/test/test_browser_thread_bundle.h" | 41 #include "content/public/test/test_browser_thread_bundle.h" |
43 #include "google_apis/gaia/gaia_auth_consumer.h" | 42 #include "google_apis/gaia/gaia_auth_consumer.h" |
44 #include "google_apis/gaia/gaia_constants.h" | 43 #include "google_apis/gaia/gaia_constants.h" |
45 #include "google_apis/gaia/gaia_urls.h" | 44 #include "google_apis/gaia/gaia_urls.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // the signin Profile is an OTR Profile then for this test it suffices to | 104 // the signin Profile is an OTR Profile then for this test it suffices to |
106 // attach it to the main Profile. | 105 // attach it to the main Profile. |
107 signin_profile_ = TestingProfile::Builder().BuildIncognito(profile_); | 106 signin_profile_ = TestingProfile::Builder().BuildIncognito(profile_); |
108 ASSERT_EQ(signin_profile_, chromeos::ProfileHelper::GetSigninProfile()); | 107 ASSERT_EQ(signin_profile_, chromeos::ProfileHelper::GetSigninProfile()); |
109 | 108 |
110 chrome::RegisterLocalState(prefs_.registry()); | 109 chrome::RegisterLocalState(prefs_.registry()); |
111 | 110 |
112 // Set up a policy map for testing. | 111 // Set up a policy map for testing. |
113 policy_map_.Set(key::kHomepageLocation, | 112 policy_map_.Set(key::kHomepageLocation, |
114 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 113 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
115 POLICY_SOURCE_CLOUD, | |
116 new base::StringValue("http://chromium.org"), | 114 new base::StringValue("http://chromium.org"), |
117 NULL); | 115 NULL); |
118 policy_map_.Set(key::kChromeOsMultiProfileUserBehavior, | 116 policy_map_.Set(key::kChromeOsMultiProfileUserBehavior, |
119 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 117 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
120 POLICY_SOURCE_ENTERPRISE_DEFAULT, | |
121 new base::StringValue("primary-only"), | 118 new base::StringValue("primary-only"), |
122 NULL); | 119 NULL); |
123 policy_map_.Set(key::kEasyUnlockAllowed, | 120 policy_map_.Set(key::kEasyUnlockAllowed, |
124 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 121 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
125 POLICY_SOURCE_CLOUD, | |
126 new base::FundamentalValue(false), | 122 new base::FundamentalValue(false), |
127 NULL); | 123 NULL); |
128 policy_map_.Set(key::kCaptivePortalAuthenticationIgnoresProxy, | 124 policy_map_.Set(key::kCaptivePortalAuthenticationIgnoresProxy, |
129 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 125 POLICY_LEVEL_MANDATORY, |
130 POLICY_SOURCE_CLOUD, | 126 POLICY_SCOPE_USER, |
131 new base::FundamentalValue(false), | 127 new base::FundamentalValue(false), |
132 NULL); | 128 NULL); |
133 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 129 expected_bundle_.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
134 .CopyFrom(policy_map_); | 130 .CopyFrom(policy_map_); |
135 | 131 |
136 // Create fake policy blobs to deliver to the client. | 132 // Create fake policy blobs to deliver to the client. |
137 em::DeviceRegisterResponse* register_response = | 133 em::DeviceRegisterResponse* register_response = |
138 register_blob_.mutable_register_response(); | 134 register_blob_.mutable_register_response(); |
139 register_response->set_device_management_token("dmtoken123"); | 135 register_response->set_device_management_token("dmtoken123"); |
140 | 136 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 585 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
590 EXPECT_TRUE(manager_->core()->client()->is_registered()); | 586 EXPECT_TRUE(manager_->core()->client()->is_registered()); |
591 | 587 |
592 // The refresh scheduler takes care of the initial fetch for unmanaged users. | 588 // The refresh scheduler takes care of the initial fetch for unmanaged users. |
593 // Running the task runner issues the initial fetch. | 589 // Running the task runner issues the initial fetch. |
594 FetchPolicy( | 590 FetchPolicy( |
595 base::Bind(&base::TestSimpleTaskRunner::RunUntilIdle, task_runner_)); | 591 base::Bind(&base::TestSimpleTaskRunner::RunUntilIdle, task_runner_)); |
596 } | 592 } |
597 | 593 |
598 } // namespace policy | 594 } // namespace policy |
OLD | NEW |