OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/device_local_account_external_polic
y_loader.h" | 5 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic
y_loader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "base/version.h" | 20 #include "base/version.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "chrome/browser/extensions/external_provider_impl.h" | 22 #include "chrome/browser/extensions/external_provider_impl.h" |
23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
25 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 25 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
26 #include "components/policy/core/common/policy_map.h" | 26 #include "components/policy/core/common/policy_map.h" |
27 #include "components/policy/core/common/policy_types.h" | 27 #include "components/policy/core/common/policy_types.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/shell_context.h" |
30 #include "content/public/test/test_browser_thread_bundle.h" | 31 #include "content/public/test/test_browser_thread_bundle.h" |
31 #include "content/public/test/test_utils.h" | 32 #include "content/public/test/test_utils.h" |
32 #include "extensions/browser/external_install_info.h" | 33 #include "extensions/browser/external_install_info.h" |
33 #include "extensions/browser/external_provider_interface.h" | 34 #include "extensions/browser/external_provider_interface.h" |
34 #include "extensions/browser/notification_types.h" | 35 #include "extensions/browser/notification_types.h" |
35 #include "extensions/browser/updater/extension_downloader.h" | 36 #include "extensions/browser/updater/extension_downloader.h" |
36 #include "extensions/common/extension.h" | 37 #include "extensions/common/extension.h" |
37 #include "extensions/common/extension_urls.h" | 38 #include "extensions/common/extension_urls.h" |
38 #include "extensions/common/manifest.h" | 39 #include "extensions/common/manifest.h" |
39 #include "net/url_request/test_url_fetcher_factory.h" | 40 #include "net/url_request/test_url_fetcher_factory.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DeviceLocalAccountExternalPolicyLoaderTest(); | 106 DeviceLocalAccountExternalPolicyLoaderTest(); |
106 ~DeviceLocalAccountExternalPolicyLoaderTest() override; | 107 ~DeviceLocalAccountExternalPolicyLoaderTest() override; |
107 | 108 |
108 void SetUp() override; | 109 void SetUp() override; |
109 void TearDown() override; | 110 void TearDown() override; |
110 | 111 |
111 void VerifyAndResetVisitorCallExpectations(); | 112 void VerifyAndResetVisitorCallExpectations(); |
112 void SetForceInstallListPolicy(); | 113 void SetForceInstallListPolicy(); |
113 | 114 |
114 content::TestBrowserThreadBundle thread_bundle_; | 115 content::TestBrowserThreadBundle thread_bundle_; |
| 116 std::unique_ptr<content::ShellContext> shell_context_; |
115 base::ScopedTempDir temp_dir_; | 117 base::ScopedTempDir temp_dir_; |
116 base::FilePath cache_dir_; | 118 base::FilePath cache_dir_; |
117 policy::MockCloudPolicyStore store_; | 119 policy::MockCloudPolicyStore store_; |
118 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 120 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
119 base::FilePath test_dir_; | 121 base::FilePath test_dir_; |
120 | 122 |
121 scoped_refptr<DeviceLocalAccountExternalPolicyLoader> loader_; | 123 scoped_refptr<DeviceLocalAccountExternalPolicyLoader> loader_; |
122 MockExternalPolicyProviderVisitor visitor_; | 124 MockExternalPolicyProviderVisitor visitor_; |
123 std::unique_ptr<extensions::ExternalProviderImpl> provider_; | 125 std::unique_ptr<extensions::ExternalProviderImpl> provider_; |
124 | 126 |
125 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; | 127 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; |
126 | 128 |
127 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
128 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 130 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
129 chromeos::ScopedTestCrosSettings test_cros_settings_; | 131 chromeos::ScopedTestCrosSettings test_cros_settings_; |
130 #endif // defined(OS_CHROMEOS) | 132 #endif // defined(OS_CHROMEOS) |
131 }; | 133 }; |
132 | 134 |
133 DeviceLocalAccountExternalPolicyLoaderTest:: | 135 DeviceLocalAccountExternalPolicyLoaderTest:: |
134 DeviceLocalAccountExternalPolicyLoaderTest() | 136 DeviceLocalAccountExternalPolicyLoaderTest() |
135 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { | 137 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { |
136 } | 138 } |
137 | 139 |
138 DeviceLocalAccountExternalPolicyLoaderTest:: | 140 DeviceLocalAccountExternalPolicyLoaderTest:: |
139 ~DeviceLocalAccountExternalPolicyLoaderTest() { | 141 ~DeviceLocalAccountExternalPolicyLoaderTest() { |
140 } | 142 } |
141 | 143 |
142 void DeviceLocalAccountExternalPolicyLoaderTest::SetUp() { | 144 void DeviceLocalAccountExternalPolicyLoaderTest::SetUp() { |
| 145 shell_context_ = content::ShellContext::Create(); |
143 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 146 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
144 cache_dir_ = temp_dir_.path().Append(kCacheDir); | 147 cache_dir_ = temp_dir_.path().Append(kCacheDir); |
145 ASSERT_TRUE(base::CreateDirectoryAndGetError(cache_dir_, NULL)); | 148 ASSERT_TRUE(base::CreateDirectoryAndGetError(cache_dir_, NULL)); |
146 request_context_getter_ = | 149 request_context_getter_ = |
147 new net::TestURLRequestContextGetter(base::ThreadTaskRunnerHandle::Get()); | 150 new net::TestURLRequestContextGetter(base::ThreadTaskRunnerHandle::Get()); |
148 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( | 151 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( |
149 request_context_getter_.get()); | 152 request_context_getter_.get()); |
150 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); | 153 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); |
151 | 154 |
152 loader_ = new DeviceLocalAccountExternalPolicyLoader(&store_, cache_dir_); | 155 loader_ = new DeviceLocalAccountExternalPolicyLoader(&store_, cache_dir_); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 loader_->StopCache(shutdown_run_loop.QuitClosure()); | 315 loader_->StopCache(shutdown_run_loop.QuitClosure()); |
313 VerifyAndResetVisitorCallExpectations(); | 316 VerifyAndResetVisitorCallExpectations(); |
314 | 317 |
315 // Spin the loop until the cache shutdown callback is invoked. Verify that at | 318 // Spin the loop until the cache shutdown callback is invoked. Verify that at |
316 // that point, no further file I/O tasks are pending. | 319 // that point, no further file I/O tasks are pending. |
317 shutdown_run_loop.Run(); | 320 shutdown_run_loop.Run(); |
318 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); | 321 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); |
319 } | 322 } |
320 | 323 |
321 } // namespace chromeos | 324 } // namespace chromeos |
OLD | NEW |