diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 02:30:43 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 02:30:43 +0000 |
commit | ed45566a74d2a8dae55ab4e2589ce5f0d78e49b2 (patch) | |
tree | 7c24abaa9d7e76f2482e9ef75be0c25bc2319a9a /chrome/common/zip_unittest.cc | |
parent | a4c34a20c8b0a2fae699edbacf1e82655dab147f (diff) | |
download | chromium_src-ed45566a74d2a8dae55ab4e2589ce5f0d78e49b2.zip chromium_src-ed45566a74d2a8dae55ab4e2589ce5f0d78e49b2.tar.gz chromium_src-ed45566a74d2a8dae55ab4e2589ce5f0d78e49b2.tar.bz2 |
Filter out hidden files, both when loading extensions and when
packaging them.
We also special case the common OS X zip dropping "__MACOSX" when
loading extensions.
BUG=23004
Review URL: http://codereview.chromium.org/340018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/zip_unittest.cc')
-rw-r--r-- | chrome/common/zip_unittest.cc | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/chrome/common/zip_unittest.cc b/chrome/common/zip_unittest.cc index dfa07249..ae43a09 100644 --- a/chrome/common/zip_unittest.cc +++ b/chrome/common/zip_unittest.cc @@ -33,20 +33,24 @@ class ZipTest : public PlatformTest { zip_contents_.insert(zip_path); zip_contents_.insert(zip_path.AppendASCII("baz.txt")); zip_contents_.insert(zip_path.AppendASCII("quux.txt")); + zip_contents_.insert(zip_path.AppendASCII(".hidden")); } virtual void TearDown() { PlatformTest::TearDown(); } - void TestUnzipFile(const FilePath::StringType& filename, bool need_success) { + void TestUnzipFile(const FilePath::StringType& filename, + bool expect_hidden_files, bool need_success) { FilePath test_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); test_dir = test_dir.AppendASCII("zip"); - TestUnzipFile(test_dir.Append(filename), need_success); + TestUnzipFile(test_dir.Append(filename), expect_hidden_files, + need_success); } - void TestUnzipFile(const FilePath& path, bool need_success) { + void TestUnzipFile(const FilePath& path, bool expect_hidden_files, + bool need_success) { ASSERT_TRUE(file_util::PathExists(path)) << "no file " << path.value(); if (need_success) { ASSERT_TRUE(Unzip(path, test_dir_)); @@ -70,7 +74,15 @@ class ZipTest : public PlatformTest { } next_path = files.Next(); } - EXPECT_EQ(count, zip_contents_.size()); + + size_t expected_count = 0; + for (std::set<FilePath>::iterator iter = zip_contents_.begin(); + iter != zip_contents_.end(); ++iter) { + if (expect_hidden_files || iter->BaseName().ToWStringHack()[0] != L'.') + ++expected_count; + } + + EXPECT_EQ(expected_count, count); } // the path to temporary directory used to contain the test operations @@ -83,15 +95,15 @@ class ZipTest : public PlatformTest { }; TEST_F(ZipTest, Unzip) { - TestUnzipFile(FILE_PATH_LITERAL("test.zip"), true); + TestUnzipFile(FILE_PATH_LITERAL("test.zip"), true, true); } TEST_F(ZipTest, UnzipUncompressed) { - TestUnzipFile(FILE_PATH_LITERAL("test_nocompress.zip"), true); + TestUnzipFile(FILE_PATH_LITERAL("test_nocompress.zip"), true, true); } TEST_F(ZipTest, UnzipEvil) { - TestUnzipFile(FILE_PATH_LITERAL("evil.zip"), false); + TestUnzipFile(FILE_PATH_LITERAL("evil.zip"), true, false); FilePath evil_file = test_dir_; evil_file = evil_file.AppendASCII( "../levilevilevilevilevilevilevilevilevilevilevilevil"); @@ -107,9 +119,21 @@ TEST_F(ZipTest, Zip) { ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); - EXPECT_TRUE(Zip(src_dir, zip_file)); + EXPECT_TRUE(Zip(src_dir, zip_file, true)); + TestUnzipFile(zip_file, true, true); +} + +TEST_F(ZipTest, ZipIgnoreHidden) { + FilePath src_dir; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &src_dir)); + src_dir = src_dir.AppendASCII("zip").AppendASCII("test"); + + ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); - TestUnzipFile(zip_file, true); + EXPECT_TRUE(Zip(src_dir, zip_file, false)); + TestUnzipFile(zip_file, false, true); } } // namespace |