OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file.h" | 11 #include "base/files/file.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "content/browser/fileapi/mock_file_change_observer.h" | 16 #include "content/browser/fileapi/mock_file_change_observer.h" |
17 #include "content/public/test/async_file_test_helper.h" | 17 #include "content/public/test/async_file_test_helper.h" |
18 #include "content/public/test/mock_special_storage_policy.h" | 18 #include "content/public/test/mock_special_storage_policy.h" |
19 #include "content/public/test/sandbox_file_system_test_helper.h" | 19 #include "content/public/test/sandbox_file_system_test_helper.h" |
20 #include "content/public/test/test_file_system_context.h" | 20 #include "content/public/test/test_file_system_context.h" |
21 #include "content/test/fileapi_test_file_set.h" | 21 #include "content/test/fileapi_test_file_set.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "webkit/browser/fileapi/external_mount_points.h" | 23 #include "storage/browser/fileapi/external_mount_points.h" |
24 #include "webkit/browser/fileapi/file_system_backend.h" | 24 #include "storage/browser/fileapi/file_system_backend.h" |
25 #include "webkit/browser/fileapi/file_system_context.h" | 25 #include "storage/browser/fileapi/file_system_context.h" |
26 #include "webkit/browser/fileapi/file_system_operation_context.h" | 26 #include "storage/browser/fileapi/file_system_operation_context.h" |
27 #include "webkit/browser/fileapi/file_system_usage_cache.h" | 27 #include "storage/browser/fileapi/file_system_usage_cache.h" |
28 #include "webkit/browser/fileapi/obfuscated_file_util.h" | 28 #include "storage/browser/fileapi/obfuscated_file_util.h" |
29 #include "webkit/browser/fileapi/sandbox_directory_database.h" | 29 #include "storage/browser/fileapi/sandbox_directory_database.h" |
30 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" | 30 #include "storage/browser/fileapi/sandbox_file_system_backend_delegate.h" |
31 #include "webkit/browser/fileapi/sandbox_isolated_origin_database.h" | 31 #include "storage/browser/fileapi/sandbox_isolated_origin_database.h" |
32 #include "webkit/browser/fileapi/sandbox_origin_database.h" | 32 #include "storage/browser/fileapi/sandbox_origin_database.h" |
33 #include "webkit/browser/quota/quota_manager.h" | 33 #include "storage/browser/quota/quota_manager.h" |
34 #include "webkit/common/database/database_identifier.h" | 34 #include "storage/common/database/database_identifier.h" |
35 #include "webkit/common/quota/quota_types.h" | 35 #include "storage/common/quota/quota_types.h" |
36 | 36 |
37 using content::AsyncFileTestHelper; | 37 using content::AsyncFileTestHelper; |
38 using fileapi::FileSystemContext; | 38 using storage::FileSystemContext; |
39 using fileapi::FileSystemOperation; | 39 using storage::FileSystemOperation; |
40 using fileapi::FileSystemOperationContext; | 40 using storage::FileSystemOperationContext; |
41 using fileapi::FileSystemURL; | 41 using storage::FileSystemURL; |
42 using fileapi::ObfuscatedFileUtil; | 42 using storage::ObfuscatedFileUtil; |
43 using fileapi::SandboxDirectoryDatabase; | 43 using storage::SandboxDirectoryDatabase; |
44 using fileapi::SandboxIsolatedOriginDatabase; | 44 using storage::SandboxIsolatedOriginDatabase; |
45 using fileapi::kFileSystemTypeTemporary; | 45 using storage::kFileSystemTypeTemporary; |
46 using fileapi::kFileSystemTypePersistent; | 46 using storage::kFileSystemTypePersistent; |
47 | 47 |
48 namespace content { | 48 namespace content { |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
52 bool FileExists(const base::FilePath& path) { | 52 bool FileExists(const base::FilePath& path) { |
53 return base::PathExists(path) && !base::DirectoryExists(path); | 53 return base::PathExists(path) && !base::DirectoryExists(path); |
54 } | 54 } |
55 | 55 |
56 int64 GetSize(const base::FilePath& path) { | 56 int64 GetSize(const base::FilePath& path) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 FileSystemURL FileSystemURLAppendUTF8( | 114 FileSystemURL FileSystemURLAppendUTF8( |
115 const FileSystemURL& url, const std::string& child) { | 115 const FileSystemURL& url, const std::string& child) { |
116 return FileSystemURL::CreateForTest( | 116 return FileSystemURL::CreateForTest( |
117 url.origin(), | 117 url.origin(), |
118 url.mount_type(), | 118 url.mount_type(), |
119 url.virtual_path().Append(base::FilePath::FromUTF8Unsafe(child))); | 119 url.virtual_path().Append(base::FilePath::FromUTF8Unsafe(child))); |
120 } | 120 } |
121 | 121 |
122 FileSystemURL FileSystemURLDirName(const FileSystemURL& url) { | 122 FileSystemURL FileSystemURLDirName(const FileSystemURL& url) { |
123 return FileSystemURL::CreateForTest( | 123 return FileSystemURL::CreateForTest( |
124 url.origin(), url.mount_type(), | 124 url.origin(), |
125 fileapi::VirtualPath::DirName(url.virtual_path())); | 125 url.mount_type(), |
| 126 storage::VirtualPath::DirName(url.virtual_path())); |
126 } | 127 } |
127 | 128 |
128 std::string GetTypeString(fileapi::FileSystemType type) { | 129 std::string GetTypeString(storage::FileSystemType type) { |
129 return fileapi::SandboxFileSystemBackendDelegate::GetTypeString(type); | 130 return storage::SandboxFileSystemBackendDelegate::GetTypeString(type); |
130 } | 131 } |
131 | 132 |
132 bool HasFileSystemType(ObfuscatedFileUtil::AbstractOriginEnumerator* enumerator, | 133 bool HasFileSystemType(ObfuscatedFileUtil::AbstractOriginEnumerator* enumerator, |
133 fileapi::FileSystemType type) { | 134 storage::FileSystemType type) { |
134 return enumerator->HasTypeDirectory(GetTypeString(type)); | 135 return enumerator->HasTypeDirectory(GetTypeString(type)); |
135 } | 136 } |
136 | 137 |
137 } // namespace | 138 } // namespace |
138 | 139 |
139 // TODO(ericu): The vast majority of this and the other FSFU subclass tests | 140 // TODO(ericu): The vast majority of this and the other FSFU subclass tests |
140 // could theoretically be shared. It would basically be a FSFU interface | 141 // could theoretically be shared. It would basically be a FSFU interface |
141 // compliance test, and only the subclass-specific bits that look into the | 142 // compliance test, and only the subclass-specific bits that look into the |
142 // implementation would need to be written per-subclass. | 143 // implementation would need to be written per-subclass. |
143 class ObfuscatedFileUtilTest : public testing::Test { | 144 class ObfuscatedFileUtilTest : public testing::Test { |
144 public: | 145 public: |
145 ObfuscatedFileUtilTest() | 146 ObfuscatedFileUtilTest() |
146 : origin_(GURL("http://www.example.com")), | 147 : origin_(GURL("http://www.example.com")), |
147 type_(fileapi::kFileSystemTypeTemporary), | 148 type_(storage::kFileSystemTypeTemporary), |
148 weak_factory_(this), | 149 weak_factory_(this), |
149 sandbox_file_system_(origin_, type_), | 150 sandbox_file_system_(origin_, type_), |
150 quota_status_(quota::kQuotaStatusUnknown), | 151 quota_status_(quota::kQuotaStatusUnknown), |
151 usage_(-1) { | 152 usage_(-1) {} |
152 } | |
153 | 153 |
154 virtual void SetUp() { | 154 virtual void SetUp() { |
155 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 155 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
156 | 156 |
157 storage_policy_ = new MockSpecialStoragePolicy(); | 157 storage_policy_ = new MockSpecialStoragePolicy(); |
158 | 158 |
159 quota_manager_ = | 159 quota_manager_ = |
160 new quota::QuotaManager(false /* is_incognito */, | 160 new quota::QuotaManager(false /* is_incognito */, |
161 data_dir_.path(), | 161 data_dir_.path(), |
162 base::MessageLoopProxy::current().get(), | 162 base::MessageLoopProxy::current().get(), |
163 base::MessageLoopProxy::current().get(), | 163 base::MessageLoopProxy::current().get(), |
164 storage_policy_.get()); | 164 storage_policy_.get()); |
165 | 165 |
166 // Every time we create a new sandbox_file_system helper, | 166 // Every time we create a new sandbox_file_system helper, |
167 // it creates another context, which creates another path manager, | 167 // it creates another context, which creates another path manager, |
168 // another sandbox_backend, and another OFU. | 168 // another sandbox_backend, and another OFU. |
169 // We need to pass in the context to skip all that. | 169 // We need to pass in the context to skip all that. |
170 file_system_context_ = CreateFileSystemContextForTesting( | 170 file_system_context_ = CreateFileSystemContextForTesting( |
171 quota_manager_->proxy(), | 171 quota_manager_->proxy(), |
172 data_dir_.path()); | 172 data_dir_.path()); |
173 | 173 |
174 sandbox_file_system_.SetUp(file_system_context_.get()); | 174 sandbox_file_system_.SetUp(file_system_context_.get()); |
175 | 175 |
176 change_observers_ = fileapi::MockFileChangeObserver::CreateList( | 176 change_observers_ = |
177 &change_observer_); | 177 storage::MockFileChangeObserver::CreateList(&change_observer_); |
178 } | 178 } |
179 | 179 |
180 virtual void TearDown() { | 180 virtual void TearDown() { |
181 quota_manager_ = NULL; | 181 quota_manager_ = NULL; |
182 sandbox_file_system_.TearDown(); | 182 sandbox_file_system_.TearDown(); |
183 } | 183 } |
184 | 184 |
185 scoped_ptr<FileSystemOperationContext> LimitedContext( | 185 scoped_ptr<FileSystemOperationContext> LimitedContext( |
186 int64 allowed_bytes_growth) { | 186 int64 allowed_bytes_growth) { |
187 scoped_ptr<FileSystemOperationContext> context( | 187 scoped_ptr<FileSystemOperationContext> context( |
(...skipping 13 matching lines...) Expand all Loading... |
201 if (file_system) | 201 if (file_system) |
202 context = file_system->NewOperationContext(); | 202 context = file_system->NewOperationContext(); |
203 else | 203 else |
204 context = sandbox_file_system_.NewOperationContext(); | 204 context = sandbox_file_system_.NewOperationContext(); |
205 // Setting allowed_bytes_growth big enough for all tests. | 205 // Setting allowed_bytes_growth big enough for all tests. |
206 context->set_allowed_bytes_growth(1024 * 1024); | 206 context->set_allowed_bytes_growth(1024 * 1024); |
207 context->set_change_observers(change_observers()); | 207 context->set_change_observers(change_observers()); |
208 return context; | 208 return context; |
209 } | 209 } |
210 | 210 |
211 const fileapi::ChangeObserverList& change_observers() const { | 211 const storage::ChangeObserverList& change_observers() const { |
212 return change_observers_; | 212 return change_observers_; |
213 } | 213 } |
214 | 214 |
215 fileapi::MockFileChangeObserver* change_observer() { | 215 storage::MockFileChangeObserver* change_observer() { |
216 return &change_observer_; | 216 return &change_observer_; |
217 } | 217 } |
218 | 218 |
219 // This can only be used after SetUp has run and created file_system_context_ | 219 // This can only be used after SetUp has run and created file_system_context_ |
220 // and obfuscated_file_util_. | 220 // and obfuscated_file_util_. |
221 // Use this for tests which need to run in multiple origins; we need a test | 221 // Use this for tests which need to run in multiple origins; we need a test |
222 // helper per origin. | 222 // helper per origin. |
223 SandboxFileSystemTestHelper* NewFileSystem( | 223 SandboxFileSystemTestHelper* NewFileSystem(const GURL& origin, |
224 const GURL& origin, fileapi::FileSystemType type) { | 224 storage::FileSystemType type) { |
225 SandboxFileSystemTestHelper* file_system = | 225 SandboxFileSystemTestHelper* file_system = |
226 new SandboxFileSystemTestHelper(origin, type); | 226 new SandboxFileSystemTestHelper(origin, type); |
227 | 227 |
228 file_system->SetUp(file_system_context_.get()); | 228 file_system->SetUp(file_system_context_.get()); |
229 return file_system; | 229 return file_system; |
230 } | 230 } |
231 | 231 |
232 scoped_ptr<ObfuscatedFileUtil> CreateObfuscatedFileUtil( | 232 scoped_ptr<ObfuscatedFileUtil> CreateObfuscatedFileUtil( |
233 quota::SpecialStoragePolicy* storage_policy) { | 233 quota::SpecialStoragePolicy* storage_policy) { |
234 return scoped_ptr<ObfuscatedFileUtil>( | 234 return scoped_ptr<ObfuscatedFileUtil>( |
235 ObfuscatedFileUtil::CreateForTesting( | 235 ObfuscatedFileUtil::CreateForTesting( |
236 storage_policy, data_dir_path(), NULL, | 236 storage_policy, data_dir_path(), NULL, |
237 base::MessageLoopProxy::current().get())); | 237 base::MessageLoopProxy::current().get())); |
238 } | 238 } |
239 | 239 |
240 ObfuscatedFileUtil* ofu() { | 240 ObfuscatedFileUtil* ofu() { |
241 return static_cast<ObfuscatedFileUtil*>(sandbox_file_system_.file_util()); | 241 return static_cast<ObfuscatedFileUtil*>(sandbox_file_system_.file_util()); |
242 } | 242 } |
243 | 243 |
244 const base::FilePath& test_directory() const { | 244 const base::FilePath& test_directory() const { |
245 return data_dir_.path(); | 245 return data_dir_.path(); |
246 } | 246 } |
247 | 247 |
248 const GURL& origin() const { | 248 const GURL& origin() const { |
249 return origin_; | 249 return origin_; |
250 } | 250 } |
251 | 251 |
252 fileapi::FileSystemType type() const { | 252 storage::FileSystemType type() const { return type_; } |
253 return type_; | |
254 } | |
255 | 253 |
256 std::string type_string() const { | 254 std::string type_string() const { |
257 return GetTypeString(type_); | 255 return GetTypeString(type_); |
258 } | 256 } |
259 | 257 |
260 int64 ComputeTotalFileSize() { | 258 int64 ComputeTotalFileSize() { |
261 return sandbox_file_system_.ComputeCurrentOriginUsage() - | 259 return sandbox_file_system_.ComputeCurrentOriginUsage() - |
262 sandbox_file_system_.ComputeCurrentDirectoryDatabaseUsage(); | 260 sandbox_file_system_.ComputeCurrentDirectoryDatabaseUsage(); |
263 } | 261 } |
264 | 262 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 base::File::Error error = ofu()->GetFileInfo( | 294 base::File::Error error = ofu()->GetFileInfo( |
297 context.get(), url, &file_info, &platform_path); | 295 context.get(), url, &file_info, &platform_path); |
298 return error == base::File::FILE_OK; | 296 return error == base::File::FILE_OK; |
299 } | 297 } |
300 | 298 |
301 bool DirectoryExists(const FileSystemURL& url) { | 299 bool DirectoryExists(const FileSystemURL& url) { |
302 return AsyncFileTestHelper::DirectoryExists(file_system_context(), url); | 300 return AsyncFileTestHelper::DirectoryExists(file_system_context(), url); |
303 } | 301 } |
304 | 302 |
305 int64 usage() const { return usage_; } | 303 int64 usage() const { return usage_; } |
306 fileapi::FileSystemUsageCache* usage_cache() { | 304 storage::FileSystemUsageCache* usage_cache() { |
307 return sandbox_file_system_.usage_cache(); | 305 return sandbox_file_system_.usage_cache(); |
308 } | 306 } |
309 | 307 |
310 FileSystemURL CreateURLFromUTF8(const std::string& path) { | 308 FileSystemURL CreateURLFromUTF8(const std::string& path) { |
311 return sandbox_file_system_.CreateURLFromUTF8(path); | 309 return sandbox_file_system_.CreateURLFromUTF8(path); |
312 } | 310 } |
313 | 311 |
314 int64 PathCost(const FileSystemURL& url) { | 312 int64 PathCost(const FileSystemURL& url) { |
315 return ObfuscatedFileUtil::ComputeFilePathCost(url.path()); | 313 return ObfuscatedFileUtil::ComputeFilePathCost(url.path()); |
316 } | 314 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 int64 usage = sandbox_file_system_.GetCachedOriginUsage(); | 431 int64 usage = sandbox_file_system_.GetCachedOriginUsage(); |
434 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper( | 432 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper( |
435 LimitedContext(requested_growth - 1), &sandbox_file_system_, usage)); | 433 LimitedContext(requested_growth - 1), &sandbox_file_system_, usage)); |
436 } | 434 } |
437 | 435 |
438 void FillTestDirectory( | 436 void FillTestDirectory( |
439 const FileSystemURL& root_url, | 437 const FileSystemURL& root_url, |
440 std::set<base::FilePath::StringType>* files, | 438 std::set<base::FilePath::StringType>* files, |
441 std::set<base::FilePath::StringType>* directories) { | 439 std::set<base::FilePath::StringType>* directories) { |
442 scoped_ptr<FileSystemOperationContext> context; | 440 scoped_ptr<FileSystemOperationContext> context; |
443 std::vector<fileapi::DirectoryEntry> entries; | 441 std::vector<storage::DirectoryEntry> entries; |
444 EXPECT_EQ(base::File::FILE_OK, | 442 EXPECT_EQ(base::File::FILE_OK, |
445 AsyncFileTestHelper::ReadDirectory(file_system_context(), | 443 AsyncFileTestHelper::ReadDirectory(file_system_context(), |
446 root_url, &entries)); | 444 root_url, &entries)); |
447 EXPECT_EQ(0UL, entries.size()); | 445 EXPECT_EQ(0UL, entries.size()); |
448 | 446 |
449 files->clear(); | 447 files->clear(); |
450 files->insert(FILE_PATH_LITERAL("first")); | 448 files->insert(FILE_PATH_LITERAL("first")); |
451 files->insert(FILE_PATH_LITERAL("second")); | 449 files->insert(FILE_PATH_LITERAL("second")); |
452 files->insert(FILE_PATH_LITERAL("third")); | 450 files->insert(FILE_PATH_LITERAL("third")); |
453 directories->clear(); | 451 directories->clear(); |
(...skipping 21 matching lines...) Expand all Loading... |
475 } | 473 } |
476 ValidateTestDirectory(root_url, *files, *directories); | 474 ValidateTestDirectory(root_url, *files, *directories); |
477 } | 475 } |
478 | 476 |
479 void TestReadDirectoryHelper(const FileSystemURL& root_url) { | 477 void TestReadDirectoryHelper(const FileSystemURL& root_url) { |
480 std::set<base::FilePath::StringType> files; | 478 std::set<base::FilePath::StringType> files; |
481 std::set<base::FilePath::StringType> directories; | 479 std::set<base::FilePath::StringType> directories; |
482 FillTestDirectory(root_url, &files, &directories); | 480 FillTestDirectory(root_url, &files, &directories); |
483 | 481 |
484 scoped_ptr<FileSystemOperationContext> context; | 482 scoped_ptr<FileSystemOperationContext> context; |
485 std::vector<fileapi::DirectoryEntry> entries; | 483 std::vector<storage::DirectoryEntry> entries; |
486 context.reset(NewContext(NULL)); | 484 context.reset(NewContext(NULL)); |
487 EXPECT_EQ(base::File::FILE_OK, | 485 EXPECT_EQ(base::File::FILE_OK, |
488 AsyncFileTestHelper::ReadDirectory( | 486 AsyncFileTestHelper::ReadDirectory( |
489 file_system_context(), root_url, &entries)); | 487 file_system_context(), root_url, &entries)); |
490 std::vector<fileapi::DirectoryEntry>::iterator entry_iter; | 488 std::vector<storage::DirectoryEntry>::iterator entry_iter; |
491 EXPECT_EQ(files.size() + directories.size(), entries.size()); | 489 EXPECT_EQ(files.size() + directories.size(), entries.size()); |
492 EXPECT_TRUE(change_observer()->HasNoChange()); | 490 EXPECT_TRUE(change_observer()->HasNoChange()); |
493 for (entry_iter = entries.begin(); entry_iter != entries.end(); | 491 for (entry_iter = entries.begin(); entry_iter != entries.end(); |
494 ++entry_iter) { | 492 ++entry_iter) { |
495 const fileapi::DirectoryEntry& entry = *entry_iter; | 493 const storage::DirectoryEntry& entry = *entry_iter; |
496 std::set<base::FilePath::StringType>::iterator iter = | 494 std::set<base::FilePath::StringType>::iterator iter = |
497 files.find(entry.name); | 495 files.find(entry.name); |
498 if (iter != files.end()) { | 496 if (iter != files.end()) { |
499 EXPECT_FALSE(entry.is_directory); | 497 EXPECT_FALSE(entry.is_directory); |
500 files.erase(iter); | 498 files.erase(iter); |
501 continue; | 499 continue; |
502 } | 500 } |
503 iter = directories.find(entry.name); | 501 iter = directories.find(entry.name); |
504 EXPECT_FALSE(directories.end() == iter); | 502 EXPECT_FALSE(directories.end() == iter); |
505 EXPECT_TRUE(entry.is_directory); | 503 EXPECT_TRUE(entry.is_directory); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 return data_dir_.path(); | 795 return data_dir_.path(); |
798 } | 796 } |
799 | 797 |
800 protected: | 798 protected: |
801 base::ScopedTempDir data_dir_; | 799 base::ScopedTempDir data_dir_; |
802 base::MessageLoop message_loop_; | 800 base::MessageLoop message_loop_; |
803 scoped_refptr<MockSpecialStoragePolicy> storage_policy_; | 801 scoped_refptr<MockSpecialStoragePolicy> storage_policy_; |
804 scoped_refptr<quota::QuotaManager> quota_manager_; | 802 scoped_refptr<quota::QuotaManager> quota_manager_; |
805 scoped_refptr<FileSystemContext> file_system_context_; | 803 scoped_refptr<FileSystemContext> file_system_context_; |
806 GURL origin_; | 804 GURL origin_; |
807 fileapi::FileSystemType type_; | 805 storage::FileSystemType type_; |
808 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_; | 806 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_; |
809 SandboxFileSystemTestHelper sandbox_file_system_; | 807 SandboxFileSystemTestHelper sandbox_file_system_; |
810 quota::QuotaStatusCode quota_status_; | 808 quota::QuotaStatusCode quota_status_; |
811 int64 usage_; | 809 int64 usage_; |
812 fileapi::MockFileChangeObserver change_observer_; | 810 storage::MockFileChangeObserver change_observer_; |
813 fileapi::ChangeObserverList change_observers_; | 811 storage::ChangeObserverList change_observers_; |
814 | 812 |
815 private: | 813 private: |
816 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtilTest); | 814 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtilTest); |
817 }; | 815 }; |
818 | 816 |
819 TEST_F(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) { | 817 TEST_F(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) { |
820 FileSystemURL url = CreateURLFromUTF8("fake/file"); | 818 FileSystemURL url = CreateURLFromUTF8("fake/file"); |
821 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 819 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
822 int file_flags = base::File::FLAG_CREATE | base::File::FLAG_WRITE; | 820 int file_flags = base::File::FLAG_CREATE | base::File::FLAG_WRITE; |
823 | 821 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 | 1208 |
1211 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) { | 1209 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) { |
1212 FileSystemURL url = CreateURLFromUTF8("file"); | 1210 FileSystemURL url = CreateURLFromUTF8("file"); |
1213 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 1211 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
1214 | 1212 |
1215 bool created = false; | 1213 bool created = false; |
1216 ASSERT_EQ(base::File::FILE_OK, | 1214 ASSERT_EQ(base::File::FILE_OK, |
1217 ofu()->EnsureFileExists(context.get(), url, &created)); | 1215 ofu()->EnsureFileExists(context.get(), url, &created)); |
1218 ASSERT_TRUE(created); | 1216 ASSERT_TRUE(created); |
1219 | 1217 |
1220 std::vector<fileapi::DirectoryEntry> entries; | 1218 std::vector<storage::DirectoryEntry> entries; |
1221 EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, | 1219 EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, |
1222 AsyncFileTestHelper::ReadDirectory(file_system_context(), url, | 1220 AsyncFileTestHelper::ReadDirectory(file_system_context(), url, |
1223 &entries)); | 1221 &entries)); |
1224 | 1222 |
1225 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url)); | 1223 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url)); |
1226 } | 1224 } |
1227 | 1225 |
1228 TEST_F(ObfuscatedFileUtilTest, TestTouch) { | 1226 TEST_F(ObfuscatedFileUtilTest, TestTouch) { |
1229 FileSystemURL url = CreateURLFromUTF8("file"); | 1227 FileSystemURL url = CreateURLFromUTF8("file"); |
1230 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 1228 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 scoped_ptr<FileSystemOperationContext> context; | 1786 scoped_ptr<FileSystemOperationContext> context; |
1789 | 1787 |
1790 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) { | 1788 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) { |
1791 bool created = false; | 1789 bool created = false; |
1792 context.reset(NewContext(NULL)); | 1790 context.reset(NewContext(NULL)); |
1793 EXPECT_EQ(base::File::FILE_OK, | 1791 EXPECT_EQ(base::File::FILE_OK, |
1794 ofu()->EnsureFileExists(context.get(), kPath[i], &created)); | 1792 ofu()->EnsureFileExists(context.get(), kPath[i], &created)); |
1795 EXPECT_TRUE(created); | 1793 EXPECT_TRUE(created); |
1796 } | 1794 } |
1797 | 1795 |
1798 std::vector<fileapi::DirectoryEntry> entries; | 1796 std::vector<storage::DirectoryEntry> entries; |
1799 EXPECT_EQ(base::File::FILE_OK, | 1797 EXPECT_EQ(base::File::FILE_OK, |
1800 AsyncFileTestHelper::ReadDirectory( | 1798 AsyncFileTestHelper::ReadDirectory( |
1801 file_system_context(), empty_path, &entries)); | 1799 file_system_context(), empty_path, &entries)); |
1802 EXPECT_EQ(3u, entries.size()); | 1800 EXPECT_EQ(3u, entries.size()); |
1803 | 1801 |
1804 base::FilePath local_path; | 1802 base::FilePath local_path; |
1805 EXPECT_EQ(base::File::FILE_OK, | 1803 EXPECT_EQ(base::File::FILE_OK, |
1806 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); | 1804 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); |
1807 EXPECT_TRUE(base::DeleteFile(local_path, false)); | 1805 EXPECT_TRUE(base::DeleteFile(local_path, false)); |
1808 | 1806 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 ofu()->GetLocalFilePath(context.get(), url1, &file_path)); | 2031 ofu()->GetLocalFilePath(context.get(), url1, &file_path)); |
2034 EXPECT_FALSE(file_path.empty()); | 2032 EXPECT_FALSE(file_path.empty()); |
2035 | 2033 |
2036 context.reset(NewContext(NULL)); | 2034 context.reset(NewContext(NULL)); |
2037 EXPECT_EQ(base::File::FILE_OK, | 2035 EXPECT_EQ(base::File::FILE_OK, |
2038 ofu()->Touch(context.get(), url1, | 2036 ofu()->Touch(context.get(), url1, |
2039 base::Time::Now() + base::TimeDelta::FromHours(1), | 2037 base::Time::Now() + base::TimeDelta::FromHours(1), |
2040 base::Time())); | 2038 base::Time())); |
2041 | 2039 |
2042 context.reset(NewContext(NULL)); | 2040 context.reset(NewContext(NULL)); |
2043 scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator> file_enum( | 2041 scoped_ptr<storage::FileSystemFileUtil::AbstractFileEnumerator> file_enum( |
2044 ofu()->CreateFileEnumerator(context.get(), dir, false)); | 2042 ofu()->CreateFileEnumerator(context.get(), dir, false)); |
2045 | 2043 |
2046 int count = 0; | 2044 int count = 0; |
2047 base::FilePath file_path_each; | 2045 base::FilePath file_path_each; |
2048 while (!(file_path_each = file_enum->Next()).empty()) { | 2046 while (!(file_path_each = file_enum->Next()).empty()) { |
2049 context.reset(NewContext(NULL)); | 2047 context.reset(NewContext(NULL)); |
2050 base::File::Info file_info; | 2048 base::File::Info file_info; |
2051 base::FilePath file_path; | 2049 base::FilePath file_path; |
2052 EXPECT_EQ(base::File::FILE_OK, | 2050 EXPECT_EQ(base::File::FILE_OK, |
2053 ofu()->GetFileInfo(context.get(), | 2051 ofu()->GetFileInfo(context.get(), |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 false /* exclusive */, | 2445 false /* exclusive */, |
2448 true /* recursive */)); | 2446 true /* recursive */)); |
2449 ASSERT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, | 2447 ASSERT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, |
2450 ofu()->CreateDirectory(UnlimitedContext().get(), | 2448 ofu()->CreateDirectory(UnlimitedContext().get(), |
2451 path_in_file_in_file, | 2449 path_in_file_in_file, |
2452 false /* exclusive */, | 2450 false /* exclusive */, |
2453 true /* recursive */)); | 2451 true /* recursive */)); |
2454 } | 2452 } |
2455 | 2453 |
2456 } // namespace content | 2454 } // namespace content |
OLD | NEW |