Index: chrome/common/zip_unittest.cc |
=================================================================== |
--- chrome/common/zip_unittest.cc (revision 35352) |
+++ chrome/common/zip_unittest.cc (working copy) |
@@ -41,23 +41,16 @@ |
} |
void TestUnzipFile(const FilePath::StringType& filename, |
- bool expect_hidden_files, bool need_success) { |
+ bool expect_hidden_files) { |
FilePath test_dir; |
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
test_dir = test_dir.AppendASCII("zip"); |
- TestUnzipFile(test_dir.Append(filename), expect_hidden_files, |
- need_success); |
+ TestUnzipFile(test_dir.Append(filename), expect_hidden_files); |
} |
- void TestUnzipFile(const FilePath& path, bool expect_hidden_files, |
- bool need_success) { |
+ void TestUnzipFile(const FilePath& path, bool expect_hidden_files) { |
ASSERT_TRUE(file_util::PathExists(path)) << "no file " << path.value(); |
- if (need_success) { |
- ASSERT_TRUE(Unzip(path, test_dir_)); |
- } else { |
- ASSERT_FALSE(Unzip(path, test_dir_)); |
- return; |
- } |
+ ASSERT_TRUE(Unzip(path, test_dir_)); |
file_util::FileEnumerator files(test_dir_, true, |
static_cast<file_util::FileEnumerator::FILE_TYPE>( |
@@ -95,15 +88,18 @@ |
}; |
TEST_F(ZipTest, Unzip) { |
- TestUnzipFile(FILE_PATH_LITERAL("test.zip"), true, true); |
+ TestUnzipFile(FILE_PATH_LITERAL("test.zip"), true); |
} |
TEST_F(ZipTest, UnzipUncompressed) { |
- TestUnzipFile(FILE_PATH_LITERAL("test_nocompress.zip"), true, true); |
+ TestUnzipFile(FILE_PATH_LITERAL("test_nocompress.zip"), true); |
} |
TEST_F(ZipTest, UnzipEvil) { |
- TestUnzipFile(FILE_PATH_LITERAL("evil.zip"), true, false); |
+ FilePath path; |
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
+ path = path.AppendASCII("zip").AppendASCII("evil.zip"); |
+ ASSERT_FALSE(Unzip(path, test_dir_)); |
FilePath evil_file = test_dir_; |
evil_file = evil_file.AppendASCII( |
"../levilevilevilevilevilevilevilevilevilevilevilevil"); |
@@ -111,15 +107,11 @@ |
} |
TEST_F(ZipTest, UnzipEvil2) { |
- ScopedTempDir dest_dir; |
- ASSERT_TRUE(dest_dir.CreateUniqueTempDir()); |
- |
- FilePath test_dir; |
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
- test_dir = test_dir.AppendASCII("zip"); |
- TestUnzipFile(FILE_PATH_LITERAL("evil_via_invalid_utf8.zip"), true, false); |
- |
- FilePath evil_file = dest_dir.path(); |
+ FilePath path; |
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
+ path = path.AppendASCII("zip").AppendASCII("evil_via_invalid_utf8.zip"); |
+ ASSERT_TRUE(Unzip(path, test_dir_)); |
+ FilePath evil_file = test_dir_; |
evil_file = evil_file.AppendASCII("../evil.txt"); |
ASSERT_FALSE(file_util::PathExists(evil_file)); |
} |
@@ -134,7 +126,7 @@ |
FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); |
EXPECT_TRUE(Zip(src_dir, zip_file, true)); |
- TestUnzipFile(zip_file, true, true); |
+ TestUnzipFile(zip_file, true); |
} |
TEST_F(ZipTest, ZipIgnoreHidden) { |
@@ -147,7 +139,7 @@ |
FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); |
EXPECT_TRUE(Zip(src_dir, zip_file, false)); |
- TestUnzipFile(zip_file, false, true); |
+ TestUnzipFile(zip_file, false); |
} |
} // namespace |