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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 12 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 13 #include "webkit/fileapi/file_system_file_util.h" |
13 #include "webkit/fileapi/file_system_operation.h" | 14 #include "webkit/fileapi/file_system_operation.h" |
14 | 15 |
15 namespace fileapi { | 16 namespace fileapi { |
16 | 17 |
17 const int kFileOperationStatusNotSet = 1; | 18 const int kFileOperationStatusNotSet = 1; |
18 const int kFileOperationSucceeded = 0; | 19 const int kFileOperationSucceeded = 0; |
19 | 20 |
20 static bool FileExists(FilePath path) { | 21 static bool FileExists(FilePath path) { |
21 return file_util::PathExists(path) && !file_util::DirectoryExists(path); | 22 return file_util::PathExists(path) && !file_util::DirectoryExists(path); |
22 } | 23 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 91 |
91 virtual void DidWrite(int64 bytes, bool complete) { | 92 virtual void DidWrite(int64 bytes, bool complete) { |
92 NOTREACHED(); | 93 NOTREACHED(); |
93 } | 94 } |
94 | 95 |
95 private: | 96 private: |
96 FileSystemOperationTest* test_; | 97 FileSystemOperationTest* test_; |
97 }; | 98 }; |
98 | 99 |
99 FileSystemOperation* FileSystemOperationTest::operation() { | 100 FileSystemOperation* FileSystemOperationTest::operation() { |
100 return new FileSystemOperation( | 101 FileSystemOperation* operation = new FileSystemOperation( |
101 new MockDispatcher(this), | 102 new MockDispatcher(this), |
102 base::MessageLoopProxy::CreateForCurrentThread(), | 103 base::MessageLoopProxy::CreateForCurrentThread(), |
103 NULL); | 104 NULL, |
| 105 FileSystemFileUtil::GetInstance()); |
| 106 operation->file_system_operation_context()->set_src_type( |
| 107 kFileSystemTypeTemporary); |
| 108 operation->file_system_operation_context()->set_dest_type( |
| 109 kFileSystemTypeTemporary); |
| 110 return operation; |
104 } | 111 } |
105 | 112 |
106 TEST_F(FileSystemOperationTest, TestMoveFailureSrcDoesntExist) { | 113 TEST_F(FileSystemOperationTest, TestMoveFailureSrcDoesntExist) { |
107 FilePath src(base_.path().Append(FILE_PATH_LITERAL("a"))); | 114 FilePath src(base_.path().Append(FILE_PATH_LITERAL("a"))); |
108 FilePath dest(base_.path().Append(FILE_PATH_LITERAL("b"))); | 115 FilePath dest(base_.path().Append(FILE_PATH_LITERAL("b"))); |
109 operation()->Move(src, dest); | 116 operation()->Move(src, dest); |
110 MessageLoop::current()->RunAllPending(); | 117 MessageLoop::current()->RunAllPending(); |
111 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); | 118 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
112 } | 119 } |
113 | 120 |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 748 |
742 // Check that its length is now 3 and that it contains only bits of test data. | 749 // Check that its length is now 3 and that it contains only bits of test data. |
743 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); | 750 EXPECT_TRUE(file_util::GetFileInfo(file, &info)); |
744 EXPECT_EQ(length, info.size); | 751 EXPECT_EQ(length, info.size); |
745 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); | 752 EXPECT_EQ(length, file_util::ReadFile(file, data, length)); |
746 for (int i = 0; i < length; ++i) | 753 for (int i = 0; i < length; ++i) |
747 EXPECT_EQ(test_data[i], data[i]); | 754 EXPECT_EQ(test_data[i], data[i]); |
748 } | 755 } |
749 | 756 |
750 } // namespace fileapi | 757 } // namespace fileapi |
OLD | NEW |