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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 456 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
457 FilePath file; | 457 FilePath file; |
458 | 458 |
459 file_util::CreateTemporaryFileInDir(dir.path(), &file); | 459 file_util::CreateTemporaryFileInDir(dir.path(), &file); |
460 operation()->CreateFile(file, true); | 460 operation()->CreateFile(file, true); |
461 MessageLoop::current()->RunAllPending(); | 461 MessageLoop::current()->RunAllPending(); |
462 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, mock_dispatcher_->status()); | 462 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, mock_dispatcher_->status()); |
463 EXPECT_EQ(request_id_, mock_dispatcher_->request_id()); | 463 EXPECT_EQ(request_id_, mock_dispatcher_->request_id()); |
464 } | 464 } |
465 | 465 |
| 466 TEST_F(FileSystemOperationTest, TestCreateVeryLongName) { |
| 467 ScopedTempDir dir; |
| 468 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 469 |
| 470 #if defined(OS_WIN) |
| 471 FilePath dir_path(FILE_PATH_LITERAL("\\\\?\\") + dir.path().value()); |
| 472 #else |
| 473 FilePath dir_path = dir.path(); |
| 474 #endif |
| 475 |
| 476 // TODO(kkanetkar): Once each platform's limitations have been enforced |
| 477 // consider that in this test. Currently this test is for |
| 478 // windows primarily. |
| 479 FilePath dir1 = dir_path.AppendASCII( |
| 480 "012345678901234567890123456789012345678901234567890123456789" |
| 481 "012345678901234567890123456789012345678901234567890123456789" |
| 482 "0123456789012345678901234567890123456789"); |
| 483 FilePath file = dir1.AppendASCII( |
| 484 "012345678901234567890123456789012345678901234567890123456789" |
| 485 "012345678901234567890123456789012345678901234567890123456789" |
| 486 "0123456789012345678901234567890123456789"); |
| 487 operation()->CreateDirectory(dir1, false, true); |
| 488 MessageLoop::current()->RunAllPending(); |
| 489 operation()->CreateFile(file, true); |
| 490 MessageLoop::current()->RunAllPending(); |
| 491 EXPECT_TRUE(file_util::PathExists(file)); |
| 492 } |
| 493 |
466 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { | 494 TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { |
467 // Already existing file and exclusive false. | 495 // Already existing file and exclusive false. |
468 ScopedTempDir dir; | 496 ScopedTempDir dir; |
469 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 497 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
470 FilePath file; | 498 FilePath file; |
471 file_util::CreateTemporaryFileInDir(dir.path(), &file); | 499 file_util::CreateTemporaryFileInDir(dir.path(), &file); |
472 | 500 |
473 operation()->CreateFile(file, false); | 501 operation()->CreateFile(file, false); |
474 MessageLoop::current()->RunAllPending(); | 502 MessageLoop::current()->RunAllPending(); |
475 EXPECT_EQ(kFileOperationSucceeded, mock_dispatcher_->status()); | 503 EXPECT_EQ(kFileOperationSucceeded, mock_dispatcher_->status()); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 | 809 |
782 // Check that its length is now 3 and that it contains only bits of test data. | 810 // Check that its length is now 3 and that it contains only bits of test data. |
783 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); | 811 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); |
784 EXPECT_EQ(length, info.size); | 812 EXPECT_EQ(length, info.size); |
785 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); | 813 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); |
786 for (int i = 0; i < length; ++i) | 814 for (int i = 0; i < length; ++i) |
787 EXPECT_EQ(test_data[i], data[i]); | 815 EXPECT_EQ(test_data[i], data[i]); |
788 } | 816 } |
789 | 817 |
790 } // namespace fileapi | 818 } // namespace fileapi |
OLD | NEW |