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_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "components/zip/zip.h" | 13 #include "base/zip/zip.h" |
14 #include "components/zip/zip_reader.h" | 14 #include "base/zip/zip_reader.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Make the test a PlatformTest to setup autorelease pools properly on Mac. | 20 // Make the test a PlatformTest to setup autorelease pools properly on Mac. |
21 class ZipTest : public PlatformTest { | 21 class ZipTest : public PlatformTest { |
22 protected: | 22 protected: |
23 virtual void SetUp() { | 23 virtual void SetUp() { |
24 PlatformTest::SetUp(); | 24 PlatformTest::SetUp(); |
(...skipping 22 matching lines...) Expand all Loading... |
47 | 47 |
48 virtual void TearDown() { | 48 virtual void TearDown() { |
49 PlatformTest::TearDown(); | 49 PlatformTest::TearDown(); |
50 } | 50 } |
51 | 51 |
52 bool GetTestDataDirectory(base::FilePath* path) { | 52 bool GetTestDataDirectory(base::FilePath* path) { |
53 bool success = PathService::Get(base::DIR_SOURCE_ROOT, path); | 53 bool success = PathService::Get(base::DIR_SOURCE_ROOT, path); |
54 EXPECT_TRUE(success); | 54 EXPECT_TRUE(success); |
55 if (!success) | 55 if (!success) |
56 return false; | 56 return false; |
57 *path = path->AppendASCII("components"); | 57 *path = path->AppendASCII("base"); |
58 *path = path->AppendASCII("test"); | 58 *path = path->AppendASCII("test"); |
59 *path = path->AppendASCII("data"); | 59 *path = path->AppendASCII("data"); |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 void TestUnzipFile(const base::FilePath::StringType& filename, | 63 void TestUnzipFile(const base::FilePath::StringType& filename, |
64 bool expect_hidden_files) { | 64 bool expect_hidden_files) { |
65 base::FilePath test_dir; | 65 base::FilePath test_dir; |
66 ASSERT_TRUE(GetTestDataDirectory(&test_dir)); | 66 ASSERT_TRUE(GetTestDataDirectory(&test_dir)); |
67 test_dir = test_dir.AppendASCII("zip"); | 67 test_dir = test_dir.AppendASCII("zip"); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 EXPECT_TRUE(reader.LocateAndOpenEntry(zip_file_list_[i])); | 197 EXPECT_TRUE(reader.LocateAndOpenEntry(zip_file_list_[i])); |
198 // Check the path in the entry just in case. | 198 // Check the path in the entry just in case. |
199 const zip::ZipReader::EntryInfo* entry_info = reader.current_entry_info(); | 199 const zip::ZipReader::EntryInfo* entry_info = reader.current_entry_info(); |
200 EXPECT_EQ(entry_info->file_path(), zip_file_list_[i]); | 200 EXPECT_EQ(entry_info->file_path(), zip_file_list_[i]); |
201 } | 201 } |
202 } | 202 } |
203 #endif // defined(OS_POSIX) | 203 #endif // defined(OS_POSIX) |
204 | 204 |
205 } // namespace | 205 } // namespace |
206 | 206 |
OLD | NEW |