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/device_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 store_ = new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 91 store_ = new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
92 install_attributes_.get(), | 92 install_attributes_.get(), |
93 loop_.message_loop_proxy()); | 93 loop_.message_loop_proxy()); |
94 manager_.reset(new DeviceCloudPolicyManagerChromeOS( | 94 manager_.reset(new DeviceCloudPolicyManagerChromeOS( |
95 make_scoped_ptr(store_), | 95 make_scoped_ptr(store_), |
96 loop_.message_loop_proxy(), | 96 loop_.message_loop_proxy(), |
97 loop_.message_loop_proxy(), | 97 loop_.message_loop_proxy(), |
98 install_attributes_.get())); | 98 install_attributes_.get())); |
99 | 99 |
100 chrome::RegisterLocalState(local_state_.registry()); | 100 chrome::RegisterLocalState(local_state_.registry()); |
101 manager_->Init(); | 101 manager_->Init(&schema_registry_); |
102 | 102 |
103 // DeviceOAuth2TokenService uses the system request context to fetch | 103 // DeviceOAuth2TokenService uses the system request context to fetch |
104 // OAuth tokens, then writes the token to local state, encrypting it | 104 // OAuth tokens, then writes the token to local state, encrypting it |
105 // first with methods in CryptohomeTokenEncryptor. | 105 // first with methods in CryptohomeTokenEncryptor. |
106 request_context_getter_ = new net::TestURLRequestContextGetter( | 106 request_context_getter_ = new net::TestURLRequestContextGetter( |
107 loop_.message_loop_proxy()); | 107 loop_.message_loop_proxy()); |
108 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( | 108 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( |
109 request_context_getter_.get()); | 109 request_context_getter_.get()); |
110 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | 110 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); |
111 // SystemSaltGetter is used in DeviceOAuth2TokenServiceFactory. | 111 // SystemSaltGetter is used in DeviceOAuth2TokenServiceFactory. |
(...skipping 20 matching lines...) Expand all Loading... | |
132 net::TestURLFetcherFactory url_fetcher_factory_; | 132 net::TestURLFetcherFactory url_fetcher_factory_; |
133 int url_fetcher_response_code_; | 133 int url_fetcher_response_code_; |
134 string url_fetcher_response_string_; | 134 string url_fetcher_response_string_; |
135 TestingPrefServiceSimple local_state_; | 135 TestingPrefServiceSimple local_state_; |
136 MockDeviceManagementService device_management_service_; | 136 MockDeviceManagementService device_management_service_; |
137 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 137 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
138 chromeos::ScopedTestCrosSettings test_cros_settings_; | 138 chromeos::ScopedTestCrosSettings test_cros_settings_; |
139 chromeos::system::MockStatisticsProvider mock_statistics_provider_; | 139 chromeos::system::MockStatisticsProvider mock_statistics_provider_; |
140 | 140 |
141 DeviceCloudPolicyStoreChromeOS* store_; | 141 DeviceCloudPolicyStoreChromeOS* store_; |
142 SchemaRegistry schema_registry_; | |
bartfab (slow)
2013/11/05 15:53:04
Nit: #include "chrome/browser/policy/schema_regist
Joao da Silva
2013/11/07 13:15:00
Done.
| |
142 scoped_ptr<DeviceCloudPolicyManagerChromeOS> manager_; | 143 scoped_ptr<DeviceCloudPolicyManagerChromeOS> manager_; |
143 | 144 |
144 private: | 145 private: |
145 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest); | 146 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest); |
146 }; | 147 }; |
147 | 148 |
148 TEST_F(DeviceCloudPolicyManagerChromeOSTest, FreshDevice) { | 149 TEST_F(DeviceCloudPolicyManagerChromeOSTest, FreshDevice) { |
149 owner_key_util_->Clear(); | 150 owner_key_util_->Clear(); |
150 FlushDeviceSettings(); | 151 FlushDeviceSettings(); |
151 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 152 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { | 527 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { |
527 loaded_blob_.clear(); | 528 loaded_blob_.clear(); |
528 RunTest(); | 529 RunTest(); |
529 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); | 530 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); |
530 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, | 531 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, |
531 status_.store_status()); | 532 status_.store_status()); |
532 } | 533 } |
533 | 534 |
534 } // namespace | 535 } // namespace |
535 } // namespace policy | 536 } // namespace policy |
OLD | NEW |