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" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DeviceLocalAccountExternalPolicyLoaderTest() | 135 DeviceLocalAccountExternalPolicyLoaderTest() |
136 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { | 136 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { |
137 } | 137 } |
138 | 138 |
139 DeviceLocalAccountExternalPolicyLoaderTest:: | 139 DeviceLocalAccountExternalPolicyLoaderTest:: |
140 ~DeviceLocalAccountExternalPolicyLoaderTest() { | 140 ~DeviceLocalAccountExternalPolicyLoaderTest() { |
141 } | 141 } |
142 | 142 |
143 void DeviceLocalAccountExternalPolicyLoaderTest::SetUp() { | 143 void DeviceLocalAccountExternalPolicyLoaderTest::SetUp() { |
144 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 144 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
145 cache_dir_ = temp_dir_.path().Append(kCacheDir); | 145 cache_dir_ = temp_dir_.GetPath().Append(kCacheDir); |
146 ASSERT_TRUE(base::CreateDirectoryAndGetError(cache_dir_, NULL)); | 146 ASSERT_TRUE(base::CreateDirectoryAndGetError(cache_dir_, NULL)); |
147 request_context_getter_ = | 147 request_context_getter_ = |
148 new net::TestURLRequestContextGetter(base::ThreadTaskRunnerHandle::Get()); | 148 new net::TestURLRequestContextGetter(base::ThreadTaskRunnerHandle::Get()); |
149 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( | 149 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( |
150 request_context_getter_.get()); | 150 request_context_getter_.get()); |
151 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); | 151 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); |
152 | 152 |
153 loader_ = new DeviceLocalAccountExternalPolicyLoader(&store_, cache_dir_); | 153 loader_ = new DeviceLocalAccountExternalPolicyLoader(&store_, cache_dir_); |
154 provider_.reset(new extensions::ExternalProviderImpl( | 154 provider_.reset(new extensions::ExternalProviderImpl( |
155 &visitor_, | 155 &visitor_, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 // Verify that the downloader is attempting to download a CRX file. | 269 // Verify that the downloader is attempting to download a CRX file. |
270 fetcher = factory.GetFetcherByID( | 270 fetcher = factory.GetFetcherByID( |
271 extensions::ExtensionDownloader::kExtensionFetcherId); | 271 extensions::ExtensionDownloader::kExtensionFetcherId); |
272 ASSERT_TRUE(fetcher); | 272 ASSERT_TRUE(fetcher); |
273 ASSERT_TRUE(fetcher->delegate()); | 273 ASSERT_TRUE(fetcher->delegate()); |
274 | 274 |
275 // Create a temporary CRX file and return its path to the downloader. | 275 // Create a temporary CRX file and return its path to the downloader. |
276 EXPECT_TRUE(base::CopyFile( | 276 EXPECT_TRUE(base::CopyFile( |
277 test_dir_.Append(kExtensionCRXSourceDir).Append(kExtensionCRXFile), | 277 test_dir_.Append(kExtensionCRXSourceDir).Append(kExtensionCRXFile), |
278 temp_dir_.path().Append(kExtensionCRXFile))); | 278 temp_dir_.GetPath().Append(kExtensionCRXFile))); |
279 fetcher->set_response_code(200); | 279 fetcher->set_response_code(200); |
280 fetcher->SetResponseFilePath(temp_dir_.path().Append(kExtensionCRXFile)); | 280 fetcher->SetResponseFilePath(temp_dir_.GetPath().Append(kExtensionCRXFile)); |
281 fetcher->delegate()->OnURLFetchComplete(fetcher); | 281 fetcher->delegate()->OnURLFetchComplete(fetcher); |
282 | 282 |
283 // Spin the loop. Verify that the loader announces the presence of a new CRX | 283 // Spin the loop. Verify that the loader announces the presence of a new CRX |
284 // file, served from the cache directory. | 284 // file, served from the cache directory. |
285 const base::FilePath cached_crx_path = cache_dir_.Append(base::StringPrintf( | 285 const base::FilePath cached_crx_path = cache_dir_.Append(base::StringPrintf( |
286 "%s-%s.crx", kExtensionId, kExtensionCRXVersion)); | 286 "%s-%s.crx", kExtensionId, kExtensionCRXVersion)); |
287 base::RunLoop cache_run_loop; | 287 base::RunLoop cache_run_loop; |
288 EXPECT_CALL( | 288 EXPECT_CALL( |
289 visitor_, | 289 visitor_, |
290 OnExternalExtensionFileFound(AllOf( | 290 OnExternalExtensionFileFound(AllOf( |
(...skipping 21 matching lines...) Expand all Loading... |
312 loader_->StopCache(shutdown_run_loop.QuitClosure()); | 312 loader_->StopCache(shutdown_run_loop.QuitClosure()); |
313 VerifyAndResetVisitorCallExpectations(); | 313 VerifyAndResetVisitorCallExpectations(); |
314 | 314 |
315 // Spin the loop until the cache shutdown callback is invoked. Verify that at | 315 // Spin the loop until the cache shutdown callback is invoked. Verify that at |
316 // that point, no further file I/O tasks are pending. | 316 // that point, no further file I/O tasks are pending. |
317 shutdown_run_loop.Run(); | 317 shutdown_run_loop.Run(); |
318 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); | 318 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); |
319 } | 319 } |
320 | 320 |
321 } // namespace chromeos | 321 } // namespace chromeos |
OLD | NEW |