Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 class FileSystemFileUtilTest : public testing::Test { | 57 class FileSystemFileUtilTest : public testing::Test { |
| 58 public: | 58 public: |
| 59 FileSystemFileUtilTest() { | 59 FileSystemFileUtilTest() { |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SetUp() { | 62 void SetUp() { |
| 63 } | 63 } |
| 64 | 64 |
| 65 FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) { | 65 FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) { |
| 66 FileSystemOperationContext* context = helper->NewOperationContext(); | 66 FileSystemOperationContext* context = helper->NewOperationContext(); |
| 67 // We need to allocate quota for paths for | |
| 68 // TestCrossFileSystemCopyMoveHelper, since it calls into OFSFU, which | |
| 69 // charges quota for paths. | |
|
Dai Mikurube (NOT FULLTIME)
2011/08/16 05:11:00
Does this test require OFSFU? Or could it be in O
ericu
2011/08/16 21:16:31
The cross-filesystem copy/move is a FSFU method.
| |
| 70 context->set_allowed_bytes_growth(1024 * 1024); | |
| 67 return context; | 71 return context; |
| 68 } | 72 } |
| 69 | 73 |
| 70 void TestCrossFileSystemCopyMoveHelper( | 74 void TestCrossFileSystemCopyMoveHelper( |
| 71 const GURL& src_origin, fileapi::FileSystemType src_type, | 75 const GURL& src_origin, fileapi::FileSystemType src_type, |
| 72 const GURL& dest_origin, fileapi::FileSystemType dest_type, | 76 const GURL& dest_origin, fileapi::FileSystemType dest_type, |
| 73 bool copy) { | 77 bool copy) { |
| 74 ScopedTempDir base_dir; | 78 ScopedTempDir base_dir; |
| 75 ASSERT_TRUE(base_dir.CreateUniqueTempDir()); | 79 ASSERT_TRUE(base_dir.CreateUniqueTempDir()); |
| 76 scoped_refptr<ObfuscatedFileSystemFileUtil> file_util( | 80 scoped_refptr<ObfuscatedFileSystemFileUtil> file_util( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 // Do the actual copy or move. | 114 // Do the actual copy or move. |
| 111 FileSystemContext* file_system_context = dest_helper.file_system_context(); | 115 FileSystemContext* file_system_context = dest_helper.file_system_context(); |
| 112 scoped_ptr<FileSystemOperationContext> copy_context( | 116 scoped_ptr<FileSystemOperationContext> copy_context( |
| 113 new FileSystemOperationContext(file_system_context, NULL)); | 117 new FileSystemOperationContext(file_system_context, NULL)); |
| 114 copy_context->set_src_file_system_file_util(file_util); | 118 copy_context->set_src_file_system_file_util(file_util); |
| 115 copy_context->set_dest_file_system_file_util(file_util); | 119 copy_context->set_dest_file_system_file_util(file_util); |
| 116 copy_context->set_src_origin_url(src_helper.origin()); | 120 copy_context->set_src_origin_url(src_helper.origin()); |
| 117 copy_context->set_dest_origin_url(dest_helper.origin()); | 121 copy_context->set_dest_origin_url(dest_helper.origin()); |
| 118 copy_context->set_src_type(src_helper.type()); | 122 copy_context->set_src_type(src_helper.type()); |
| 119 copy_context->set_dest_type(dest_helper.type()); | 123 copy_context->set_dest_type(dest_helper.type()); |
| 124 copy_context->set_allowed_bytes_growth(1024 * 1024); // OFSFU path quota. | |
| 120 | 125 |
| 121 if (copy) | 126 if (copy) |
| 122 ASSERT_EQ(base::PLATFORM_FILE_OK, | 127 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 123 file_util->Copy(copy_context.get(), test_root, test_root)); | 128 file_util->Copy(copy_context.get(), test_root, test_root)); |
| 124 else | 129 else |
| 125 ASSERT_EQ(base::PLATFORM_FILE_OK, | 130 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 126 file_util->Move(copy_context.get(), test_root, test_root)); | 131 file_util->Move(copy_context.get(), test_root, test_root)); |
| 127 | 132 |
| 128 // Validate that the destination paths are correct. | 133 // Validate that the destination paths are correct. |
| 129 for (size_t i = 0; i < arraysize(kCopyMoveTestCases); ++i) { | 134 for (size_t i = 0; i < arraysize(kCopyMoveTestCases); ++i) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 TestCrossFileSystemCopyMoveHelper(src_origin, type, dest_origin, type, false); | 200 TestCrossFileSystemCopyMoveHelper(src_origin, type, dest_origin, type, false); |
| 196 } | 201 } |
| 197 | 202 |
| 198 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) { | 203 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) { |
| 199 GURL origin("http://www.example.com"); | 204 GURL origin("http://www.example.com"); |
| 200 fileapi::FileSystemType src_type = kFileSystemTypePersistent; | 205 fileapi::FileSystemType src_type = kFileSystemTypePersistent; |
| 201 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary; | 206 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary; |
| 202 | 207 |
| 203 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false); | 208 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false); |
| 204 } | 209 } |
| OLD | NEW |