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_path.h" | 10 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
15 #include "third_party/zlib/google/zip.h" | 16 #include "third_party/zlib/google/zip.h" |
16 #include "third_party/zlib/google/zip_reader.h" | 17 #include "third_party/zlib/google/zip_reader.h" |
17 | 18 |
18 namespace { | 19 namespace { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 bool expect_hidden_files) { | 67 bool expect_hidden_files) { |
67 base::FilePath test_dir; | 68 base::FilePath test_dir; |
68 ASSERT_TRUE(GetTestDataDirectory(&test_dir)); | 69 ASSERT_TRUE(GetTestDataDirectory(&test_dir)); |
69 TestUnzipFile(test_dir.Append(filename), expect_hidden_files); | 70 TestUnzipFile(test_dir.Append(filename), expect_hidden_files); |
70 } | 71 } |
71 | 72 |
72 void TestUnzipFile(const base::FilePath& path, bool expect_hidden_files) { | 73 void TestUnzipFile(const base::FilePath& path, bool expect_hidden_files) { |
73 ASSERT_TRUE(file_util::PathExists(path)) << "no file " << path.value(); | 74 ASSERT_TRUE(file_util::PathExists(path)) << "no file " << path.value(); |
74 ASSERT_TRUE(zip::Unzip(path, test_dir_)); | 75 ASSERT_TRUE(zip::Unzip(path, test_dir_)); |
75 | 76 |
76 file_util::FileEnumerator files(test_dir_, true, | 77 base::FileEnumerator files(test_dir_, true, |
77 file_util::FileEnumerator::FILES | | 78 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); |
78 file_util::FileEnumerator::DIRECTORIES); | |
79 base::FilePath next_path = files.Next(); | 79 base::FilePath next_path = files.Next(); |
80 size_t count = 0; | 80 size_t count = 0; |
81 while (!next_path.value().empty()) { | 81 while (!next_path.value().empty()) { |
82 if (next_path.value().find(FILE_PATH_LITERAL(".svn")) == | 82 if (next_path.value().find(FILE_PATH_LITERAL(".svn")) == |
83 base::FilePath::StringType::npos) { | 83 base::FilePath::StringType::npos) { |
84 EXPECT_EQ(zip_contents_.count(next_path), 1U) << | 84 EXPECT_EQ(zip_contents_.count(next_path), 1U) << |
85 "Couldn't find " << next_path.value(); | 85 "Couldn't find " << next_path.value(); |
86 count++; | 86 count++; |
87 } | 87 } |
88 next_path = files.Next(); | 88 next_path = files.Next(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 EXPECT_TRUE(reader.LocateAndOpenEntry(zip_file_list_[i])); | 198 EXPECT_TRUE(reader.LocateAndOpenEntry(zip_file_list_[i])); |
199 // Check the path in the entry just in case. | 199 // Check the path in the entry just in case. |
200 const zip::ZipReader::EntryInfo* entry_info = reader.current_entry_info(); | 200 const zip::ZipReader::EntryInfo* entry_info = reader.current_entry_info(); |
201 EXPECT_EQ(entry_info->file_path(), zip_file_list_[i]); | 201 EXPECT_EQ(entry_info->file_path(), zip_file_list_[i]); |
202 } | 202 } |
203 } | 203 } |
204 #endif // defined(OS_POSIX) | 204 #endif // defined(OS_POSIX) |
205 | 205 |
206 } // namespace | 206 } // namespace |
207 | 207 |
OLD | NEW |