| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> | 
| 6 #include <vector> | 6 #include <vector> | 
| 7 | 7 | 
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" | 
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" | 
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" | 
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 167   src_dir = src_dir.AppendASCII("test"); | 167   src_dir = src_dir.AppendASCII("test"); | 
| 168 | 168 | 
| 169   base::ScopedTempDir temp_dir; | 169   base::ScopedTempDir temp_dir; | 
| 170   ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 170   ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 
| 171   base::FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); | 171   base::FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); | 
| 172 | 172 | 
| 173   EXPECT_TRUE(zip::Zip(src_dir, zip_file, false)); | 173   EXPECT_TRUE(zip::Zip(src_dir, zip_file, false)); | 
| 174   TestUnzipFile(zip_file, false); | 174   TestUnzipFile(zip_file, false); | 
| 175 } | 175 } | 
| 176 | 176 | 
|  | 177 TEST_F(ZipTest, ZipNonASCIIDir) { | 
|  | 178   base::FilePath src_dir; | 
|  | 179   ASSERT_TRUE(GetTestDataDirectory(&src_dir)); | 
|  | 180   src_dir = src_dir.AppendASCII("test"); | 
|  | 181 | 
|  | 182   base::ScopedTempDir temp_dir; | 
|  | 183   ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 
|  | 184   // Append 'Тест' (in cyrillic). | 
|  | 185   base::FilePath src_dir_russian = | 
|  | 186       temp_dir.path().Append(base::FilePath::FromUTF8Unsafe( | 
|  | 187           "\xD0\xA2\xD0\xB5\xD1\x81\xD1\x82")); | 
|  | 188   base::CopyDirectory(src_dir, src_dir_russian, true); | 
|  | 189   base::FilePath zip_file = temp_dir.path().AppendASCII("out_russian.zip"); | 
|  | 190 | 
|  | 191   EXPECT_TRUE(zip::Zip(src_dir_russian, zip_file, true)); | 
|  | 192   TestUnzipFile(zip_file, true); | 
|  | 193 } | 
|  | 194 | 
| 177 #if defined(OS_POSIX) | 195 #if defined(OS_POSIX) | 
| 178 TEST_F(ZipTest, ZipFiles) { | 196 TEST_F(ZipTest, ZipFiles) { | 
| 179   base::FilePath src_dir; | 197   base::FilePath src_dir; | 
| 180   ASSERT_TRUE(GetTestDataDirectory(&src_dir)); | 198   ASSERT_TRUE(GetTestDataDirectory(&src_dir)); | 
| 181   src_dir = src_dir.AppendASCII("test"); | 199   src_dir = src_dir.AppendASCII("test"); | 
| 182 | 200 | 
| 183   base::ScopedTempDir temp_dir; | 201   base::ScopedTempDir temp_dir; | 
| 184   ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 202   ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 
| 185   base::FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); | 203   base::FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); | 
| 186 | 204 | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 198     EXPECT_TRUE(reader.LocateAndOpenEntry(zip_file_list_[i])); | 216     EXPECT_TRUE(reader.LocateAndOpenEntry(zip_file_list_[i])); | 
| 199     // Check the path in the entry just in case. | 217     // Check the path in the entry just in case. | 
| 200     const zip::ZipReader::EntryInfo* entry_info = reader.current_entry_info(); | 218     const zip::ZipReader::EntryInfo* entry_info = reader.current_entry_info(); | 
| 201     EXPECT_EQ(entry_info->file_path(), zip_file_list_[i]); | 219     EXPECT_EQ(entry_info->file_path(), zip_file_list_[i]); | 
| 202   } | 220   } | 
| 203 } | 221 } | 
| 204 #endif  // defined(OS_POSIX) | 222 #endif  // defined(OS_POSIX) | 
| 205 | 223 | 
| 206 }  // namespace | 224 }  // namespace | 
| 207 | 225 | 
| OLD | NEW | 
|---|