| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 virtual void DidWrite(int64 bytes, bool complete) { | 91 virtual void DidWrite(int64 bytes, bool complete) { |
| 92 NOTREACHED(); | 92 NOTREACHED(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 FileSystemOperationTest* test_; | 96 FileSystemOperationTest* test_; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 FileSystemOperation* FileSystemOperationTest::operation() { | 99 FileSystemOperation* FileSystemOperationTest::operation() { |
| 100 return new FileSystemOperation( | 100 FileSystemOperation* operation = new FileSystemOperation( |
| 101 new MockDispatcher(this), | 101 new MockDispatcher(this), |
| 102 base::MessageLoopProxy::CreateForCurrentThread(), | 102 base::MessageLoopProxy::CreateForCurrentThread(), |
| 103 NULL); | 103 NULL); |
| 104 operation->file_system_operation_context()->set_src_type( |
| 105 kFileSystemTypeTemporary); |
| 106 operation->file_system_operation_context()->set_dest_type( |
| 107 kFileSystemTypeTemporary); |
| 108 return operation; |
| 104 } | 109 } |
| 105 | 110 |
| 106 TEST_F(FileSystemOperationTest, TestMoveFailureSrcDoesntExist) { | 111 TEST_F(FileSystemOperationTest, TestMoveFailureSrcDoesntExist) { |
| 107 FilePath src(base_.path().Append(FILE_PATH_LITERAL("a"))); | 112 FilePath src(base_.path().Append(FILE_PATH_LITERAL("a"))); |
| 108 FilePath dest(base_.path().Append(FILE_PATH_LITERAL("b"))); | 113 FilePath dest(base_.path().Append(FILE_PATH_LITERAL("b"))); |
| 109 operation()->Move(src, dest); | 114 operation()->Move(src, dest); |
| 110 MessageLoop::current()->RunAllPending(); | 115 MessageLoop::current()->RunAllPending(); |
| 111 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); | 116 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| 112 } | 117 } |
| 113 | 118 |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 746 |
| 742 // Check that its length is now 3 and that it contains only bits of test data. | 747 // Check that its length is now 3 and that it contains only bits of test data. |
| 743 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); | 748 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); |
| 744 EXPECT_EQ(length, info.size); | 749 EXPECT_EQ(length, info.size); |
| 745 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); | 750 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); |
| 746 for (int i = 0; i < length; ++i) | 751 for (int i = 0; i < length; ++i) |
| 747 EXPECT_EQ(test_data[i], data[i]); | 752 EXPECT_EQ(test_data[i], data[i]); |
| 748 } | 753 } |
| 749 | 754 |
| 750 } // namespace fileapi | 755 } // namespace fileapi |
| OLD | NEW |