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()); |
| 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 "0123456789012345678901234567890123456789"); |
| 448 FilePath file = dir1.AppendASCII( |
| 449 "012345678901234567890123456789012345678901234567890123456789" |
| 450 "012345678901234567890123456789012345678901234567890123456789" |
| 451 "0123456789012345678901234567890123456789"); |
| 452 operation()->CreateDirectory(dir1, false, true); |
| 453 MessageLoop::current()->RunAllPending(); |
| 454 operation()->CreateFile(file, true); |
| 455 MessageLoop::current()->RunAllPending(); |
| 456 EXPECT_TRUE(file_util::PathExists(file)); |
| 457 // ScopedTempDir does not delete dir with long name since it does |
| 458 // not prefix \\?\. So Delete the long file here. |
| 459 EXPECT_TRUE(file_util::Delete(file, false)); |
| 460 } |
| 461 |
431 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { | 462 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { |
432 // Already existing file and exclusive false. | 463 // Already existing file and exclusive false. |
433 ScopedTempDir dir; | 464 ScopedTempDir dir; |
434 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 465 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
435 FilePath file; | 466 FilePath file; |
436 file_util::CreateTemporaryFileInDir(dir.path(), &file); | 467 file_util::CreateTemporaryFileInDir(dir.path(), &file); |
437 | 468 |
438 operation()->CreateFile(file, false); | 469 operation()->CreateFile(file, false); |
439 MessageLoop::current()->RunAllPending(); | 470 MessageLoop::current()->RunAllPending(); |
440 EXPECT_EQ(kFileOperationSucceeded, status()); | 471 EXPECT_EQ(kFileOperationSucceeded, status()); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 752 |
722 // Check that its length is now 3 and that it contains only bits of test data. | 753 // Check that its length is now 3 and that it contains only bits of test data. |
723 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); | 754 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); |
724 EXPECT_EQ(length, info.size); | 755 EXPECT_EQ(length, info.size); |
725 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); | 756 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); |
726 for (int i = 0; i < length; ++i) | 757 for (int i = 0; i < length; ++i) |
727 EXPECT_EQ(test_data[i], data[i]); | 758 EXPECT_EQ(test_data[i], data[i]); |
728 } | 759 } |
729 | 760 |
730 } // namespace fileapi | 761 } // namespace fileapi |
OLD | NEW |