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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 class ZipFileCreatorTest : public InProcessBrowserTest { | 29 class ZipFileCreatorTest : public InProcessBrowserTest { |
30 protected: | 30 protected: |
31 void SetUpOnMainThread() override { | 31 void SetUpOnMainThread() override { |
32 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 32 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
33 ASSERT_TRUE(base::CreateDirectory(zip_base_dir())); | 33 ASSERT_TRUE(base::CreateDirectory(zip_base_dir())); |
34 } | 34 } |
35 | 35 |
36 base::FilePath zip_archive_path() const { | 36 base::FilePath zip_archive_path() const { |
37 return dir_.path().AppendASCII("test.zip"); | 37 return dir_.GetPath().AppendASCII("test.zip"); |
38 } | 38 } |
39 | 39 |
40 base::FilePath zip_base_dir() const { | 40 base::FilePath zip_base_dir() const { |
41 return dir_.path().AppendASCII("files"); | 41 return dir_.GetPath().AppendASCII("files"); |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 base::ScopedTempDir dir_; | 45 base::ScopedTempDir dir_; |
46 }; | 46 }; |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 IN_PROC_BROWSER_TEST_F(ZipFileCreatorTest, FailZipForAbsentFile) { | 50 IN_PROC_BROWSER_TEST_F(ZipFileCreatorTest, FailZipForAbsentFile) { |
51 base::RunLoop run_loop; | 51 base::RunLoop run_loop; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // ZipReader returns directory path with trailing slash. | 103 // ZipReader returns directory path with trailing slash. |
104 if (entry->file_path() == kDir1.AsEndingWithSeparator()) { | 104 if (entry->file_path() == kDir1.AsEndingWithSeparator()) { |
105 EXPECT_TRUE(entry->is_directory()); | 105 EXPECT_TRUE(entry->is_directory()); |
106 } else if (entry->file_path() == kFile1) { | 106 } else if (entry->file_path() == kFile1) { |
107 EXPECT_FALSE(entry->is_directory()); | 107 EXPECT_FALSE(entry->is_directory()); |
108 EXPECT_EQ(3, entry->original_size()); | 108 EXPECT_EQ(3, entry->original_size()); |
109 } else if (entry->file_path() == kFile2) { | 109 } else if (entry->file_path() == kFile2) { |
110 EXPECT_FALSE(entry->is_directory()); | 110 EXPECT_FALSE(entry->is_directory()); |
111 EXPECT_EQ(kRandomDataSize, entry->original_size()); | 111 EXPECT_EQ(kRandomDataSize, entry->original_size()); |
112 | 112 |
113 const base::FilePath out = dir_.path().AppendASCII("archived_content"); | 113 const base::FilePath out = dir_.GetPath().AppendASCII("archived_content"); |
114 EXPECT_TRUE(reader.ExtractCurrentEntryToFilePath(out)); | 114 EXPECT_TRUE(reader.ExtractCurrentEntryToFilePath(out)); |
115 EXPECT_TRUE(base::ContentsEqual(zip_base_dir().Append(kFile2), out)); | 115 EXPECT_TRUE(base::ContentsEqual(zip_base_dir().Append(kFile2), out)); |
116 } else { | 116 } else { |
117 ADD_FAILURE(); | 117 ADD_FAILURE(); |
118 } | 118 } |
119 ASSERT_TRUE(reader.AdvanceToNextEntry()); | 119 ASSERT_TRUE(reader.AdvanceToNextEntry()); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 } // namespace file_manager | 123 } // namespace file_manager |
OLD | NEW |