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/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 extensions::ExtensionList loaded_; | 969 extensions::ExtensionList loaded_; |
970 std::string unloaded_id_; | 970 std::string unloaded_id_; |
971 const Extension* installed_; | 971 const Extension* installed_; |
972 | 972 |
973 private: | 973 private: |
974 content::NotificationRegistrar registrar_; | 974 content::NotificationRegistrar registrar_; |
975 }; | 975 }; |
976 | 976 |
977 // Receives notifications from a PackExtensionJob, indicating either that | 977 // Receives notifications from a PackExtensionJob, indicating either that |
978 // packing succeeded or that there was some error. | 978 // packing succeeded or that there was some error. |
979 class PackExtensionTestClient : public PackExtensionJob::Client { | 979 class PackExtensionTestClient : public extensions::PackExtensionJob::Client { |
980 public: | 980 public: |
981 PackExtensionTestClient(const FilePath& expected_crx_path, | 981 PackExtensionTestClient(const FilePath& expected_crx_path, |
982 const FilePath& expected_private_key_path); | 982 const FilePath& expected_private_key_path); |
983 virtual void OnPackSuccess(const FilePath& crx_path, | 983 virtual void OnPackSuccess(const FilePath& crx_path, |
984 const FilePath& private_key_path); | 984 const FilePath& private_key_path); |
985 virtual void OnPackFailure(const std::string& error_message, | 985 virtual void OnPackFailure(const std::string& error_message, |
986 ExtensionCreator::ErrorType type); | 986 ExtensionCreator::ErrorType type); |
987 | 987 |
988 private: | 988 private: |
989 const FilePath expected_crx_path_; | 989 const FilePath expected_crx_path_; |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 | 1740 |
1741 // Copy the extension into the output directory, as PackExtensionJob doesn't | 1741 // Copy the extension into the output directory, as PackExtensionJob doesn't |
1742 // let us choose where to output the packed extension. | 1742 // let us choose where to output the packed extension. |
1743 ASSERT_TRUE(file_util::CopyDirectory(input_directory, output_dir, true)); | 1743 ASSERT_TRUE(file_util::CopyDirectory(input_directory, output_dir, true)); |
1744 | 1744 |
1745 FilePath expected_crx_path = temp_dir.path().Append(expected_crx_names[i]); | 1745 FilePath expected_crx_path = temp_dir.path().Append(expected_crx_names[i]); |
1746 FilePath expected_private_key_path = | 1746 FilePath expected_private_key_path = |
1747 temp_dir.path().Append(expected_private_key_names[i]); | 1747 temp_dir.path().Append(expected_private_key_names[i]); |
1748 PackExtensionTestClient pack_client(expected_crx_path, | 1748 PackExtensionTestClient pack_client(expected_crx_path, |
1749 expected_private_key_path); | 1749 expected_private_key_path); |
1750 scoped_refptr<PackExtensionJob> packer( | 1750 scoped_refptr<extensions::PackExtensionJob> packer( |
1751 new PackExtensionJob(&pack_client, output_dir, FilePath(), | 1751 new extensions::PackExtensionJob(&pack_client, output_dir, FilePath(), |
1752 ExtensionCreator::kOverwriteCRX)); | 1752 ExtensionCreator::kOverwriteCRX)); |
1753 packer->Start(); | 1753 packer->Start(); |
1754 | 1754 |
1755 // The packer will post a notification task to the current thread's message | 1755 // The packer will post a notification task to the current thread's message |
1756 // loop when it is finished. We manually run the loop here so that we | 1756 // loop when it is finished. We manually run the loop here so that we |
1757 // block and catch the notification; otherwise, the process would exit. | 1757 // block and catch the notification; otherwise, the process would exit. |
1758 // This call to |Run()| is matched by a call to |Quit()| in the | 1758 // This call to |Run()| is matched by a call to |Quit()| in the |
1759 // |PackExtensionTestClient|'s notification handling code. | 1759 // |PackExtensionTestClient|'s notification handling code. |
1760 MessageLoop::current()->Run(); | 1760 MessageLoop::current()->Run(); |
1761 | 1761 |
1762 if (HasFatalFailure()) | 1762 if (HasFatalFailure()) |
(...skipping 3483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5246 // This should NOT trigger an alert. | 5246 // This should NOT trigger an alert. |
5247 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", | 5247 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", |
5248 data_dir_.AppendASCII("hosted_app.crx")); | 5248 data_dir_.AppendASCII("hosted_app.crx")); |
5249 | 5249 |
5250 service_->CheckForExternalUpdates(); | 5250 service_->CheckForExternalUpdates(); |
5251 loop_.RunAllPending(); | 5251 loop_.RunAllPending(); |
5252 | 5252 |
5253 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); | 5253 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); |
5254 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); | 5254 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); |
5255 } | 5255 } |
OLD | NEW |