| 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 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 46 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
| 47 test_dir = test_dir.AppendASCII("zip"); | 47 test_dir = test_dir.AppendASCII("zip"); |
| 48 TestUnzipFile(test_dir.Append(filename), expect_hidden_files); | 48 TestUnzipFile(test_dir.Append(filename), expect_hidden_files); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void TestUnzipFile(const FilePath& path, bool expect_hidden_files) { | 51 void TestUnzipFile(const FilePath& path, bool expect_hidden_files) { |
| 52 ASSERT_TRUE(file_util::PathExists(path)) << "no file " << path.value(); | 52 ASSERT_TRUE(file_util::PathExists(path)) << "no file " << path.value(); |
| 53 ASSERT_TRUE(zip::Unzip(path, test_dir_)); | 53 ASSERT_TRUE(zip::Unzip(path, test_dir_)); |
| 54 | 54 |
| 55 file_util::FileEnumerator files(test_dir_, true, | 55 file_util::FileEnumerator files(test_dir_, true, |
| 56 static_cast<file_util::FileEnumerator::FileType>( | 56 (file_util::FileEnumerator::FILES | |
| 57 file_util::FileEnumerator::FILES | | 57 file_util::FileEnumerator::DIRECTORIES)); |
| 58 file_util::FileEnumerator::DIRECTORIES)); | |
| 59 FilePath next_path = files.Next(); | 58 FilePath next_path = files.Next(); |
| 60 size_t count = 0; | 59 size_t count = 0; |
| 61 while (!next_path.value().empty()) { | 60 while (!next_path.value().empty()) { |
| 62 if (next_path.value().find(FILE_PATH_LITERAL(".svn")) == | 61 if (next_path.value().find(FILE_PATH_LITERAL(".svn")) == |
| 63 FilePath::StringType::npos) { | 62 FilePath::StringType::npos) { |
| 64 EXPECT_EQ(zip_contents_.count(next_path), 1U) << | 63 EXPECT_EQ(zip_contents_.count(next_path), 1U) << |
| 65 "Couldn't find " << next_path.value(); | 64 "Couldn't find " << next_path.value(); |
| 66 count++; | 65 count++; |
| 67 } | 66 } |
| 68 next_path = files.Next(); | 67 next_path = files.Next(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 144 |
| 146 ScopedTempDir temp_dir; | 145 ScopedTempDir temp_dir; |
| 147 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 146 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 148 FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); | 147 FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); |
| 149 | 148 |
| 150 EXPECT_TRUE(zip::Zip(src_dir, zip_file, false)); | 149 EXPECT_TRUE(zip::Zip(src_dir, zip_file, false)); |
| 151 TestUnzipFile(zip_file, false); | 150 TestUnzipFile(zip_file, false); |
| 152 } | 151 } |
| 153 | 152 |
| 154 } // namespace | 153 } // namespace |
| OLD | NEW |