| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 src_root, dest_root)); | 109 src_root, dest_root)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Validate that the destination paths are correct. | 112 // Validate that the destination paths are correct. |
| 113 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { | 113 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { |
| 114 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; | 114 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; |
| 115 FileSystemURL url = dest_root.WithPath( | 115 FileSystemURL url = dest_root.WithPath( |
| 116 dest_root.path().Append(test_case.path)); | 116 dest_root.path().Append(test_case.path)); |
| 117 | 117 |
| 118 base::PlatformFileInfo dest_file_info; | 118 base::PlatformFileInfo dest_file_info; |
| 119 FilePath data_path; | 119 base::FilePath data_path; |
| 120 context.reset(NewContext(&dest_helper)); | 120 context.reset(NewContext(&dest_helper)); |
| 121 EXPECT_EQ(base::PLATFORM_FILE_OK, | 121 EXPECT_EQ(base::PLATFORM_FILE_OK, |
| 122 file_util->GetFileInfo( | 122 file_util->GetFileInfo( |
| 123 context.get(), url, &dest_file_info, &data_path)); | 123 context.get(), url, &dest_file_info, &data_path)); |
| 124 if (test_case.is_directory) { | 124 if (test_case.is_directory) { |
| 125 EXPECT_TRUE(dest_file_info.is_directory); | 125 EXPECT_TRUE(dest_file_info.is_directory); |
| 126 } else { | 126 } else { |
| 127 base::PlatformFileInfo platform_file_info; | 127 base::PlatformFileInfo platform_file_info; |
| 128 ASSERT_TRUE(file_util::GetFileInfo(data_path, &platform_file_info)); | 128 ASSERT_TRUE(file_util::GetFileInfo(data_path, &platform_file_info)); |
| 129 EXPECT_EQ(test_case.data_file_size, platform_file_info.size); | 129 EXPECT_EQ(test_case.data_file_size, platform_file_info.size); |
| 130 EXPECT_FALSE(platform_file_info.is_directory); | 130 EXPECT_FALSE(platform_file_info.is_directory); |
| 131 EXPECT_EQ(platform_file_info.size, dest_file_info.size); | 131 EXPECT_EQ(platform_file_info.size, dest_file_info.size); |
| 132 EXPECT_FALSE(dest_file_info.is_directory); | 132 EXPECT_FALSE(dest_file_info.is_directory); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Validate that the source paths are still there [for a copy] or gone [for | 136 // Validate that the source paths are still there [for a copy] or gone [for |
| 137 // a move]. | 137 // a move]. |
| 138 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { | 138 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { |
| 139 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; | 139 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; |
| 140 FileSystemURL url = src_root.WithPath( | 140 FileSystemURL url = src_root.WithPath( |
| 141 src_root.path().Append(test_case.path)); | 141 src_root.path().Append(test_case.path)); |
| 142 base::PlatformFileInfo src_file_info; | 142 base::PlatformFileInfo src_file_info; |
| 143 FilePath data_path; | 143 base::FilePath data_path; |
| 144 context.reset(NewContext(&src_helper)); | 144 context.reset(NewContext(&src_helper)); |
| 145 base::PlatformFileError expected_result; | 145 base::PlatformFileError expected_result; |
| 146 if (copy) | 146 if (copy) |
| 147 expected_result = base::PLATFORM_FILE_OK; | 147 expected_result = base::PLATFORM_FILE_OK; |
| 148 else | 148 else |
| 149 expected_result = base::PLATFORM_FILE_ERROR_NOT_FOUND; | 149 expected_result = base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 150 EXPECT_EQ(expected_result, | 150 EXPECT_EQ(expected_result, |
| 151 file_util->GetFileInfo( | 151 file_util->GetFileInfo( |
| 152 context.get(), url, &src_file_info, &data_path)); | 152 context.get(), url, &src_file_info, &data_path)); |
| 153 } | 153 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 184 | 184 |
| 185 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) { | 185 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) { |
| 186 GURL origin("http://www.example.com"); | 186 GURL origin("http://www.example.com"); |
| 187 fileapi::FileSystemType src_type = kFileSystemTypePersistent; | 187 fileapi::FileSystemType src_type = kFileSystemTypePersistent; |
| 188 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary; | 188 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary; |
| 189 | 189 |
| 190 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false); | 190 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace fileapi | 193 } // namespace fileapi |
| OLD | NEW |