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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 | 982 |
983 protected: | 983 protected: |
984 ExtensionList loaded_; | 984 ExtensionList loaded_; |
985 std::string unloaded_id_; | 985 std::string unloaded_id_; |
986 const Extension* installed_; | 986 const Extension* installed_; |
987 | 987 |
988 private: | 988 private: |
989 content::NotificationRegistrar registrar_; | 989 content::NotificationRegistrar registrar_; |
990 }; | 990 }; |
991 | 991 |
992 FilePath NormalizeSeparators(const FilePath& path) { | |
993 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | |
994 return path.NormalizeWindowsPathSeparators(); | |
995 #else | |
996 return path; | |
997 #endif // FILE_PATH_USES_WIN_SEPARATORS | |
998 } | |
999 | |
1000 // Receives notifications from a PackExtensionJob, indicating either that | 992 // Receives notifications from a PackExtensionJob, indicating either that |
1001 // packing succeeded or that there was some error. | 993 // packing succeeded or that there was some error. |
1002 class PackExtensionTestClient : public PackExtensionJob::Client { | 994 class PackExtensionTestClient : public PackExtensionJob::Client { |
1003 public: | 995 public: |
1004 PackExtensionTestClient(const FilePath& expected_crx_path, | 996 PackExtensionTestClient(const FilePath& expected_crx_path, |
1005 const FilePath& expected_private_key_path); | 997 const FilePath& expected_private_key_path); |
1006 virtual void OnPackSuccess(const FilePath& crx_path, | 998 virtual void OnPackSuccess(const FilePath& crx_path, |
1007 const FilePath& private_key_path); | 999 const FilePath& private_key_path); |
1008 virtual void OnPackFailure(const std::string& error_message, | 1000 virtual void OnPackFailure(const std::string& error_message, |
1009 ExtensionCreator::ErrorType type); | 1001 ExtensionCreator::ErrorType type); |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 .AppendASCII("Extensions") | 1746 .AppendASCII("Extensions") |
1755 .AppendASCII(good0) | 1747 .AppendASCII(good0) |
1756 .AppendASCII("1.0.0.0"); | 1748 .AppendASCII("1.0.0.0"); |
1757 | 1749 |
1758 ScopedTempDir temp_dir; | 1750 ScopedTempDir temp_dir; |
1759 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1751 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1760 | 1752 |
1761 // Extension names containing punctuation, and the expected names for the | 1753 // Extension names containing punctuation, and the expected names for the |
1762 // packed extensions. | 1754 // packed extensions. |
1763 const FilePath punctuated_names[] = { | 1755 const FilePath punctuated_names[] = { |
1764 FilePath(FilePath::StringType( | 1756 FilePath(FILE_PATH_LITERAL("this.extensions.name.has.periods")), |
1765 FILE_PATH_LITERAL("this.extensions.name.has.periods"))), | 1757 FilePath(FILE_PATH_LITERAL(".thisextensionsnamestartswithaperiod")), |
1766 FilePath(FilePath::StringType( | 1758 FilePath(FILE_PATH_LITERAL("thisextensionhasaslashinitsname/")). |
1767 FILE_PATH_LITERAL(".thisextensionsnamestartswithaperiod"))), | 1759 NormalizePathSeparators(), |
1768 NormalizeSeparators(FilePath(FilePath::StringType( | |
1769 FILE_PATH_LITERAL("thisextensionhasaslashinitsname/")))), | |
1770 }; | 1760 }; |
1771 const FilePath expected_crx_names[] = { | 1761 const FilePath expected_crx_names[] = { |
1772 FilePath(FilePath::StringType( | 1762 FilePath(FILE_PATH_LITERAL("this.extensions.name.has.periods.crx")), |
1773 FILE_PATH_LITERAL("this.extensions.name.has.periods.crx"))), | 1763 FilePath(FILE_PATH_LITERAL(".thisextensionsnamestartswithaperiod.crx")), |
1774 FilePath(FilePath::StringType( | 1764 FilePath(FILE_PATH_LITERAL("thisextensionhasaslashinitsname.crx")), |
1775 FILE_PATH_LITERAL(".thisextensionsnamestartswithaperiod.crx"))), | |
1776 FilePath(FilePath::StringType( | |
1777 FILE_PATH_LITERAL("thisextensionhasaslashinitsname.crx"))), | |
1778 }; | 1765 }; |
1779 const FilePath expected_private_key_names[] = { | 1766 const FilePath expected_private_key_names[] = { |
1780 FilePath(FilePath::StringType( | 1767 FilePath(FILE_PATH_LITERAL("this.extensions.name.has.periods.pem")), |
1781 FILE_PATH_LITERAL("this.extensions.name.has.periods.pem"))), | 1768 FilePath(FILE_PATH_LITERAL(".thisextensionsnamestartswithaperiod.pem")), |
1782 FilePath(FilePath::StringType( | 1769 FilePath(FILE_PATH_LITERAL("thisextensionhasaslashinitsname.pem")), |
1783 FILE_PATH_LITERAL(".thisextensionsnamestartswithaperiod.pem"))), | |
1784 FilePath(FilePath::StringType( | |
1785 FILE_PATH_LITERAL("thisextensionhasaslashinitsname.pem"))), | |
1786 }; | 1770 }; |
1787 | 1771 |
1788 for (size_t i = 0; i < arraysize(punctuated_names); ++i) { | 1772 for (size_t i = 0; i < arraysize(punctuated_names); ++i) { |
1789 SCOPED_TRACE(punctuated_names[i].value().c_str()); | 1773 SCOPED_TRACE(punctuated_names[i].value().c_str()); |
1790 FilePath output_dir = temp_dir.path().Append(punctuated_names[i]); | 1774 FilePath output_dir = temp_dir.path().Append(punctuated_names[i]); |
1791 | 1775 |
1792 // Copy the extension into the output directory, as PackExtensionJob doesn't | 1776 // Copy the extension into the output directory, as PackExtensionJob doesn't |
1793 // let us choose where to output the packed extension. | 1777 // let us choose where to output the packed extension. |
1794 ASSERT_TRUE(file_util::CopyDirectory(input_directory, output_dir, true)); | 1778 ASSERT_TRUE(file_util::CopyDirectory(input_directory, output_dir, true)); |
1795 | 1779 |
(...skipping 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4788 ASSERT_FALSE(AddPendingSyncInstall()); | 4772 ASSERT_FALSE(AddPendingSyncInstall()); |
4789 | 4773 |
4790 // Wait for the external source to install. | 4774 // Wait for the external source to install. |
4791 WaitForCrxInstall(crx_path_, INSTALL_NEW); | 4775 WaitForCrxInstall(crx_path_, INSTALL_NEW); |
4792 ASSERT_TRUE(IsCrxInstalled()); | 4776 ASSERT_TRUE(IsCrxInstalled()); |
4793 | 4777 |
4794 // Now that the extension is installed, sync request should fail | 4778 // Now that the extension is installed, sync request should fail |
4795 // because the extension is already installed. | 4779 // because the extension is already installed. |
4796 ASSERT_FALSE(AddPendingSyncInstall()); | 4780 ASSERT_FALSE(AddPendingSyncInstall()); |
4797 } | 4781 } |
OLD | NEW |