| Index: third_party/zlib/google/zip_unittest.cc
|
| diff --git a/third_party/zlib/google/zip_unittest.cc b/third_party/zlib/google/zip_unittest.cc
|
| index afa92f137c14283b1fc912a1cb7237a0eeb47fa1..72a5fa44636939f4a5e776c9a57a2e42b2332731 100644
|
| --- a/third_party/zlib/google/zip_unittest.cc
|
| +++ b/third_party/zlib/google/zip_unittest.cc
|
| @@ -12,6 +12,7 @@
|
| #include "base/files/scoped_temp_dir.h"
|
| #include "base/path_service.h"
|
| #include "base/strings/string_util.h"
|
| +#include "base/strings/stringprintf.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "testing/platform_test.h"
|
| #include "third_party/zlib/google/zip.h"
|
| @@ -301,5 +302,34 @@ TEST_F(ZipTest, ZipFiles) {
|
| }
|
| #endif // defined(OS_POSIX)
|
|
|
| +TEST_F(ZipTest, UnzipFilesWithIncorrectSize) {
|
| + base::FilePath test_data_folder;
|
| + ASSERT_TRUE(GetTestDataDirectory(&test_data_folder));
|
| +
|
| + // test_mismatch_size.zip contains files with names from 0.txt to 7.txt with
|
| + // sizes from 0 to 7 respectively, but the metadata in the zip file says the
|
| + // size is 3 bytes. The reader code needs to be clever enough to get all the
|
| + // data out.
|
| + base::FilePath test_zip_file =
|
| + test_data_folder.AppendASCII("test_mismatch_size.zip");
|
| +
|
| + base::ScopedTempDir scoped_temp_dir;
|
| + ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir());
|
| + const base::FilePath& temp_dir = scoped_temp_dir.path();
|
| +
|
| + ASSERT_TRUE(zip::Unzip(test_zip_file, temp_dir));
|
| +
|
| + EXPECT_TRUE(base::DirectoryExists(temp_dir.AppendASCII("d")));
|
| +
|
| + for (int k = 0; k < 8; k++) {
|
| + SCOPED_TRACE(base::StringPrintf("<loop:%d>", static_cast<int>(k)));
|
| + base::FilePath file_path = temp_dir.AppendASCII(
|
| + base::StringPrintf(FILE_PATH_LITERAL("%d.txt"), static_cast<int>(k)));
|
| + int64 file_size = -1;
|
| + EXPECT_TRUE(base::GetFileSize(file_path, &file_size));
|
| + EXPECT_EQ(file_size, static_cast<int64>(k));
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
|
|