| 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(Unzip(path, test_dir_)); | 53 ASSERT_TRUE(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::FILE_TYPE>( | 56 static_cast<file_util::FileEnumerator::FileType>( |
| 57 file_util::FileEnumerator::FILES | | 57 file_util::FileEnumerator::FILES | |
| 58 file_util::FileEnumerator::DIRECTORIES)); | 58 file_util::FileEnumerator::DIRECTORIES)); |
| 59 FilePath next_path = files.Next(); | 59 FilePath next_path = files.Next(); |
| 60 size_t count = 0; | 60 size_t count = 0; |
| 61 while (!next_path.value().empty()) { | 61 while (!next_path.value().empty()) { |
| 62 if (next_path.value().find(FILE_PATH_LITERAL(".svn")) == | 62 if (next_path.value().find(FILE_PATH_LITERAL(".svn")) == |
| 63 FilePath::StringType::npos) { | 63 FilePath::StringType::npos) { |
| 64 EXPECT_EQ(zip_contents_.count(next_path), 1U) << | 64 EXPECT_EQ(zip_contents_.count(next_path), 1U) << |
| 65 "Couldn't find " << next_path.value(); | 65 "Couldn't find " << next_path.value(); |
| 66 count++; | 66 count++; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 ScopedTempDir temp_dir; | 137 ScopedTempDir temp_dir; |
| 138 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 138 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 139 FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); | 139 FilePath zip_file = temp_dir.path().AppendASCII("out.zip"); |
| 140 | 140 |
| 141 EXPECT_TRUE(Zip(src_dir, zip_file, false)); | 141 EXPECT_TRUE(Zip(src_dir, zip_file, false)); |
| 142 TestUnzipFile(zip_file, false); | 142 TestUnzipFile(zip_file, false); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace | 145 } // namespace |
| OLD | NEW |