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/stl_util.h" | 5 #include "base/stl_util.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "webkit/browser/fileapi/file_system_file_util.h" | 7 #include "webkit/browser/fileapi/file_system_file_util.h" |
8 #include "webkit/fileapi/file_system_context.h" | 8 #include "webkit/fileapi/file_system_context.h" |
9 #include "webkit/fileapi/file_system_operation_context.h" | 9 #include "webkit/fileapi/file_system_operation_context.h" |
10 #include "webkit/fileapi/file_system_task_runners.h" | 10 #include "webkit/fileapi/file_system_task_runners.h" |
11 #include "webkit/fileapi/file_system_types.h" | 11 #include "webkit/fileapi/file_system_types.h" |
12 #include "webkit/fileapi/isolated_context.h" | 12 #include "webkit/fileapi/isolated_context.h" |
13 #include "webkit/fileapi/local_file_system_operation.h" | 13 #include "webkit/fileapi/local_file_system_operation.h" |
14 #include "webkit/fileapi/local_file_system_test_helper.h" | 14 #include "webkit/fileapi/sandbox_file_system_test_helper.h" |
15 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" | 15 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" |
16 #include "webkit/fileapi/syncable/local_file_change_tracker.h" | 16 #include "webkit/fileapi/syncable/local_file_change_tracker.h" |
17 #include "webkit/fileapi/syncable/local_file_sync_context.h" | 17 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
18 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 18 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
19 #include "webkit/quota/quota_manager.h" | 19 #include "webkit/quota/quota_manager.h" |
20 #include "webkit/quota/quota_types.h" | 20 #include "webkit/quota/quota_types.h" |
21 | 21 |
22 using base::PlatformFileError; | 22 using base::PlatformFileError; |
23 using fileapi::FileSystemContext; | 23 using fileapi::FileSystemContext; |
24 using fileapi::FileSystemOperationContext; | 24 using fileapi::FileSystemOperationContext; |
25 using fileapi::FileSystemURL; | 25 using fileapi::FileSystemURL; |
26 using fileapi::FileSystemURLSet; | 26 using fileapi::FileSystemURLSet; |
27 using fileapi::LocalFileSystemTestOriginHelper; | 27 using fileapi::SandboxFileSystemTestHelper; |
28 using quota::QuotaManager; | 28 using quota::QuotaManager; |
29 using quota::QuotaStatusCode; | 29 using quota::QuotaStatusCode; |
30 | 30 |
31 namespace sync_file_system { | 31 namespace sync_file_system { |
32 | 32 |
33 class SyncableFileSystemTest : public testing::Test { | 33 class SyncableFileSystemTest : public testing::Test { |
34 public: | 34 public: |
35 SyncableFileSystemTest() | 35 SyncableFileSystemTest() |
36 : file_system_(GURL("http://example.com/"), "test", | 36 : file_system_(GURL("http://example.com/"), "test", |
37 base::MessageLoopProxy::current(), | 37 base::MessageLoopProxy::current(), |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 TEST_F(SyncableFileSystemTest, DisableDirectoryOperations) { | 241 TEST_F(SyncableFileSystemTest, DisableDirectoryOperations) { |
242 SetEnableSyncFSDirectoryOperation(false); | 242 SetEnableSyncFSDirectoryOperation(false); |
243 EXPECT_EQ(base::PLATFORM_FILE_OK, | 243 EXPECT_EQ(base::PLATFORM_FILE_OK, |
244 file_system_.OpenFileSystem()); | 244 file_system_.OpenFileSystem()); |
245 | 245 |
246 // Try some directory operations (which should fail). | 246 // Try some directory operations (which should fail). |
247 EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, | 247 EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, |
248 file_system_.CreateDirectory(URL("dir"))); | 248 file_system_.CreateDirectory(URL("dir"))); |
249 | 249 |
250 // Set up another (non-syncable) local file system. | 250 // Set up another (non-syncable) local file system. |
251 LocalFileSystemTestOriginHelper other_file_system_( | 251 SandboxFileSystemTestHelper other_file_system_( |
252 GURL("http://foo.com/"), fileapi::kFileSystemTypeTemporary); | 252 GURL("http://foo.com/"), fileapi::kFileSystemTypeTemporary); |
253 other_file_system_.SetUp(file_system_.file_system_context()); | 253 other_file_system_.SetUp(file_system_.file_system_context()); |
254 | 254 |
255 // Create directory '/a' and file '/a/b' in the other file system. | 255 // Create directory '/a' and file '/a/b' in the other file system. |
256 const FileSystemURL kSrcDir = other_file_system_.CreateURLFromUTF8("/a"); | 256 const FileSystemURL kSrcDir = other_file_system_.CreateURLFromUTF8("/a"); |
257 const FileSystemURL kSrcChild = other_file_system_.CreateURLFromUTF8("/a/b"); | 257 const FileSystemURL kSrcChild = other_file_system_.CreateURLFromUTF8("/a/b"); |
258 | 258 |
259 bool created = false; | 259 bool created = false; |
260 scoped_ptr<FileSystemOperationContext> operation_context; | 260 scoped_ptr<FileSystemOperationContext> operation_context; |
261 | 261 |
(...skipping 13 matching lines...) Expand all Loading... |
275 | 275 |
276 // Now try copying the directory into the syncable file system, which should | 276 // Now try copying the directory into the syncable file system, which should |
277 // fail if directory operation is disabled. (http://crbug.com/161442) | 277 // fail if directory operation is disabled. (http://crbug.com/161442) |
278 EXPECT_NE(base::PLATFORM_FILE_OK, | 278 EXPECT_NE(base::PLATFORM_FILE_OK, |
279 file_system_.Copy(kSrcDir, URL("dest"))); | 279 file_system_.Copy(kSrcDir, URL("dest"))); |
280 | 280 |
281 other_file_system_.TearDown(); | 281 other_file_system_.TearDown(); |
282 } | 282 } |
283 | 283 |
284 } // namespace sync_file_system | 284 } // namespace sync_file_system |
OLD | NEW |