OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <list> | 5 #include <list> |
6 #include <utility> | 6 #include <utility> |
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" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // directory. | 102 // directory. |
103 std::list<std::pair<base::FilePath, int> > directories; | 103 std::list<std::pair<base::FilePath, int> > directories; |
104 ASSERT_TRUE(temp_root_dir_.CreateUniqueTempDir()); | 104 ASSERT_TRUE(temp_root_dir_.CreateUniqueTempDir()); |
105 directories.push_back(std::make_pair(temp_root_dir_.path(), 0)); | 105 directories.push_back(std::make_pair(temp_root_dir_.path(), 0)); |
106 while (!directories.empty()) { | 106 while (!directories.empty()) { |
107 std::pair<base::FilePath, int> dir_data = directories.front(); | 107 std::pair<base::FilePath, int> dir_data = directories.front(); |
108 directories.pop_front(); | 108 directories.pop_front(); |
109 for (int i = 0; i < kFilesPerDirectory; i++) { | 109 for (int i = 0; i < kFilesPerDirectory; i++) { |
110 std::string file_name = base::StringPrintf("file_id_%d", i); | 110 std::string file_name = base::StringPrintf("file_id_%d", i); |
111 base::FilePath file_path = dir_data.first.AppendASCII(file_name); | 111 base::FilePath file_path = dir_data.first.AppendASCII(file_name); |
112 base::PlatformFile file = base::CreatePlatformFile( | 112 base::File file(file_path, |
113 file_path, | 113 base::File::FLAG_CREATE | base::File::FLAG_WRITE); |
114 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE, | 114 ASSERT_TRUE(file.IsValid()); |
115 NULL, | |
116 NULL); | |
117 ASSERT_NE(base::kInvalidPlatformFileValue, file); | |
118 ASSERT_TRUE(base::ClosePlatformFile(file)); | |
119 } | 115 } |
120 if (dir_data.second < kMaxDepth - 1) { | 116 if (dir_data.second < kMaxDepth - 1) { |
121 for (int i = 0; i < kBranchingFactor; i++) { | 117 for (int i = 0; i < kBranchingFactor; i++) { |
122 std::string dir_name = base::StringPrintf("child_dir_%d", i); | 118 std::string dir_name = base::StringPrintf("child_dir_%d", i); |
123 base::FilePath dir_path = dir_data.first.AppendASCII(dir_name); | 119 base::FilePath dir_path = dir_data.first.AppendASCII(dir_name); |
124 ASSERT_TRUE(base::CreateDirectory(dir_path)); | 120 ASSERT_TRUE(base::CreateDirectory(dir_path)); |
125 directories.push_back(std::make_pair(dir_path, dir_data.second + 1)); | 121 directories.push_back(std::make_pair(dir_path, dir_data.second + 1)); |
126 } | 122 } |
127 } | 123 } |
128 } | 124 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 lister.Start(); | 181 lister.Start(); |
186 | 182 |
187 base::MessageLoop::current()->Run(); | 183 base::MessageLoop::current()->Run(); |
188 | 184 |
189 // Contains only the parent directory ("..") | 185 // Contains only the parent directory ("..") |
190 EXPECT_EQ(1, delegate.num_files()); | 186 EXPECT_EQ(1, delegate.num_files()); |
191 EXPECT_EQ(OK, delegate.error()); | 187 EXPECT_EQ(OK, delegate.error()); |
192 } | 188 } |
193 | 189 |
194 } // namespace net | 190 } // namespace net |
OLD | NEW |