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 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "base/version.h" | 18 #include "base/version.h" |
19 #include "chrome/browser/chrome_notification_types.h" | |
20 #include "chrome/browser/extensions/external_provider_impl.h" | 19 #include "chrome/browser/extensions/external_provider_impl.h" |
21 #include "chrome/browser/extensions/updater/extension_downloader.h" | 20 #include "chrome/browser/extensions/updater/extension_downloader.h" |
22 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
24 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
25 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 24 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
26 #include "components/policy/core/common/policy_map.h" | 25 #include "components/policy/core/common/policy_map.h" |
27 #include "components/policy/core/common/policy_types.h" | 26 #include "components/policy/core/common/policy_types.h" |
28 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
30 #include "content/public/test/test_browser_thread_bundle.h" | 29 #include "content/public/test/test_browser_thread_bundle.h" |
31 #include "content/public/test/test_utils.h" | 30 #include "content/public/test/test_utils.h" |
32 #include "extensions/browser/external_provider_interface.h" | 31 #include "extensions/browser/external_provider_interface.h" |
| 32 #include "extensions/browser/notification_types.h" |
33 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
34 #include "extensions/common/manifest.h" | 34 #include "extensions/common/manifest.h" |
35 #include "net/url_request/test_url_fetcher_factory.h" | 35 #include "net/url_request/test_url_fetcher_factory.h" |
36 #include "net/url_request/url_fetcher_delegate.h" | 36 #include "net/url_request/url_fetcher_delegate.h" |
37 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
38 #include "net/url_request/url_request_test_util.h" | 38 #include "net/url_request/url_request_test_util.h" |
39 #include "policy/policy_constants.h" | 39 #include "policy/policy_constants.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
42 #include "url/gurl.h" | 42 #include "url/gurl.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // Return a manifest to the downloader. | 245 // Return a manifest to the downloader. |
246 std::string manifest; | 246 std::string manifest; |
247 EXPECT_TRUE(base::ReadFileToString(test_dir_.Append(kExtensionUpdateManifest), | 247 EXPECT_TRUE(base::ReadFileToString(test_dir_.Append(kExtensionUpdateManifest), |
248 &manifest)); | 248 &manifest)); |
249 fetcher->set_response_code(200); | 249 fetcher->set_response_code(200); |
250 fetcher->SetResponseString(manifest); | 250 fetcher->SetResponseString(manifest); |
251 fetcher->delegate()->OnURLFetchComplete(fetcher); | 251 fetcher->delegate()->OnURLFetchComplete(fetcher); |
252 | 252 |
253 // Wait for the manifest to be parsed. | 253 // Wait for the manifest to be parsed. |
254 content::WindowedNotificationObserver( | 254 content::WindowedNotificationObserver( |
255 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 255 extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
256 content::NotificationService::AllSources()).Wait(); | 256 content::NotificationService::AllSources()).Wait(); |
257 | 257 |
258 // Verify that the downloader is attempting to download a CRX file. | 258 // Verify that the downloader is attempting to download a CRX file. |
259 fetcher = factory.GetFetcherByID( | 259 fetcher = factory.GetFetcherByID( |
260 extensions::ExtensionDownloader::kExtensionFetcherId); | 260 extensions::ExtensionDownloader::kExtensionFetcherId); |
261 ASSERT_TRUE(fetcher); | 261 ASSERT_TRUE(fetcher); |
262 ASSERT_TRUE(fetcher->delegate()); | 262 ASSERT_TRUE(fetcher->delegate()); |
263 | 263 |
264 // Create a temporary CRX file and return its path to the downloader. | 264 // Create a temporary CRX file and return its path to the downloader. |
265 EXPECT_TRUE(base::CopyFile( | 265 EXPECT_TRUE(base::CopyFile( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 loader_->StopCache(shutdown_run_loop.QuitClosure()); | 300 loader_->StopCache(shutdown_run_loop.QuitClosure()); |
301 VerifyAndResetVisitorCallExpectations(); | 301 VerifyAndResetVisitorCallExpectations(); |
302 | 302 |
303 // Spin the loop until the cache shutdown callback is invoked. Verify that at | 303 // Spin the loop until the cache shutdown callback is invoked. Verify that at |
304 // that point, no further file I/O tasks are pending. | 304 // that point, no further file I/O tasks are pending. |
305 shutdown_run_loop.Run(); | 305 shutdown_run_loop.Run(); |
306 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); | 306 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); |
307 } | 307 } |
308 | 308 |
309 } // namespace chromeos | 309 } // namespace chromeos |
OLD | NEW |