OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/fileapi/file_system_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 ScopedTempDir dir; | 421 ScopedTempDir dir; |
422 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 422 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
423 FilePath file; | 423 FilePath file; |
424 | 424 |
425 file_util::CreateTemporaryFileInDir(dir.path(), &file); | 425 file_util::CreateTemporaryFileInDir(dir.path(), &file); |
426 operation()->CreateFile(file, true); | 426 operation()->CreateFile(file, true); |
427 MessageLoop::current()->RunAllPending(); | 427 MessageLoop::current()->RunAllPending(); |
428 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); | 428 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); |
429 } | 429 } |
430 | 430 |
431 TEST_F(FileSystemOperationTest, TestCreateVeryLongName) { | |
432 ScopedTempDir dir; | |
433 ASSERT_TRUE(dir.CreateUniqueTempDir()); | |
434 | |
435 #if defined(OS_WIN) | |
436 FilePath dir_path(FILE_PATH_LITERAL("\\\\?\\") + dir.path().value()); | |
kinuko
2010/12/15 00:09:30
Can we use FilePath::kExtendedPathPrefix?
Kavita Kanetkar
2010/12/16 00:48:55
Done.
| |
437 #else | |
438 FilePath dir_path = dir.path(); | |
439 #endif | |
440 | |
441 // TODO(kkanetkar): Once each platform's limitations have been enforced | |
442 // consider that in this test. Currently this test is for | |
443 // windows primarily. | |
444 FilePath dir1 = dir_path.AppendASCII( | |
445 "012345678901234567890123456789012345678901234567890123456789" | |
446 "012345678901234567890123456789012345678901234567890123456789" | |
447 "0123456789012345678901234567890123456789012345"); | |
448 | |
449 FilePath dir2 = dir1.AppendASCII( | |
450 "012345678901234567890123456789012345678901234567890123456789" | |
451 "012345678901234567890123456789012345678901234567890123456789" | |
452 "0123456789012345678901234567890123456789"); | |
453 | |
454 FilePath file = dir2.AppendASCII( | |
455 "012345678901234567890123456789012345678901234567890123456789" | |
456 "012345678901234567890123456789012345678901234567890123456789" | |
457 "0123456789012345678901234567890123456789"); | |
kinuko
2010/12/15 00:09:30
It might be better to define FilePath::String long
Kavita Kanetkar
2010/12/16 00:48:55
Done.
| |
458 | |
459 operation()->CreateDirectory(dir1, false, true); | |
460 MessageLoop::current()->RunAllPending(); | |
461 | |
462 operation()->CreateDirectory(dir2, false, true); | |
463 MessageLoop::current()->RunAllPending(); | |
464 | |
465 operation()->CreateFile(file, true); | |
466 MessageLoop::current()->RunAllPending(); | |
467 EXPECT_TRUE(file_util::PathExists(file)); | |
468 // ScopedTempDir does not delete dir with long name since it does | |
469 // not prefix \\?\. So Delete the long file here. | |
470 EXPECT_TRUE(file_util::Delete(dir1, true)); | |
471 } | |
472 | |
431 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { | 473 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { |
432 // Already existing file and exclusive false. | 474 // Already existing file and exclusive false. |
433 ScopedTempDir dir; | 475 ScopedTempDir dir; |
434 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 476 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
435 FilePath file; | 477 FilePath file; |
436 file_util::CreateTemporaryFileInDir(dir.path(), &file); | 478 file_util::CreateTemporaryFileInDir(dir.path(), &file); |
437 | 479 |
438 operation()->CreateFile(file, false); | 480 operation()->CreateFile(file, false); |
439 MessageLoop::current()->RunAllPending(); | 481 MessageLoop::current()->RunAllPending(); |
440 EXPECT_EQ(kFileOperationSucceeded, status()); | 482 EXPECT_EQ(kFileOperationSucceeded, status()); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 | 763 |
722 // Check that its length is now 3 and that it contains only bits of test data. | 764 // Check that its length is now 3 and that it contains only bits of test data. |
723 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); | 765 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); |
724 EXPECT_EQ(length, info.size); | 766 EXPECT_EQ(length, info.size); |
725 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); | 767 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); |
726 for (int i = 0; i < length; ++i) | 768 for (int i = 0; i < length; ++i) |
727 EXPECT_EQ(test_data[i], data[i]); | 769 EXPECT_EQ(test_data[i], data[i]); |
728 } | 770 } |
729 | 771 |
730 } // namespace fileapi | 772 } // namespace fileapi |
OLD | NEW |