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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc

Issue 56623005: Policy providers all get a SchemaRegistry to work with. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-9-purge-with-callback
Patch Set: rebase Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/device_local_account_policy_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/prefs/pref_registry_simple.h" 11 #include "base/prefs/pref_registry_simple.h"
12 #include "base/prefs/testing_pref_service.h" 12 #include "base/prefs/testing_pref_service.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" 14 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" 15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
16 #include "chrome/browser/chromeos/settings/cros_settings.h" 16 #include "chrome/browser/chromeos/settings/cros_settings.h"
17 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 17 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
18 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 18 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
19 #include "chrome/browser/chromeos/settings/device_settings_service.h" 19 #include "chrome/browser/chromeos/settings/device_settings_service.h"
20 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 20 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
21 #include "chrome/browser/policy/cloud/cloud_policy_client.h" 21 #include "chrome/browser/policy/cloud/cloud_policy_client.h"
22 #include "chrome/browser/policy/cloud/mock_device_management_service.h" 22 #include "chrome/browser/policy/cloud/mock_device_management_service.h"
23 #include "chrome/browser/policy/external_data_fetcher.h" 23 #include "chrome/browser/policy/external_data_fetcher.h"
24 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" 24 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h"
25 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" 25 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
26 #include "chrome/browser/policy/schema_registry.h"
26 #include "chrome/browser/prefs/browser_prefs.h" 27 #include "chrome/browser/prefs/browser_prefs.h"
27 #include "chrome/test/base/testing_browser_process.h" 28 #include "chrome/test/base/testing_browser_process.h"
28 #include "chromeos/cryptohome/system_salt_getter.h" 29 #include "chromeos/cryptohome/system_salt_getter.h"
29 #include "chromeos/dbus/dbus_client_implementation_type.h" 30 #include "chromeos/dbus/dbus_client_implementation_type.h"
30 #include "chromeos/dbus/dbus_thread_manager.h" 31 #include "chromeos/dbus/dbus_thread_manager.h"
31 #include "chromeos/system/mock_statistics_provider.h" 32 #include "chromeos/system/mock_statistics_provider.h"
32 #include "chromeos/system/statistics_provider.h" 33 #include "chromeos/system/statistics_provider.h"
33 #include "google_apis/gaia/gaia_oauth_client.h" 34 #include "google_apis/gaia/gaia_oauth_client.h"
34 #include "net/url_request/test_url_fetcher_factory.h" 35 #include "net/url_request/test_url_fetcher_factory.h"
35 #include "net/url_request/url_request_test_util.h" 36 #include "net/url_request/url_request_test_util.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 store_ = new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, 92 store_ = new DeviceCloudPolicyStoreChromeOS(&device_settings_service_,
92 install_attributes_.get(), 93 install_attributes_.get(),
93 loop_.message_loop_proxy()); 94 loop_.message_loop_proxy());
94 manager_.reset(new DeviceCloudPolicyManagerChromeOS( 95 manager_.reset(new DeviceCloudPolicyManagerChromeOS(
95 make_scoped_ptr(store_), 96 make_scoped_ptr(store_),
96 loop_.message_loop_proxy(), 97 loop_.message_loop_proxy(),
97 loop_.message_loop_proxy(), 98 loop_.message_loop_proxy(),
98 install_attributes_.get())); 99 install_attributes_.get()));
99 100
100 chrome::RegisterLocalState(local_state_.registry()); 101 chrome::RegisterLocalState(local_state_.registry());
101 manager_->Init(); 102 manager_->Init(&schema_registry_);
102 103
103 // DeviceOAuth2TokenService uses the system request context to fetch 104 // DeviceOAuth2TokenService uses the system request context to fetch
104 // OAuth tokens, then writes the token to local state, encrypting it 105 // OAuth tokens, then writes the token to local state, encrypting it
105 // first with methods in CryptohomeTokenEncryptor. 106 // first with methods in CryptohomeTokenEncryptor.
106 request_context_getter_ = new net::TestURLRequestContextGetter( 107 request_context_getter_ = new net::TestURLRequestContextGetter(
107 loop_.message_loop_proxy()); 108 loop_.message_loop_proxy());
108 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( 109 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext(
109 request_context_getter_.get()); 110 request_context_getter_.get());
110 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); 111 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
111 // SystemSaltGetter is used in DeviceOAuth2TokenServiceFactory. 112 // SystemSaltGetter is used in DeviceOAuth2TokenServiceFactory.
(...skipping 20 matching lines...) Expand all
132 net::TestURLFetcherFactory url_fetcher_factory_; 133 net::TestURLFetcherFactory url_fetcher_factory_;
133 int url_fetcher_response_code_; 134 int url_fetcher_response_code_;
134 string url_fetcher_response_string_; 135 string url_fetcher_response_string_;
135 TestingPrefServiceSimple local_state_; 136 TestingPrefServiceSimple local_state_;
136 MockDeviceManagementService device_management_service_; 137 MockDeviceManagementService device_management_service_;
137 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 138 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
138 chromeos::ScopedTestCrosSettings test_cros_settings_; 139 chromeos::ScopedTestCrosSettings test_cros_settings_;
139 chromeos::system::MockStatisticsProvider mock_statistics_provider_; 140 chromeos::system::MockStatisticsProvider mock_statistics_provider_;
140 141
141 DeviceCloudPolicyStoreChromeOS* store_; 142 DeviceCloudPolicyStoreChromeOS* store_;
143 SchemaRegistry schema_registry_;
142 scoped_ptr<DeviceCloudPolicyManagerChromeOS> manager_; 144 scoped_ptr<DeviceCloudPolicyManagerChromeOS> manager_;
143 145
144 private: 146 private:
145 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest); 147 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest);
146 }; 148 };
147 149
148 TEST_F(DeviceCloudPolicyManagerChromeOSTest, FreshDevice) { 150 TEST_F(DeviceCloudPolicyManagerChromeOSTest, FreshDevice) {
149 owner_key_util_->Clear(); 151 owner_key_util_->Clear();
150 FlushDeviceSettings(); 152 FlushDeviceSettings();
151 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); 153 EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { 528 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) {
527 loaded_blob_.clear(); 529 loaded_blob_.clear();
528 RunTest(); 530 RunTest();
529 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); 531 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR);
530 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, 532 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR,
531 status_.store_status()); 533 status_.store_status());
532 } 534 }
533 535
534 } // namespace 536 } // namespace
535 } // namespace policy 537 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/device_local_account_policy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698