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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 }; | 49 }; |
50 | 50 |
51 base::FilePath GetTopLevelPath(const base::FilePath& path) { | 51 base::FilePath GetTopLevelPath(const base::FilePath& path) { |
52 std::vector<base::FilePath::StringType> components; | 52 std::vector<base::FilePath::StringType> components; |
53 path.GetComponents(&components); | 53 path.GetComponents(&components); |
54 return base::FilePath(components[0]); | 54 return base::FilePath(components[0]); |
55 } | 55 } |
56 | 56 |
57 bool IsDirectoryEmpty(FileSystemContext* context, const FileSystemURL& url) { | 57 bool IsDirectoryEmpty(FileSystemContext* context, const FileSystemURL& url) { |
58 FileEntryList entries; | 58 FileEntryList entries; |
59 EXPECT_EQ(base::PLATFORM_FILE_OK, | 59 EXPECT_EQ(base::File::FILE_OK, |
60 AsyncFileTestHelper::ReadDirectory(context, url, &entries)); | 60 AsyncFileTestHelper::ReadDirectory(context, url, &entries)); |
61 return entries.empty(); | 61 return entries.empty(); |
62 } | 62 } |
63 | 63 |
64 FileSystemURL GetEntryURL(FileSystemContext* file_system_context, | 64 FileSystemURL GetEntryURL(FileSystemContext* file_system_context, |
65 const FileSystemURL& dir, | 65 const FileSystemURL& dir, |
66 const base::FilePath::StringType& name) { | 66 const base::FilePath::StringType& name) { |
67 return file_system_context->CreateCrackedFileSystemURL( | 67 return file_system_context->CreateCrackedFileSystemURL( |
68 dir.origin(), | 68 dir.origin(), |
69 dir.mount_type(), | 69 dir.mount_type(), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 FileSystemURL GetOtherFileSystemURL(const base::FilePath& path) const { | 155 FileSystemURL GetOtherFileSystemURL(const base::FilePath& path) const { |
156 return file_system_context()->CreateCrackedFileSystemURL( | 156 return file_system_context()->CreateCrackedFileSystemURL( |
157 GURL("http://example.com"), | 157 GURL("http://example.com"), |
158 fileapi::kFileSystemTypeTemporary, | 158 fileapi::kFileSystemTypeTemporary, |
159 base::FilePath().AppendASCII("dest").Append(path)); | 159 base::FilePath().AppendASCII("dest").Append(path)); |
160 } | 160 } |
161 | 161 |
162 void VerifyFilesHaveSameContent(const FileSystemURL& url1, | 162 void VerifyFilesHaveSameContent(const FileSystemURL& url1, |
163 const FileSystemURL& url2) { | 163 const FileSystemURL& url2) { |
164 // Get the file info and the platform path for url1. | 164 // Get the file info and the platform path for url1. |
165 base::PlatformFileInfo info1; | 165 base::File::Info info1; |
166 ASSERT_EQ(base::PLATFORM_FILE_OK, | 166 ASSERT_EQ(base::File::FILE_OK, |
167 AsyncFileTestHelper::GetMetadata( | 167 AsyncFileTestHelper::GetMetadata( |
168 file_system_context(), url1, &info1)); | 168 file_system_context(), url1, &info1)); |
169 base::FilePath platform_path1; | 169 base::FilePath platform_path1; |
170 ASSERT_EQ(base::PLATFORM_FILE_OK, | 170 ASSERT_EQ(base::File::FILE_OK, |
171 AsyncFileTestHelper::GetPlatformPath( | 171 AsyncFileTestHelper::GetPlatformPath( |
172 file_system_context(), url1, &platform_path1)); | 172 file_system_context(), url1, &platform_path1)); |
173 | 173 |
174 // Get the file info and the platform path for url2. | 174 // Get the file info and the platform path for url2. |
175 base::PlatformFileInfo info2; | 175 base::File::Info info2; |
176 ASSERT_EQ(base::PLATFORM_FILE_OK, | 176 ASSERT_EQ(base::File::FILE_OK, |
177 AsyncFileTestHelper::GetMetadata( | 177 AsyncFileTestHelper::GetMetadata( |
178 file_system_context(), url2, &info2)); | 178 file_system_context(), url2, &info2)); |
179 base::FilePath platform_path2; | 179 base::FilePath platform_path2; |
180 ASSERT_EQ(base::PLATFORM_FILE_OK, | 180 ASSERT_EQ(base::File::FILE_OK, |
181 AsyncFileTestHelper::GetPlatformPath( | 181 AsyncFileTestHelper::GetPlatformPath( |
182 file_system_context(), url2, &platform_path2)); | 182 file_system_context(), url2, &platform_path2)); |
183 | 183 |
184 // See if file info matches with the other one. | 184 // See if file info matches with the other one. |
185 EXPECT_EQ(info1.is_directory, info2.is_directory); | 185 EXPECT_EQ(info1.is_directory, info2.is_directory); |
186 EXPECT_EQ(info1.size, info2.size); | 186 EXPECT_EQ(info1.size, info2.size); |
187 EXPECT_EQ(info1.is_symbolic_link, info2.is_symbolic_link); | 187 EXPECT_EQ(info1.is_symbolic_link, info2.is_symbolic_link); |
188 EXPECT_NE(platform_path1, platform_path2); | 188 EXPECT_NE(platform_path1, platform_path2); |
189 | 189 |
190 std::string content1, content2; | 190 std::string content1, content2; |
191 EXPECT_TRUE(base::ReadFileToString(platform_path1, &content1)); | 191 EXPECT_TRUE(base::ReadFileToString(platform_path1, &content1)); |
192 EXPECT_TRUE(base::ReadFileToString(platform_path2, &content2)); | 192 EXPECT_TRUE(base::ReadFileToString(platform_path2, &content2)); |
193 EXPECT_EQ(content1, content2); | 193 EXPECT_EQ(content1, content2); |
194 } | 194 } |
195 | 195 |
196 void VerifyDirectoriesHaveSameContent(const FileSystemURL& root1, | 196 void VerifyDirectoriesHaveSameContent(const FileSystemURL& root1, |
197 const FileSystemURL& root2) { | 197 const FileSystemURL& root2) { |
198 base::FilePath root_path1 = root1.path(); | 198 base::FilePath root_path1 = root1.path(); |
199 base::FilePath root_path2 = root2.path(); | 199 base::FilePath root_path2 = root2.path(); |
200 | 200 |
201 FileEntryList entries; | 201 FileEntryList entries; |
202 std::queue<FileSystemURL> directories; | 202 std::queue<FileSystemURL> directories; |
203 | 203 |
204 directories.push(root1); | 204 directories.push(root1); |
205 std::set<base::FilePath> file_set1; | 205 std::set<base::FilePath> file_set1; |
206 while (!directories.empty()) { | 206 while (!directories.empty()) { |
207 FileSystemURL dir = directories.front(); | 207 FileSystemURL dir = directories.front(); |
208 directories.pop(); | 208 directories.pop(); |
209 | 209 |
210 ASSERT_EQ(base::PLATFORM_FILE_OK, | 210 ASSERT_EQ(base::File::FILE_OK, |
211 AsyncFileTestHelper::ReadDirectory( | 211 AsyncFileTestHelper::ReadDirectory( |
212 file_system_context(), dir, &entries)); | 212 file_system_context(), dir, &entries)); |
213 for (size_t i = 0; i < entries.size(); ++i) { | 213 for (size_t i = 0; i < entries.size(); ++i) { |
214 FileSystemURL url = GetEntryURL(file_system_context(), | 214 FileSystemURL url = GetEntryURL(file_system_context(), |
215 dir, entries[i].name); | 215 dir, entries[i].name); |
216 if (entries[i].is_directory) { | 216 if (entries[i].is_directory) { |
217 directories.push(url); | 217 directories.push(url); |
218 continue; | 218 continue; |
219 } | 219 } |
220 file_set1.insert(GetRelativeVirtualPath(root1, url)); | 220 file_set1.insert(GetRelativeVirtualPath(root1, url)); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 directories.push(root2); | 224 directories.push(root2); |
225 while (!directories.empty()) { | 225 while (!directories.empty()) { |
226 FileSystemURL dir = directories.front(); | 226 FileSystemURL dir = directories.front(); |
227 directories.pop(); | 227 directories.pop(); |
228 | 228 |
229 ASSERT_EQ(base::PLATFORM_FILE_OK, | 229 ASSERT_EQ(base::File::FILE_OK, |
230 AsyncFileTestHelper::ReadDirectory( | 230 AsyncFileTestHelper::ReadDirectory( |
231 file_system_context(), dir, &entries)); | 231 file_system_context(), dir, &entries)); |
232 for (size_t i = 0; i < entries.size(); ++i) { | 232 for (size_t i = 0; i < entries.size(); ++i) { |
233 FileSystemURL url2 = GetEntryURL(file_system_context(), | 233 FileSystemURL url2 = GetEntryURL(file_system_context(), |
234 dir, entries[i].name); | 234 dir, entries[i].name); |
235 FileSystemURL url1 = GetOtherURL(file_system_context(), | 235 FileSystemURL url1 = GetOtherURL(file_system_context(), |
236 root2, root1, url2); | 236 root2, root1, url2); |
237 if (entries[i].is_directory) { | 237 if (entries[i].is_directory) { |
238 directories.push(url2); | 238 directories.push(url2); |
239 EXPECT_EQ(IsDirectoryEmpty(file_system_context(), url1), | 239 EXPECT_EQ(IsDirectoryEmpty(file_system_context(), url1), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { | 294 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { |
295 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i); | 295 SCOPED_TRACE(testing::Message() << "Testing RegularTestCases " << i); |
296 const fileapi::test::TestCaseRecord& test_case = | 296 const fileapi::test::TestCaseRecord& test_case = |
297 fileapi::test::kRegularTestCases[i]; | 297 fileapi::test::kRegularTestCases[i]; |
298 | 298 |
299 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 299 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
300 | 300 |
301 // See if we can query the file info via the isolated FileUtil. | 301 // See if we can query the file info via the isolated FileUtil. |
302 // (This should succeed since we have registered all the top-level | 302 // (This should succeed since we have registered all the top-level |
303 // entries of the test cases in SetUp()) | 303 // entries of the test cases in SetUp()) |
304 base::PlatformFileInfo info; | 304 base::File::Info info; |
305 base::FilePath platform_path; | 305 base::FilePath platform_path; |
306 FileSystemOperationContext context(file_system_context()); | 306 FileSystemOperationContext context(file_system_context()); |
307 ASSERT_EQ(base::PLATFORM_FILE_OK, | 307 ASSERT_EQ(base::File::FILE_OK, |
308 file_util()->GetFileInfo(&context, url, &info, &platform_path)); | 308 file_util()->GetFileInfo(&context, url, &info, &platform_path)); |
309 | 309 |
310 // See if the obtained file info is correct. | 310 // See if the obtained file info is correct. |
311 if (!test_case.is_directory) | 311 if (!test_case.is_directory) |
312 ASSERT_EQ(test_case.data_file_size, info.size); | 312 ASSERT_EQ(test_case.data_file_size, info.size); |
313 ASSERT_EQ(test_case.is_directory, info.is_directory); | 313 ASSERT_EQ(test_case.is_directory, info.is_directory); |
314 ASSERT_EQ(GetTestCasePlatformPath(test_case.path), | 314 ASSERT_EQ(GetTestCasePlatformPath(test_case.path), |
315 platform_path.NormalizePathSeparators()); | 315 platform_path.NormalizePathSeparators()); |
316 } | 316 } |
317 } | 317 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 base::CreateSymbolicLink( | 386 base::CreateSymbolicLink( |
387 current, | 387 current, |
388 dir_path.Append(current.BaseName().AddExtension( | 388 dir_path.Append(current.BaseName().AddExtension( |
389 FILE_PATH_LITERAL("link")))); | 389 FILE_PATH_LITERAL("link")))); |
390 #endif | 390 #endif |
391 } | 391 } |
392 | 392 |
393 // Perform ReadDirectory in the isolated filesystem. | 393 // Perform ReadDirectory in the isolated filesystem. |
394 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 394 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
395 FileEntryList entries; | 395 FileEntryList entries; |
396 ASSERT_EQ(base::PLATFORM_FILE_OK, | 396 ASSERT_EQ(base::File::FILE_OK, |
397 AsyncFileTestHelper::ReadDirectory( | 397 AsyncFileTestHelper::ReadDirectory( |
398 file_system_context(), url, &entries)); | 398 file_system_context(), url, &entries)); |
399 | 399 |
400 EXPECT_EQ(expected_entry_map.size(), entries.size()); | 400 EXPECT_EQ(expected_entry_map.size(), entries.size()); |
401 for (size_t i = 0; i < entries.size(); ++i) { | 401 for (size_t i = 0; i < entries.size(); ++i) { |
402 const fileapi::DirectoryEntry& entry = entries[i]; | 402 const fileapi::DirectoryEntry& entry = entries[i]; |
403 EntryMap::iterator found = expected_entry_map.find(entry.name); | 403 EntryMap::iterator found = expected_entry_map.find(entry.name); |
404 EXPECT_TRUE(found != expected_entry_map.end()); | 404 EXPECT_TRUE(found != expected_entry_map.end()); |
405 EXPECT_EQ(found->second.name, entry.name); | 405 EXPECT_EQ(found->second.name, entry.name); |
406 EXPECT_EQ(found->second.is_directory, entry.is_directory); | 406 EXPECT_EQ(found->second.is_directory, entry.is_directory); |
407 EXPECT_EQ(found->second.size, entry.size); | 407 EXPECT_EQ(found->second.size, entry.size); |
408 EXPECT_EQ(found->second.last_modified_time.ToDoubleT(), | 408 EXPECT_EQ(found->second.last_modified_time.ToDoubleT(), |
409 entry.last_modified_time.ToDoubleT()); | 409 entry.last_modified_time.ToDoubleT()); |
410 } | 410 } |
411 } | 411 } |
412 } | 412 } |
413 | 413 |
414 TEST_F(DraggedFileUtilTest, GetLocalFilePathTest) { | 414 TEST_F(DraggedFileUtilTest, GetLocalFilePathTest) { |
415 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { | 415 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { |
416 const fileapi::test::TestCaseRecord& test_case = | 416 const fileapi::test::TestCaseRecord& test_case = |
417 fileapi::test::kRegularTestCases[i]; | 417 fileapi::test::kRegularTestCases[i]; |
418 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 418 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
419 | 419 |
420 FileSystemOperationContext context(file_system_context()); | 420 FileSystemOperationContext context(file_system_context()); |
421 | 421 |
422 base::FilePath local_file_path; | 422 base::FilePath local_file_path; |
423 EXPECT_EQ(base::PLATFORM_FILE_OK, | 423 EXPECT_EQ(base::File::FILE_OK, |
424 file_util()->GetLocalFilePath(&context, url, &local_file_path)); | 424 file_util()->GetLocalFilePath(&context, url, &local_file_path)); |
425 EXPECT_EQ(GetTestCasePlatformPath(test_case.path).value(), | 425 EXPECT_EQ(GetTestCasePlatformPath(test_case.path).value(), |
426 local_file_path.value()); | 426 local_file_path.value()); |
427 } | 427 } |
428 } | 428 } |
429 | 429 |
430 TEST_F(DraggedFileUtilTest, CopyOutFileTest) { | 430 TEST_F(DraggedFileUtilTest, CopyOutFileTest) { |
431 FileSystemURL src_root = GetFileSystemURL(base::FilePath()); | 431 FileSystemURL src_root = GetFileSystemURL(base::FilePath()); |
432 FileSystemURL dest_root = GetOtherFileSystemURL(base::FilePath()); | 432 FileSystemURL dest_root = GetOtherFileSystemURL(base::FilePath()); |
433 | 433 |
434 FileEntryList entries; | 434 FileEntryList entries; |
435 std::queue<FileSystemURL> directories; | 435 std::queue<FileSystemURL> directories; |
436 directories.push(src_root); | 436 directories.push(src_root); |
437 | 437 |
438 ASSERT_EQ(base::PLATFORM_FILE_OK, | 438 ASSERT_EQ(base::File::FILE_OK, |
439 AsyncFileTestHelper::CreateDirectory(file_system_context(), | 439 AsyncFileTestHelper::CreateDirectory(file_system_context(), |
440 dest_root)); | 440 dest_root)); |
441 | 441 |
442 while (!directories.empty()) { | 442 while (!directories.empty()) { |
443 FileSystemURL dir = directories.front(); | 443 FileSystemURL dir = directories.front(); |
444 directories.pop(); | 444 directories.pop(); |
445 ASSERT_EQ(base::PLATFORM_FILE_OK, | 445 ASSERT_EQ(base::File::FILE_OK, |
446 AsyncFileTestHelper::ReadDirectory(file_system_context(), | 446 AsyncFileTestHelper::ReadDirectory(file_system_context(), |
447 dir, &entries)); | 447 dir, &entries)); |
448 for (size_t i = 0; i < entries.size(); ++i) { | 448 for (size_t i = 0; i < entries.size(); ++i) { |
449 FileSystemURL src_url = GetEntryURL(file_system_context(), | 449 FileSystemURL src_url = GetEntryURL(file_system_context(), |
450 dir, entries[i].name); | 450 dir, entries[i].name); |
451 FileSystemURL dest_url = GetOtherURL(file_system_context(), | 451 FileSystemURL dest_url = GetOtherURL(file_system_context(), |
452 src_root, dest_root, src_url); | 452 src_root, dest_root, src_url); |
453 | 453 |
454 if (entries[i].is_directory) { | 454 if (entries[i].is_directory) { |
455 ASSERT_EQ(base::PLATFORM_FILE_OK, | 455 ASSERT_EQ(base::File::FILE_OK, |
456 AsyncFileTestHelper::CreateDirectory(file_system_context(), | 456 AsyncFileTestHelper::CreateDirectory(file_system_context(), |
457 dest_url)); | 457 dest_url)); |
458 directories.push(src_url); | 458 directories.push(src_url); |
459 continue; | 459 continue; |
460 } | 460 } |
461 SCOPED_TRACE(testing::Message() << "Testing file copy " | 461 SCOPED_TRACE(testing::Message() << "Testing file copy " |
462 << src_url.path().value()); | 462 << src_url.path().value()); |
463 ASSERT_EQ(base::PLATFORM_FILE_OK, | 463 ASSERT_EQ(base::File::FILE_OK, |
464 AsyncFileTestHelper::Copy(file_system_context(), | 464 AsyncFileTestHelper::Copy(file_system_context(), |
465 src_url, dest_url)); | 465 src_url, dest_url)); |
466 VerifyFilesHaveSameContent(src_url, dest_url); | 466 VerifyFilesHaveSameContent(src_url, dest_url); |
467 } | 467 } |
468 } | 468 } |
469 } | 469 } |
470 | 470 |
471 TEST_F(DraggedFileUtilTest, CopyOutDirectoryTest) { | 471 TEST_F(DraggedFileUtilTest, CopyOutDirectoryTest) { |
472 FileSystemURL src_root = GetFileSystemURL(base::FilePath()); | 472 FileSystemURL src_root = GetFileSystemURL(base::FilePath()); |
473 FileSystemURL dest_root = GetOtherFileSystemURL(base::FilePath()); | 473 FileSystemURL dest_root = GetOtherFileSystemURL(base::FilePath()); |
474 | 474 |
475 ASSERT_EQ(base::PLATFORM_FILE_OK, | 475 ASSERT_EQ(base::File::FILE_OK, |
476 AsyncFileTestHelper::CreateDirectory(file_system_context(), | 476 AsyncFileTestHelper::CreateDirectory(file_system_context(), |
477 dest_root)); | 477 dest_root)); |
478 | 478 |
479 FileEntryList entries; | 479 FileEntryList entries; |
480 ASSERT_EQ(base::PLATFORM_FILE_OK, | 480 ASSERT_EQ(base::File::FILE_OK, |
481 AsyncFileTestHelper::ReadDirectory(file_system_context(), | 481 AsyncFileTestHelper::ReadDirectory(file_system_context(), |
482 src_root, &entries)); | 482 src_root, &entries)); |
483 for (size_t i = 0; i < entries.size(); ++i) { | 483 for (size_t i = 0; i < entries.size(); ++i) { |
484 if (!entries[i].is_directory) | 484 if (!entries[i].is_directory) |
485 continue; | 485 continue; |
486 FileSystemURL src_url = GetEntryURL(file_system_context(), | 486 FileSystemURL src_url = GetEntryURL(file_system_context(), |
487 src_root, entries[i].name); | 487 src_root, entries[i].name); |
488 FileSystemURL dest_url = GetOtherURL(file_system_context(), | 488 FileSystemURL dest_url = GetOtherURL(file_system_context(), |
489 src_root, dest_root, src_url); | 489 src_root, dest_root, src_url); |
490 SCOPED_TRACE(testing::Message() << "Testing file copy " | 490 SCOPED_TRACE(testing::Message() << "Testing file copy " |
491 << src_url.path().value()); | 491 << src_url.path().value()); |
492 ASSERT_EQ(base::PLATFORM_FILE_OK, | 492 ASSERT_EQ(base::File::FILE_OK, |
493 AsyncFileTestHelper::Copy(file_system_context(), | 493 AsyncFileTestHelper::Copy(file_system_context(), |
494 src_url, dest_url)); | 494 src_url, dest_url)); |
495 VerifyDirectoriesHaveSameContent(src_url, dest_url); | 495 VerifyDirectoriesHaveSameContent(src_url, dest_url); |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 TEST_F(DraggedFileUtilTest, TouchTest) { | 499 TEST_F(DraggedFileUtilTest, TouchTest) { |
500 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { | 500 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { |
501 const fileapi::test::TestCaseRecord& test_case = | 501 const fileapi::test::TestCaseRecord& test_case = |
502 fileapi::test::kRegularTestCases[i]; | 502 fileapi::test::kRegularTestCases[i]; |
503 if (test_case.is_directory) | 503 if (test_case.is_directory) |
504 continue; | 504 continue; |
505 SCOPED_TRACE(testing::Message() << test_case.path); | 505 SCOPED_TRACE(testing::Message() << test_case.path); |
506 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 506 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
507 | 507 |
508 base::Time last_access_time = base::Time::FromTimeT(1000); | 508 base::Time last_access_time = base::Time::FromTimeT(1000); |
509 base::Time last_modified_time = base::Time::FromTimeT(2000); | 509 base::Time last_modified_time = base::Time::FromTimeT(2000); |
510 | 510 |
511 EXPECT_EQ(base::PLATFORM_FILE_OK, | 511 EXPECT_EQ(base::File::FILE_OK, |
512 file_util()->Touch(GetOperationContext().get(), url, | 512 file_util()->Touch(GetOperationContext().get(), url, |
513 last_access_time, | 513 last_access_time, |
514 last_modified_time)); | 514 last_modified_time)); |
515 | 515 |
516 // Verification. | 516 // Verification. |
517 base::PlatformFileInfo info; | 517 base::File::Info info; |
518 base::FilePath platform_path; | 518 base::FilePath platform_path; |
519 ASSERT_EQ(base::PLATFORM_FILE_OK, | 519 ASSERT_EQ(base::File::FILE_OK, |
520 file_util()->GetFileInfo(GetOperationContext().get(), url, | 520 file_util()->GetFileInfo(GetOperationContext().get(), url, |
521 &info, &platform_path)); | 521 &info, &platform_path)); |
522 EXPECT_EQ(last_access_time.ToTimeT(), info.last_accessed.ToTimeT()); | 522 EXPECT_EQ(last_access_time.ToTimeT(), info.last_accessed.ToTimeT()); |
523 EXPECT_EQ(last_modified_time.ToTimeT(), info.last_modified.ToTimeT()); | 523 EXPECT_EQ(last_modified_time.ToTimeT(), info.last_modified.ToTimeT()); |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 TEST_F(DraggedFileUtilTest, TruncateTest) { | 527 TEST_F(DraggedFileUtilTest, TruncateTest) { |
528 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { | 528 for (size_t i = 0; i < fileapi::test::kRegularTestCaseSize; ++i) { |
529 const fileapi::test::TestCaseRecord& test_case = | 529 const fileapi::test::TestCaseRecord& test_case = |
530 fileapi::test::kRegularTestCases[i]; | 530 fileapi::test::kRegularTestCases[i]; |
531 if (test_case.is_directory) | 531 if (test_case.is_directory) |
532 continue; | 532 continue; |
533 | 533 |
534 SCOPED_TRACE(testing::Message() << test_case.path); | 534 SCOPED_TRACE(testing::Message() << test_case.path); |
535 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); | 535 FileSystemURL url = GetFileSystemURL(base::FilePath(test_case.path)); |
536 | 536 |
537 // Truncate to 0. | 537 // Truncate to 0. |
538 base::PlatformFileInfo info; | 538 base::File::Info info; |
539 base::FilePath platform_path; | 539 base::FilePath platform_path; |
540 EXPECT_EQ(base::PLATFORM_FILE_OK, | 540 EXPECT_EQ(base::File::FILE_OK, |
541 file_util()->Truncate(GetOperationContext().get(), url, 0)); | 541 file_util()->Truncate(GetOperationContext().get(), url, 0)); |
542 ASSERT_EQ(base::PLATFORM_FILE_OK, | 542 ASSERT_EQ(base::File::FILE_OK, |
543 file_util()->GetFileInfo(GetOperationContext().get(), url, | 543 file_util()->GetFileInfo(GetOperationContext().get(), url, |
544 &info, &platform_path)); | 544 &info, &platform_path)); |
545 EXPECT_EQ(0, info.size); | 545 EXPECT_EQ(0, info.size); |
546 | 546 |
547 // Truncate (extend) to 999. | 547 // Truncate (extend) to 999. |
548 EXPECT_EQ(base::PLATFORM_FILE_OK, | 548 EXPECT_EQ(base::File::FILE_OK, |
549 file_util()->Truncate(GetOperationContext().get(), url, 999)); | 549 file_util()->Truncate(GetOperationContext().get(), url, 999)); |
550 ASSERT_EQ(base::PLATFORM_FILE_OK, | 550 ASSERT_EQ(base::File::FILE_OK, |
551 file_util()->GetFileInfo(GetOperationContext().get(), url, | 551 file_util()->GetFileInfo(GetOperationContext().get(), url, |
552 &info, &platform_path)); | 552 &info, &platform_path)); |
553 EXPECT_EQ(999, info.size); | 553 EXPECT_EQ(999, info.size); |
554 } | 554 } |
555 } | 555 } |
556 | 556 |
557 } // namespace content | 557 } // namespace content |
OLD | NEW |