| 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 "components/zip/zip_reader.h" | 5 #include "base/zip/zip_reader.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/md5.h" | 13 #include "base/md5.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "components/zip/zip_internal.h" | 18 #include "base/zip/zip_internal.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Wrap PlatformFiles in a class so that we don't leak them in tests. | 24 // Wrap PlatformFiles in a class so that we don't leak them in tests. |
| 25 class PlatformFileWrapper { | 25 class PlatformFileWrapper { |
| 26 public: | 26 public: |
| 27 typedef enum { | 27 typedef enum { |
| 28 READ_ONLY, | 28 READ_ONLY, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 virtual void TearDown() { | 100 virtual void TearDown() { |
| 101 PlatformTest::TearDown(); | 101 PlatformTest::TearDown(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool GetTestDataDirectory(base::FilePath* path) { | 104 bool GetTestDataDirectory(base::FilePath* path) { |
| 105 bool success = PathService::Get(base::DIR_SOURCE_ROOT, path); | 105 bool success = PathService::Get(base::DIR_SOURCE_ROOT, path); |
| 106 EXPECT_TRUE(success); | 106 EXPECT_TRUE(success); |
| 107 if (!success) | 107 if (!success) |
| 108 return false; | 108 return false; |
| 109 *path = path->AppendASCII("components"); | 109 *path = path->AppendASCII("base"); |
| 110 *path = path->AppendASCII("test"); | 110 *path = path->AppendASCII("test"); |
| 111 *path = path->AppendASCII("data"); | 111 *path = path->AppendASCII("data"); |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // The path to temporary directory used to contain the test operations. | 115 // The path to temporary directory used to contain the test operations. |
| 116 base::FilePath test_dir_; | 116 base::FilePath test_dir_; |
| 117 // The path to the test data directory where test.zip etc. are located. | 117 // The path to the test data directory where test.zip etc. are located. |
| 118 base::FilePath test_data_dir_; | 118 base::FilePath test_data_dir_; |
| 119 // The path to test.zip in the test data directory. | 119 // The path to test.zip in the test data directory. |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 ASSERT_TRUE(reader.ExtractCurrentEntryToFilePath( | 421 ASSERT_TRUE(reader.ExtractCurrentEntryToFilePath( |
| 422 test_dir_.AppendASCII("test.txt"))); | 422 test_dir_.AppendASCII("test.txt"))); |
| 423 | 423 |
| 424 std::string actual; | 424 std::string actual; |
| 425 ASSERT_TRUE(file_util::ReadFileToString( | 425 ASSERT_TRUE(file_util::ReadFileToString( |
| 426 test_dir_.AppendASCII("test.txt"), &actual)); | 426 test_dir_.AppendASCII("test.txt"), &actual)); |
| 427 EXPECT_EQ(std::string("This is a test.\n"), actual); | 427 EXPECT_EQ(std::string("This is a test.\n"), actual); |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace zip | 430 } // namespace zip |
| OLD | NEW |