| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/file_manager/zip_file_creator.h" | 5 #include "chrome/browser/chromeos/file_manager/zip_file_creator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 IN_PROC_BROWSER_TEST_F(ZipFileCreatorTest, SomeFilesZip) { | 76 IN_PROC_BROWSER_TEST_F(ZipFileCreatorTest, SomeFilesZip) { |
| 77 // Prepare files. | 77 // Prepare files. |
| 78 const base::FilePath kDir1(FILE_PATH_LITERAL("foo")); | 78 const base::FilePath kDir1(FILE_PATH_LITERAL("foo")); |
| 79 const base::FilePath kFile1(kDir1.AppendASCII("bar")); | 79 const base::FilePath kFile1(kDir1.AppendASCII("bar")); |
| 80 const base::FilePath kFile2(FILE_PATH_LITERAL("random")); | 80 const base::FilePath kFile2(FILE_PATH_LITERAL("random")); |
| 81 const int kRandomDataSize = 100000; | 81 const int kRandomDataSize = 100000; |
| 82 const std::string kRandomData = base::RandBytesAsString(kRandomDataSize); | 82 const std::string kRandomData = base::RandBytesAsString(kRandomDataSize); |
| 83 base::CreateDirectory(zip_base_dir().Append(kDir1)); | 83 base::CreateDirectory(zip_base_dir().Append(kDir1)); |
| 84 file_util::WriteFile(zip_base_dir().Append(kFile1), "123", 3); | 84 base::WriteFile(zip_base_dir().Append(kFile1), "123", 3); |
| 85 file_util::WriteFile(zip_base_dir().Append(kFile2), | 85 base::WriteFile(zip_base_dir().Append(kFile2), |
| 86 kRandomData.c_str(), kRandomData.size()); | 86 kRandomData.c_str(), kRandomData.size()); |
| 87 | 87 |
| 88 base::RunLoop run_loop; | 88 base::RunLoop run_loop; |
| 89 TestObserver observer(content::GetQuitTaskForRunLoop(&run_loop)); | 89 TestObserver observer(content::GetQuitTaskForRunLoop(&run_loop)); |
| 90 | 90 |
| 91 std::vector<base::FilePath> paths; | 91 std::vector<base::FilePath> paths; |
| 92 paths.push_back(kDir1); | 92 paths.push_back(kDir1); |
| 93 paths.push_back(kFile1); | 93 paths.push_back(kFile1); |
| 94 paths.push_back(kFile2); | 94 paths.push_back(kFile2); |
| 95 scoped_refptr<ZipFileCreator> zipper(new ZipFileCreator( | 95 scoped_refptr<ZipFileCreator> zipper(new ZipFileCreator( |
| 96 &observer, zip_base_dir(), paths, zip_archive_path())); | 96 &observer, zip_base_dir(), paths, zip_archive_path())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 120 EXPECT_TRUE(reader.ExtractCurrentEntryToFilePath(out)); | 120 EXPECT_TRUE(reader.ExtractCurrentEntryToFilePath(out)); |
| 121 EXPECT_TRUE(base::ContentsEqual(zip_base_dir().Append(kFile2), out)); | 121 EXPECT_TRUE(base::ContentsEqual(zip_base_dir().Append(kFile2), out)); |
| 122 } else { | 122 } else { |
| 123 ADD_FAILURE(); | 123 ADD_FAILURE(); |
| 124 } | 124 } |
| 125 ASSERT_TRUE(reader.AdvanceToNextEntry()); | 125 ASSERT_TRUE(reader.AdvanceToNextEntry()); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace file_manager | 129 } // namespace file_manager |
| OLD | NEW |